-
-
Notifications
You must be signed in to change notification settings - Fork 773
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
Validate Content Type #407
Comments
Did you get this working? |
@kenneho can you try the release candidate for Connection 2.0? You can install it with |
Thanks. I tried running the release candidate, but got an error: #729 When that one is sorted out I'll try again. |
Just tested this against the paths:
/greeting/{name}:
post:
summary: Generate greeting
description: Generates a greeting message.
operationId: sandbox.post_greeting
consumes:
- application/json
produces:
- text/plain;
responses:
200:
description: greeting response
schema:
type: string
examples:
"text/plain": "Hello John"
parameters:
- name: name
in: path
description: Name of the person to greet.
required: true
type: string And the operation function defined as below: def post_greeting(name):
return 'it works!' When I execute the following command:
It shows me Now talking about fixing this, wouldn't it break backward compatibility with a high potential for trouble with existing users that may be supporting multiple content-types without necessarily reflecting this fact in the swagger/openapi definition? What are your thoughts about this? |
Sorry for the delayed response. Your understanding of the issue, at least the issue as I see it, is correct. Enforcing this change now might break a lot of clients, but maybe one could implement enforcing this validation as an optional setting? Coming to think of it, I'd like like Connexion to also to validate the client's "Accept" header, so that Connexion throws an error if the client asks to get back data in a non-supported content type. In other words, if Connexion could validate both the |
I believe this is partially fixed in connexion 2.0. Has anyone had a chance to try it? I'm also working on redoing validation of content types completely. I have a demo going at #760 . If you want to take a look and let me know what you think, that would be awesome. As far as validating the |
I'm tagged on another project next next couple of days or so, but will check out your connexion fix after that. |
Fixed since #1588 |
Description
Connexion does not validate the content type of the incoming request against the swagger definition
Expected behaviour
Connexion validates the content type
Steps to reproduce
Create a swagger file that consumes
application/json
and send a request that has amultipart/form-data
content type. The request is accepted when it should be rejected.Additional info:
Output of the commands:
python --version
Python 3.4.6
pip show connexion | grep "^Version\:"
Version: 2016.0.dev1
The text was updated successfully, but these errors were encountered: