Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Stringification of response status codes leads to invalid swagger #426
Recent merge of #424 results in our swagger documentation being generated with the following response definitions:
i.e. usage of https://docs.python.org/3/library/http.html#http-status-codes results in the generation of invalid swagger.
Potential fix (
I'm happy to open a PR for this, but would appreciate any feedback on the approach laid out above (cast the code to an int before casting to str).
I'm not a big fan of the try-except approach where we try to catch all kinds of errors, potentially hiding input errors. And I wouldn't log an error since this code raises on
We only ever tested/supported status codes as string or integers. AFAIU,
for code, response in iteritems(operation["responses"]): if not PY2: from http import HTTPStatus if isinstance(code, HTTPStatus): code = code.value responses[str(code)] = get_ref( "response", response, openapi_major_version ) operation["responses"] = responses