Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
backbone-message-format
Commits
50f574f6
Verified
Commit
50f574f6
authored
7 months ago
by
Dan Jones
Browse files
Options
Download
Email Patches
Plain Diff
chore: lint changes with black
parent
0383a95b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
generate_schema_config.py
generate_schema_config.py
+8
-8
No files found.
generate_schema_config.py
View file @
50f574f6
...
...
@@ -35,7 +35,7 @@ FLASK_DEBUG = os.getenv("FLASK_DEBUG", "False").lower() in ("true", "1", "t")
def
get_swagger_config
(
reload
=
False
):
if
reload
:
print
(
"Reload specified: Ignoring cached refs"
)
swagger_config
=
{
"openapi"
:
"3.0.2"
,
"swagger_ui"
:
True
,
...
...
@@ -195,26 +195,26 @@ def downgrade_schema_30x_compatible(schema):
downgrade_schema_30x_compatible
(
propConfig
[
"items"
])
def
get_remote_ref_cache_path
(
remote_ref
):
def
get_remote_ref_cache_path
(
remote_ref
):
parsed_ref
=
urlparse
(
remote_ref
)
return
f
"remotes/
{
parsed_ref
.
hostname
}{
parsed_ref
.
path
}
"
def
get_cached_ref
(
remote_ref
):
def
get_cached_ref
(
remote_ref
):
ref_path
=
get_remote_ref_cache_path
(
remote_ref
)
ref
=
None
if
os
.
path
.
exists
(
ref_path
):
print
(
f
"loading cached ref:
{
remote_ref
}
"
)
with
open
(
ref_path
,
'r'
)
as
ref_file
:
with
open
(
ref_path
,
"r"
)
as
ref_file
:
ref
=
json
.
load
(
ref_file
)
return
ref
def
store_cached_ref
(
remote_ref
,
definition
):
ref_path
=
get_remote_ref_cache_path
(
remote_ref
)
ref_dirs
=
re
.
sub
(
r
'
\/[^\/]+$
'
,
''
,
ref_path
)
ref_dirs
=
re
.
sub
(
r
"
\/[^\/]+$
"
,
""
,
ref_path
)
os
.
makedirs
(
ref_dirs
,
0o775
,
True
)
with
open
(
ref_path
,
'w'
)
as
ref_file
:
with
open
(
ref_path
,
"w"
)
as
ref_file
:
json
.
dump
(
definition
,
ref_file
)
...
...
@@ -234,7 +234,7 @@ def inject_schema(schema, remote_ref, reload=False):
# get schema from cache if present
ref_schema
=
None
if
reload
else
get_cached_ref
(
remote_ref
)
if
not
ref_schema
:
print
(
f
"ref not cached:
{
remote_ref
}
"
)
print
(
f
"ref not cached:
{
remote_ref
}
"
)
ref_schema
=
resolve_ref
(
remote_ref
)
downgrade_schema_30x_compatible
(
ref_schema
)
store_cached_ref
(
remote_ref
,
ref_schema
)
...
...
@@ -393,7 +393,7 @@ if __name__ == "__main__":
# Parse script args
config
=
get_options
()
swagger_config
=
get_swagger_config
(
config
.
get
(
'
reload_schemas
'
))
swagger_config
=
get_swagger_config
(
config
.
get
(
"
reload_schemas
"
))
# Output compiled schema
if
config
.
get
(
"output_file"
):
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment