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

Fixing response documentation for OpenAPI 3.x #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rusnyder
Copy link

Currently, the responses OpenAPI docs are generated in OpenAPI 2.0 format regardless of specified version. This just updated the responses formatting to handle OpenAPI 3.0 appropriately.

OpenAPI 2.0:

produces:
  - application/json
responses:
  200:
    description: 'Some response'
    schema:
      $ref: "#/definitions/SomeSchema"

OpenAPI 3.0:

responses:
  200:
    description: 'Some response'
    content:
      application/json:
        schema:
          $ref: "#/definitions/SomeSchema"

@playpauseandstop
Copy link

playpauseandstop commented Jun 9, 2020

Hi flask-apispec maintainers,

It would be really great if you'll find time to review given MR.

As @rusnyder perfectly described there are some differences in Swagger 2.0 & OpenAPI Schema 3.0 response definition and currently, with flask-apispec==0.9.0, there is no chance to make valid OpenAPI 3.0 schema as flask-apispec still uses Swagger 2.0 responses definitions.

Thanks in advance!


Hi @rusnyder,

I understand, that you might be off topic already, but what do you think about allowing configuring default content type for the app instead of using default application/json here,

content_type = meta['content_type'] or 'application/json'

Something like APISPEC_DEFAULT_CONTENT_TYPE config var seems reasonable for me. What do you think?

@tedblad
Copy link

tedblad commented Dec 2, 2020

How come this hasn't been merged yet?

@zastruga
Copy link

Bump. It would appear the maintainer has left the building.

@quantrung9
Copy link

Please merge this 😅

meta.pop('content_type', None)
exploded[status_code] = meta
else:
content_type = meta['content_type'] or 'application/json'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rusnyder I think it would be better if you use the get method to get the data so that it won't get errors when content_type does not exist in the meta. Something like this:

content_type = meta.get('content_type') or 'application/json'

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

Successfully merging this pull request may close these issues.

5 participants