-
-
Notifications
You must be signed in to change notification settings - Fork 228
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Handle Default Responses in response generation #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
✨ enhancement
New feature or improvement
🍭 OpenAPI Compliance
Supporting a new bit of the OpenAPI spec
Comments
fwiy I just monkeypatched response_from_data(status_code=int(200 if code == 'default' else code) I think it is atypical @staticmethod
def _add_responses(endpoint: "Endpoint", data: oai.Responses) -> "Endpoint":
endpoint = deepcopy(endpoint)
for code, response_data in data.items():
+ if code == 'default':
+ continue
response = response_from_data(status_code=int(code), data=response_data)
if isinstance(response, ParseError):
endpoint.errors.append(
ParseError(
detail=(
f"Cannot parse response for status code {code}, "
f"response will be ommitted from generated client"
),
data=response.data,
)
)
continue
if isinstance(response, (RefResponse, ListRefResponse)):
endpoint.relative_imports.add(import_string_from_reference(response.reference, prefix="...models"))
endpoint.responses.append(response)
return endpoint |
alexifm
added a commit
to alexifm/openapi-python-client
that referenced
this issue
Jan 27, 2021
alexifm
added a commit
to alexifm/openapi-python-client
that referenced
this issue
Feb 11, 2021
alexifm
added a commit
to alexifm/openapi-python-client
that referenced
this issue
Feb 11, 2021
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Labels
✨ enhancement
New feature or improvement
🍭 OpenAPI Compliance
Supporting a new bit of the OpenAPI spec
Describe the bug
In the specifications, default MAY be used as a default response object for all HTTP codes that are not covered individually by the specification.
ValueError: invalid literal for int() with base 10: 'default'
To Reproduce
Sample code from a openapi spec.
Expected behavior
Code should generate a custom ApiResponseError class if default is defined, with content of error being a model of the reference/schema items
OpenAPI Spec File
Sample code from a openapi spec.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: