-
-
Notifications
You must be signed in to change notification settings - Fork 228
feat!: Change the Response.status_code
type to the HTTPStatus
enum
#665
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
feat!: Change the Response.status_code
type to the HTTPStatus
enum
#665
Conversation
taken from python standard library, exists from python 3.5, described in [the documentation][1] as: > A subclass of enum.IntEnum that defines a set of HTTP status codes, > reason phrases and long descriptions written in English. [1]: https://docs.python.org/3/library/http.html
the spec requires this to be a valid HTTP code, invalid integers should not be supported
apparently it was renamed, asked to learn more here: knope-dev/knope#254
dbc7212
to
5bea94f
Compare
Codecov Report
@@ Coverage Diff @@
## main #665 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 49 49
Lines 1795 1797 +2
=========================================
+ Hits 1795 1797 +2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Thanks for the PR! I did some digging to find out why It's a shame they don't expose their own, since I believe that's the actual type that we're capturing, not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks! Even though this is really fixing our compatibility with the spec—it will disallow OpenAPI documents that previously generated code fine (if they have unsupported HTTP codes), so I'll mark this is a breaking change.
I'm going to out for the day, later when back, I can do this:
|
Don’t worry about doing all that, I squash on merge so I can make sure the commits look right. Thanks for the attention to detail, though!! |
Nice, so I won't need to update the changelog manually in the PR, and you'd only need to add the Regarding the failing tests in CI, I tried reproducing the same issue by installing a fresh 3.7 env in poetry, installing dependencies and running:
Would you know how to resolve this? Could this be coming from the cache step, where do?: /usr/bin/tar --use-compress-program unzstd -xf /home/runner/work/_temp/e43cafd0-1f39-4c5d-9b22-95fc04289cd4/cache.tzst -P -C /home/runner/work/openapi-python-client/openapi-python-client |
Response.status_code
type to the HTTPStatus
enum
In the OpenAPI/Swagger 3.0 spec docs, in the section on responses, it's mentioned that the property name will be HTTP Response codes as per the IANA spec:
It continues to add two special cases, which are currently out of scope of this PR (see below for future work).
This PR includes two main changes:
int
code in aHTTPResponse
type, catching aValueError
as before - for bothint
andHTTPResponse
Note: my initial aim was to add
default
responses (as mentioned in #124), but I thought I'd start with a smaller PR, to help me find my way around the project and help build confidence this is the right approach.The following steps would be to:
1XX, 2XX, 3XX, 4XX, and 5XX
I would probably implement this using a new wrapper type (we can call it
OpenAPIResponseParameter
) that is a Union ofHTTPResponse
with a new set ofLiteral
types.(p.s: I'm not sure when I will have a stretch of a few hours again, but hopefully the info above is sufficiently detailed for anyone else to continue the work)