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

SwaggerRenderer example doesn't match the ";version=2.0" part of media_type #4287

Closed
5 of 6 tasks
osantana opened this issue Jul 19, 2016 · 4 comments
Closed
5 of 6 tasks

Comments

@osantana
Copy link
Contributor

Checklist

  • I have verified that that issue exists against the master branch of Django REST framework.
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • This is not a usage question. (Those should be directed to the discussion group instead.)
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.
  • I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

Implement the documentation example of SwaggerRenderer at: https://github.com/tomchristie/django-rest-framework/blame/master/docs/api-guide/schemas.md#L244

And try to get an HTTP request to an endpoint that uses this renderer:

http http://127.0.0.1:8000/v1/ Accept:application/openapi+json;version=2.0

Expected behavior

Get a JSON with Swagger API Schema.

Actual behavior

Get an HTTP 406:

HTTP/1.0 406 Not Acceptable
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Date: Tue, 19 Jul 2016 19:51:47 GMT
Server: WSGIServer/0.2 CPython/3.5.1+
Vary: Accept
X-Frame-Options: SAMEORIGIN

{
    "detail": "Could not satisfy the request Accept header."
}

Preliminar analisys

I've found that media_type doesn't match "version" parameter correctly in the following lines (even with */*; q=0.8 media type):

@tomchristie
Copy link
Member

Thanks for raising this!

@tomchristie
Copy link
Member

Note that this is actually a subtle command line issue...
This:

http http://127.0.0.1:8000/v1/ Accept:application/openapi+json;version=2.0

In bash is actually treated as:

http http://127.0.0.1:8000/v1/ Accept:application/openapi+json
version=2.0

@tomchristie
Copy link
Member

To simplify things I think we'll remove the optional "version=2.0" from the docs.

@osantana
Copy link
Contributor Author

To simplify things I think we'll remove the optional "version=2.0" from the docs.

I'm 👍 for this. I think that the version 2.0 is kind-of implicit in application/openapi+json content/mime-type.

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

2 participants