question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting Swagger error when specifying "file" as response type

See original GitHub issue

My API can return either JSON or compressed files. I set the following top-level producesspec:

produces:
  - application/json
  - application/x-gzip

However, when on one of my endpoints I specify the following:

responses:
  "200":
    description: Success
      schema:
        type: file

I get the following Swagger Error: Validation error: enum, with an error path pointing to the type: file above.

The specs are not entirely clear to me as to how I should format an endpoint that returns a compressed file, but the above was the result of my understanding. Is this a bug or was my understanding incorrect? If the latter, could someone enlighten me?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Cloudmersivecommented, Feb 16, 2018

Why was this closed, even though it is not fixed?

1reaction
rkyokucommented, Aug 1, 2015

I still get this error using editor.swagger.io:

0: Object
    code:  "ENUM_MISMATCH"
    message:  "No enum match for: file"
    path: Array [2]
        0:  "schema"
        1:  "type"

And my schema file:

      responses:
        '200':
          schema:
            type: file
          headers:
            Content-type:
              type: string
              description: text/csv; charset=utf-8
            Content-Disposition:
              type: string
              description: attachment; filename=myfile.csv
          description: Export data into a CSV file

Should I do something in particular to benefit from the bugfix?

My current workaround is to use type string

Read more comments on GitHub >

github_iconTop Results From Across the Web

Describing Responses - Swagger
To specify the response media types, use the content keyword at the operation level. ... For example, you can describe the conditions for...
Read more >
Swagger editor is throwing error while specifying the response ...
I am trying to generate the API documentation using swagger editor. I specified my API specification as follow paths ...
Read more >
Fix Swagger Validator errors in Power Platform connectors
The MIME type that you are trying to use isn't compatible with the content of your request in the specified operation.
Read more >
Enriched Web API Documentation using Swagger/OpenAPI in ...
Update the controller actions to specify the possible response codes and their response types (if any) by using the response tag and the ......
Read more >
Swagger: Specify Two Responses with the Same ... - Baeldung
The speed is an Integer. Using OpenAPI, these definitions correspond to the following description: Car: type: object properties: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found