Skip to content

Commit

Permalink
openapi/preprocess_spec.py: expand globally shared parameters (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed Jul 24, 2023
1 parent d2dd5e9 commit 9701a7c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions openapi/preprocess_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,35 @@ def drop_paths(spec):
print("Ignoring non Custom Resource api path %s" %k)
spec['paths'] = paths

def expand_parameters(spec):
if 'parameters' not in spec:
return
for path in spec['paths'].keys():
if 'parameters' in spec['paths'][path]:
for i in range(len(spec['paths'][path]['parameters'])):
param = spec['paths'][path]['parameters'][i]
if '$ref' in param:
ref = param['$ref']
param = spec['parameters'][ref.split('/')[-1]]
spec['paths'][path]['parameters'][i] = param
for method in spec['paths'][path].keys():
if 'parameters' in spec['paths'][path][method]:
for i in range(len(spec['paths'][path][method]['parameters'])):
param = spec['paths'][path][method]['parameters'][i]
if '$ref' in param:
ref = param['$ref']
param = spec['parameters'][ref.split('/')[-1]]
spec['paths'][path][method]['parameters'][i] = param
del spec['parameters']

def process_swagger(spec, client_language, crd_mode=False):
spec = add_custom_objects_spec(spec)

if crd_mode:
drop_paths(spec)

expand_parameters(spec)

apply_func_to_spec_operations(spec, strip_tags_from_operation_id)

if client_language == "csharp":
Expand Down

0 comments on commit 9701a7c

Please sign in to comment.