Skip to content

Commit f3bcfa5

Browse files
tomplusk8s-ci-robot
authored andcommitted
feat: add x-codegen-request-body-name in preprocessing step (#96)
1 parent d0821e6 commit f3bcfa5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

openapi/preprocess_spec.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,18 @@ def add_custom_objects_spec(spec):
110110
spec['paths'][path] = custom_objects_spec[path]
111111
return spec
112112

113+
def add_codegen_request_body(operation, _):
114+
if 'parameters' in operation and len(operation['parameters']) > 0:
115+
if operation['parameters'][0].get('in') == 'body':
116+
operation['x-codegen-request-body-name'] = 'body'
113117

114118
def process_swagger(spec, client_language):
115119
spec = add_custom_objects_spec(spec)
116120

117121
apply_func_to_spec_operations(spec, strip_tags_from_operation_id)
118122

123+
apply_func_to_spec_operations(spec, add_codegen_request_body)
124+
119125
operation_ids = {}
120126
apply_func_to_spec_operations(spec, lambda op, _: operator.setitem(
121127
operation_ids, op['operationId'], op))
@@ -295,7 +301,7 @@ def main():
295301
)
296302
argparser.add_argument(
297303
'output_spec_path',
298-
help='Path to otput spec file to'
304+
help='Path to output spec file to'
299305
)
300306
argparser.add_argument(
301307
'username',

0 commit comments

Comments
 (0)