Skip to content

Commit 43775be

Browse files
committed
parser / openapi / softly ignore invalid resp status code
1 parent af09640 commit 43775be

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

openapi_python_client/parser/openapi.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,22 @@ def _add_body(
169169
def _add_responses(*, endpoint: "Endpoint", data: oai.Responses, schemas: Schemas) -> Tuple["Endpoint", Schemas]:
170170
endpoint = deepcopy(endpoint)
171171
for code, response_data in data.items():
172+
try:
173+
code = int(code)
174+
except ValueError:
175+
endpoint.errors.append(
176+
ParseError(
177+
detail=(
178+
f"Invalid response status code {code} (not a number),"
179+
f"response will be ommitted from generated client"
180+
),
181+
data=code,
182+
)
183+
)
184+
continue
185+
172186
response, schemas = response_from_data(
173-
status_code=int(code), data=response_data, schemas=schemas, parent_name=endpoint.name
187+
status_code=code, data=response_data, schemas=schemas, parent_name=endpoint.name
174188
)
175189
if isinstance(response, ParseError):
176190
endpoint.errors.append(

0 commit comments

Comments
 (0)