Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
41b1d3c9
Commit
41b1d3c9
authored
5 years ago
by
Erwan Rouchet
Committed by
Bastien Abadie
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove nested serializers fix in OpenAPI patch script
parent
f6e36565
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openapi/patch.py
+1
-22
1 addition, 22 deletions
openapi/patch.py
with
1 addition
and
22 deletions
openapi/patch.py
+
1
−
22
View file @
41b1d3c9
...
...
@@ -38,27 +38,6 @@ def get_args():
return
args
def
fix_nested_properties
(
schema
):
"""
Walk through the schema recursively, looking for Schema Objects with type=object,
to change {
"
properties
"
: {
"
properties
"
: {},
"
required
"
: []}
into {
"
properties
"
: {},
"
required
"
: []}
See https://github.com/encode/django-rest-framework/pull/6568
"""
if
schema
.
get
(
'
type
'
)
==
'
object
'
\
and
'
properties
'
in
schema
\
and
'
properties
'
in
schema
[
'
properties
'
]
\
and
'
required
'
in
schema
[
'
properties
'
]:
schema
=
fix_nested_properties
(
schema
[
'
properties
'
])
schema
[
'
type
'
]
=
'
object
'
return
schema
return
{
k
:
(
fix_nested_properties
(
v
)
if
isinstance
(
v
,
dict
)
else
v
)
for
k
,
v
in
schema
.
items
()
}
def
update_schema
(
schema
,
patches
):
"""
Perform updates on an OpenAPI schema using another YAML file describing patches.
...
...
@@ -123,7 +102,7 @@ def update_schema(schema, patches):
print
(
'
Adding x-name to {} on {}
'
.
format
(
method
,
path
),
file
=
sys
.
stderr
)
operation
[
'
requestBody
'
][
'
x-name
'
]
=
'
body
'
return
fix_nested_properties
(
schema
)
return
schema
def
print_endpoints
(
schema
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment