-
-
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
RequestBody not passing as Parameter to method #1241
Comments
Have you tried setting requestBody to true?
|
Also struggling with the same.
Method generated:
Error:
|
I'm seeing the same thing with PATCH — e.g. consider:
With the above,
Types seem important: the Interestingly, the body does show up at For now, I'm dropping the
(with more info in the spec about the array element schema in practice, of course) ... but it's probably only a matter of time before I hit a case where this isn't an applicable solution. The fact that types seem involves makes me wonder if this somehow related to #691, #804, #1006. (Python 3.9.0, connexion 2.7.0) |
` `
TypeError: updateIdentity() missing 1 required positional argument: 'prediction' Sorry I don't undestand how to quote correctly |
@sbourdette You need to wrap the text block with two lines that contain only the string ``` (i.e. three backticks) So it would look like this in the editor:
It looks like maybe you tried it with a single backtick? But you need three. You should be able to edit the comment and try again, rather than writing a new one. Hope this helps. |
I was struggling with this problem for quite some time and as there is no solution, I feel I could provide some input. In the documentation, a note can be found titled, Automatic Parameter Handling, stating
In this same section it also states,
The solution for a spec like the following, Configuration file post:
...
requestBody:
required: true
content:
application/json:
schema:
type: object
... would be to make the python code def do_post(body):
print(body) Note the use of the parameter name, body. Something like def do_post(not_body):
print(not_body) Will not actually work even though the code is functionally the same. A weird quirk of the library in my opinion. Hopefully this will help someone in the future :-). |
Indeed @TheRealJoe24, thanks for pointing this out. The request body doesn't have a name in OpenAPI 3, so connexion cannot know that you would like to receive the body as You can see an an example of this in one of the examples: Since this is not a bug and it is documented, I'm closing this issue. |
@gimbo your issues seems unrelated. Please create a new issue with a minimal reproducible example. |
This is a late reply to thank @RobbeSneyders for clarifying that simply writing the special parameter name |
Description
I converted a swagger file to openapi 3.0.0 using https://openapi-converter.herokuapp.com/. All the calls work except the one's using POST and PUT with a requestBody. The python method hasn't been modified since upgrading. Do I need to name the definition I want to pass or does the issue lie somewhere else?
Swagger.yml
Method to receive request
Expected behavior
Successfully updated person
Actual behavior
TypeError: update() missing 1 required positional argument: 'person'
Steps to reproduce
Request-body contents
{
"fname": "John",
"lname": "Doe"
}
Additional info:
Output of the commands:
python --version
Python 3.7.2
pip show connexion | grep "^Version\:"
connexion==2.7.0
The text was updated successfully, but these errors were encountered: