File upload with custom headers a content-type

57 views
Skip to first unread message

Fabio Maulo

unread,
Nov 8, 2016, 2:43:55 PM11/8/16
to Swagger
Hi all.
I have tried different combination of parameter types but I can't achieve to document the real method behavior.
The POST needs two required custom headers ("docs-tenant" and "docs-meta") and the entirely body-content is just a file (jpg,pdf,xml, whatever); the content-type of the request should be the MIME-type of the request content.

The follow is my "last-try" 
      "post": {
        "tags": [
          "Documents"
        ],
        "operationId": "Create",
        "consumes": [
          "multipart/form-data"
        ],
        "produces": [
          "application/json",
          "text/json",
          "application/xml",
          "text/xml"
        ],
        "parameters": [
          {
            "name": "docs-tenant",
            "in": "header",
            "required": true,
            "type": "string"
          },
          {
            "name": "docs-meta",
            "in": "header",
            "required": true,
            "type": "string"
          },
          {
            "name": "document",
            "in": "body",
            "required": true,
            "schema": {
              "type": "file"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/DocumentMetadata"
            }
          },
          "201": {
            "description": "Created"
          },
          "400": {
            "description": "BadRequest"
          },
          "409": {
            "description": "Conflict"
          }
        },
        "deprecated": false
      }

Is there a way to document the behavior I'm having in the API ?
Is there a way to document something closer without incur in a schema validation error ?

Thanks in advance.
--
Fabio

tony tam

unread,
Nov 28, 2016, 4:37:36 PM11/28/16
to swagger-sw...@googlegroups.com
You can do this, but the swagger-ui won’t know how to render it.  If you read the spec, the only supported UI upload is with multi-part form data

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fabio Maulo

unread,
Nov 29, 2016, 9:03:34 AM11/29/16
to swagger-sw...@googlegroups.com
Unfortunately the problem is not SwaggerUI.
My swagger JSON is not valid when I use a swagger validator as http://editor.swagger.io/
This is the error:


Is there a way to document something closer without incur in a schema validation error ?

Thanks.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/_UM_CkjVr_Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
--
Fabio Maulo
T @fabiomaulo

tony tam

unread,
Nov 29, 2016, 11:58:45 AM11/29/16
to swagger-sw...@googlegroups.com
You cannot use type “file” in any location other than as a multipart/form-data input.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages