@ -67,7 +67,12 @@ def generatePaths(cwd: str, parser: OpenApiParser):
|
|||||||
generatePath(path, p, method, endpoint, data)
|
generatePath(path, p, method, endpoint, data)
|
||||||
|
|
||||||
|
|
||||||
def generatePath(path: str, name: str, method: str, endpoint: dict, data: dict):
|
def generatePath(
|
||||||
|
path: str,
|
||||||
|
name: str,
|
||||||
|
method: str,
|
||||||
|
endpoint: dict,
|
||||||
|
data: dict):
|
||||||
# Generate the path.
|
# Generate the path.
|
||||||
file_name = camel_to_snake(endpoint['operationId']) + '.py'
|
file_name = camel_to_snake(endpoint['operationId']) + '.py'
|
||||||
# Add the tag to the path if it exists.
|
# Add the tag to the path if it exists.
|
||||||
@ -199,7 +204,8 @@ def generatePath(path: str, name: str, method: str, endpoint: dict, data: dict):
|
|||||||
ref +
|
ref +
|
||||||
".from_dict(response.json())\n")
|
".from_dict(response.json())\n")
|
||||||
elif '$ref' in response:
|
elif '$ref' in response:
|
||||||
schema_name = response['$ref'].replace('#/components/responses/', '')
|
schema_name = response['$ref'].replace(
|
||||||
|
'#/components/responses/', '')
|
||||||
schema = data['components']['responses'][schema_name]
|
schema = data['components']['responses'][schema_name]
|
||||||
if 'content' in schema:
|
if 'content' in schema:
|
||||||
content = schema['content']
|
content = schema['content']
|
||||||
@ -207,7 +213,8 @@ def generatePath(path: str, name: str, method: str, endpoint: dict, data: dict):
|
|||||||
if content_type == 'application/json':
|
if content_type == 'application/json':
|
||||||
json = content[content_type]['schema']
|
json = content[content_type]['schema']
|
||||||
if '$ref' in json:
|
if '$ref' in json:
|
||||||
ref = json['$ref'].replace('#/components/schemas/', '')
|
ref = json['$ref'].replace(
|
||||||
|
'#/components/schemas/', '')
|
||||||
f.write(
|
f.write(
|
||||||
"\t\tresponse_" +
|
"\t\tresponse_" +
|
||||||
response_code +
|
response_code +
|
||||||
@ -618,28 +625,28 @@ def generateType(path: str, name: str, schema: dict):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
f.write(
|
f.write(
|
||||||
"\t" +
|
"\t\t" +
|
||||||
property_name +
|
property_name +
|
||||||
" = self." +
|
" = self." +
|
||||||
property_name +
|
property_name +
|
||||||
"\n")
|
"\n")
|
||||||
elif property_type == 'integer':
|
elif property_type == 'integer':
|
||||||
f.write(
|
f.write(
|
||||||
"\t" +
|
"\t\t" +
|
||||||
property_name +
|
property_name +
|
||||||
" = self." +
|
" = self." +
|
||||||
property_name +
|
property_name +
|
||||||
"\n")
|
"\n")
|
||||||
elif property_type == 'number':
|
elif property_type == 'number':
|
||||||
f.write(
|
f.write(
|
||||||
"\t" +
|
"\t\t" +
|
||||||
property_name +
|
property_name +
|
||||||
" = self." +
|
" = self." +
|
||||||
property_name +
|
property_name +
|
||||||
"\n")
|
"\n")
|
||||||
elif property_type == 'boolean':
|
elif property_type == 'boolean':
|
||||||
f.write(
|
f.write(
|
||||||
"\t" +
|
"\t\t" +
|
||||||
property_name +
|
property_name +
|
||||||
" = self." +
|
" = self." +
|
||||||
property_name +
|
property_name +
|
||||||
@ -894,7 +901,8 @@ def getEndpointRefs(endpoint: dict, data: dict) -> [str]:
|
|||||||
if ref not in refs:
|
if ref not in refs:
|
||||||
refs.append(ref)
|
refs.append(ref)
|
||||||
elif '$ref' in response:
|
elif '$ref' in response:
|
||||||
schema_name = response['$ref'].replace('#/components/responses/', '')
|
schema_name = response['$ref'].replace(
|
||||||
|
'#/components/responses/', '')
|
||||||
schema = data['components']['responses'][schema_name]
|
schema = data['components']['responses'][schema_name]
|
||||||
if 'content' in schema:
|
if 'content' in schema:
|
||||||
content = schema['content']
|
content = schema['content']
|
||||||
@ -902,7 +910,8 @@ def getEndpointRefs(endpoint: dict, data: dict) -> [str]:
|
|||||||
if content_type == 'application/json':
|
if content_type == 'application/json':
|
||||||
json = content[content_type]['schema']
|
json = content[content_type]['schema']
|
||||||
if '$ref' in json:
|
if '$ref' in json:
|
||||||
ref = json['$ref'].replace('#/components/schemas/', '')
|
ref = json['$ref'].replace(
|
||||||
|
'#/components/schemas/', '')
|
||||||
if ref not in refs:
|
if ref not in refs:
|
||||||
refs.append(ref)
|
refs.append(ref)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user