Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response schema type "file" not supported #491

Closed
hamx0r opened this issue Jun 12, 2015 · 6 comments
Closed

Response schema type "file" not supported #491

hamx0r opened this issue Jun 12, 2015 · 6 comments

Comments

@hamx0r
Copy link

hamx0r commented Jun 12, 2015

Per Response Object documentation, a schema with "type" of "file" is allowed. However, the Swagger Editor claims theres an error in this spec fragment:

{
  "basePath": "/", 
  "definitions": {
    "Unauthorized": {
      "description": "Unauthorized", 
      "properties": {
        "errors": {
          "items": {
            "properties": {
              "id": {
                "type": "string"
              }, 
              "message": {
                "type": "string"
              }
            }, 
            "title": "Error item", 
            "type": "object"
          }, 
          "type": "array"
        }, 
        "status": {
          "type": "string"
        }
      }, 
      "required": [
        "status", 
        "errors"
      ]
    }
  }, 
  "info": {
    "contact": {
      "email": "me@github.com", 
      "name": "Broken File Response Type"
    }, 
    "title": "File Response API", 
    "version": "0.1"
  }, 
  "paths": {
    "/flights/csv/{flight_id}": {
      "get": {
        "parameters": [
          {
            "description": "CSV list of flight IDs", 
            "in": "path", 
            "name": "flight_id", 
            "required": true, 
            "type": "string"
          }, 
          {
            "description": "Pagination Range: items=500-999)", 
            "in": "header", 
            "name": "Range", 
            "pattern": "items=([0-9]+)\\-([0-9]+)", 
            "required": false, 
            "type": "string"
          }
        ], 
        "produces": [
          "application/zip"
        ], 
        "responses": {
          "200": {
            "description": "CSV ZIP File", 
            "schema": {
              "type": "file"
            }
          }, 
          "401": {
            "description": "Unauthorized", 
            "examples": {
              "application/json": {
                "errors": [
                  {
                    "id": "3NhNMUKzTTqEa8GI-MT7wA", 
                    "message": "401 Client Error: Unauthorized"
                  }
                ], 
                "status": "error"
              }
            }, 
            "schema": {
              "$ref": "#/definitions/Unauthorized"
            }
          }, 
          "403": {
            "description": "Forbidden", 
            "schema": {
              "type": "string"
            }
          }, 
          "500": {
            "description": "Internal Server Error", 
            "schema": {
              "type": "string"
            }
          }
        }, 
        "summary": "\n        Return CSV of flights, one for each flight \"id\" (a CSV list of id's is acceptable)\n        ", 
        "tags": [
          "flights"
        ]
      }, 
      "parameters": [
        {
          "in": "path", 
          "name": "flight_id", 
          "required": true, 
          "type": "string"
        }
      ]
    } 
  }, 
  "security": [
    {
      "view": []
    }
  ], 
  "securityDefinitions": {
    "view": {
      "in": "header", 
      "name": "X-Identity-Token", 
      "type": "apiKey"
    }
  }, 
  "swagger": "2.0", 
  "tags": [
    {
      "description": "???", 
      "name": "flights"
    }
  ]
}
@mohsen1
Copy link
Contributor

mohsen1 commented Jun 14, 2015

@webron should know, this error is a schema error.

@webron
Copy link
Contributor

webron commented Jun 15, 2015

Yup, this is filed here - OAI/OpenAPI-Specification#260. I'll try to get around to resolving it this week.

@Srithar-ccs
Copy link

Hi All, I am also facing this issue, Pls help on this,

OAI/OpenAPI-Specification#446

@webron
Copy link
Contributor

webron commented Aug 23, 2015

@Srithar-ccs - what you described in the google group, and swagger-spec has nothing to do with this issue. Right now, you're not making it easier for us to help you by writing about it all over the place.

@Srithar-ccs
Copy link

i am sorry webron.

@mohsen1 mohsen1 closed this as completed Sep 9, 2015
@mohsen1 mohsen1 added this to the 2.9.7 milestone Sep 9, 2015
@yiyeguhu
Copy link

@webron
Can we have a complete example including "produces" field to show how to use file in response type?

Particularly, I have a doubt, say, in the example in the 1st comment: we can have multiple response types: file, Reference, and string. But the example only specifies "application/zip" as "produces" field. Does this do the work? What should we do in this scenario?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants