-
Notifications
You must be signed in to change notification settings - Fork 39
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
WIP: Content type specification #171
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mbierma! Thanks for the PR. Is this still WIP or would you like preliminary feedback?
Mostly just looking for preliminary feedback. The main intent of this PR is to:
Since this deals with response content types, and #91 is dealing with content negotiation, it would be great if there was a consistent interface between the code here and what you're planning for the future |
@RookieRick @airstandley Tagging you folks here, since you may have more context than I do regarding content types! Any thoughts? |
@mbierma The example you've given uses a Field rather than a Schema which presents all kinds of issues. I'm assuming that's a small mistake and you intended for PDF to be a marshmallow.Schema or some class that implements the The approach you are taking has some merit, but I think it would be helpful if you included a working example of a simple handler which returned a valid pdf(or something easier like plain text) when hooked up to a test app. I also think we want to keep in mind that at least in OpenApi v3 you can specify multiple content-types. I'd image this behaviour would be much more useful it we could introduce a way to support multiple content-types (eg. a handler that can return video/mp4 or video/avi) |
@airstandley thanks for the feedback. I'm going to be working on a better example I am definitely in agreement that it would be much more useful to introduce a way to support multiple content-types. Do you have any recommendations on how to specify something like that? The first things that come to mind are
or
For the first case, there'd likely be some validation that each response schema in the list contains a unique |
I haven't checked the 2.0 spec, but 3.0 specs
seems like a great approach and then we can fallback on the old behaviour and assume 'application/json' if just a schema is given. |
Those defaults sound good to me. Is there any chance that you still plan on doing this work @mbierma ? Thanks, |
This is a quick and dirty proof of concept to allow for the specification of content type other than
application/json
for OpenAPI 3 generation. Currently, it is possible to create an endpoint without specifying theresponse_body_schema
, and then returning aResponse
object with the desired content type:However, in existing implementation, the generated swagger specification does not reflect the correct content type. This PR is intended to demonstrate a way to allow for the specification of content type using a
__content_type__
magic attribute. Additionally, a primitiveresponse_body_schema
type is used to allow for responses that are not json objects.