openapi-python-client icon indicating copy to clipboard operation
openapi-python-client copied to clipboard

Add support for "XX" status code specifications

Open PSU3D0 opened this issue 1 year ago • 1 comments

As indicated in the OpenAPI specification, specifications may specify a range of response codes. See the following excerpt:

Any HTTP status code can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character X. For example, 2XX represents all response codes between [200-299]. Only the following range definitions are allowed: 1XX, 2XX, 3XX, 4XX, and 5XX. If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code.


This was missing from the library. This PR fixes that. Cheers!

PSU3D0 avatar Feb 20 '24 03:02 PSU3D0

Thanks! We'll probably want to add a new type with some template logic that can check ranges of status codes. I think as-is this will generate a ton of if statements

dbanty avatar Feb 20 '24 22:02 dbanty

Superseded by #1303

dbanty avatar Aug 24 '25 03:08 dbanty