-
-
Notifications
You must be signed in to change notification settings - Fork 765
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: support openapi spec version 3 #591
Conversation
connexion/apis/abstract.py
Outdated
from ..operation import Operation | ||
from ..options import ConnexionOptions | ||
from ..resolver import Resolver | ||
from ..utils import Jsonifier | ||
|
||
try: | ||
from urllib.parse import urlparse |
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.
Why not use six here?
from six.moves.urllib.parse import urlparse
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.
ah great - thanks!
connexion/decorators/validation.py
Outdated
if data is None and len(request.body) > 0 and not self.is_null_value_valid: | ||
# the body has contents that were not parsed as JSON | ||
return problem(415, | ||
"Unsupported Media Type", |
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.
Being working on major changes, I'd avoid typographical changes as they increase the review work.
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.
good catch, thanks!
connexion/decorators/validation.py
Outdated
if data is None and len(request.body) > 0 and not self.is_null_value_valid: | ||
# complain about no data? | ||
pass | ||
data.update({k: '' for k in dict(request.files)}) # validator expects string.. |
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.
does this work?
data.update(dict.fromkeys(request.files, ''))
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.
TIL - thanks!
connexion/decorators/parameter.py
Outdated
if parameter['in'] == 'formData'} | ||
|
||
# openapi3 body | ||
if body_name is None and body_schema is not None: |
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.
what happens if body_name is blank?
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.
I don't think body_name can be blank in swagger2 as "name" is a required field(https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject). It is set to None
in oas3 because requestBody
replace the in["body"]
parameters of swagger2, so body_parameters = [{}]
.
I find all this interspersed logic really yucky, so I'm open to ideas for how to split it out by spec version.
This file is especially bad 😞
related: see my other branch that does this with the Operation class dtkav/connexion@18a7c28...dtkav:oas3_class_separation#diff-f4018bfc9e3bdfe01ab150a7069d72ceL183
connexion/decorators/parameter.py
Outdated
else: | ||
body_properties = {} | ||
|
||
query_defns = {sanitize_param(parameter['name']): parameter |
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.
Here and beyond,
{... for parameter in parameters}
{... for param in parameters}
be consistent for readability (I prefer short stuff in comprehension) eg {... for p in parameters}
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.
yeah I totally agree
The new plan is to stage changes for a swagger 2.0 release on the dev-2.0 branch. |
This is a work in progress and is not ready for merge!
Fixes #420
Changes proposed in this pull request:
Changes in behavior for OAS3 specs:
body
by default, withx-body-name
override).There are a lot of new files in this diff. This is because I vendored swagger-ui-3 (this will change with #614)
The test suite is mostly the same, except that it has been parameterized to run with both versions of each spec. Test fixtures were added in #616