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.

Allow for multiple response schemas for each response code

See original GitHub issue

Example

  responses:
    200:
      description: An array of events
      schema:
        type: array
        items:
          $ref: '#/definitions/Event'
    200:
      description: |
        An array of flattened events. This is the response
        object when singleEvents is True.
      schema:
        type: array
        items:
          $ref: '#/definitions/EventFlat'
    default:
      description: Unexpected error
      schema:
        $ref: '#/definitions/Error'

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:162
  • Comments:81 (25 by maintainers)

github_iconTop GitHub Comments

223reactions
webroncommented, Feb 9, 2015

I doubt we’ll support that any time soon. One of the leading principles we have behind Swagger is API determinism. By saying that a single response may return various object types, that pretty much breaks that principle.

101reactions
mclatecommented, Jun 22, 2015

Also would vote for adding multiple responses with the same code. The best example would be any 400 (Bad request) error which can be caused by many reasons. Take in example validation errors: missing fields, extra fields passed or simply wrong data provided - these all are different errors grouped under the same status code where exact error is returned in response playload, which may vary for each situation. This is still considered as deterministic behaviour as it is uniquely defined in response playload.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger; specify two responses with same code based on ...
OAS2 does not support multiple response schemas per status code. You can only have a single schema, for example, a free-form object (...
Read more >
Swagger: Specify Two Responses with the Same ... - Baeldung
Learn how to write an API specification that returns two different objects for the same response code using Java and Swagger.
Read more >
Describing Responses - Swagger
Under responses , each response definition starts with a status code, such as 200 or 404. ... This is useful if multiple media...
Read more >
Swagger responses - Multiple response codes with t...
Hi! Is it possible to have multiple codes use the same schema without duplicating the schema-reference? I.e.: responses: '202': description: ...
Read more >
Multiple messages for the same http status code not displayed.
What you can do is have a single 400 response code description describing the multiple options..
Read more >

github_iconTop Related Medium Post

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