-
Notifications
You must be signed in to change notification settings - Fork 113
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
[Generator] Add headerFields and body to UndocumentedPayload #488
[Generator] Add headerFields and body to UndocumentedPayload #488
Conversation
Thank you @czechboy0, this is a much welcome addition :-) I guess it is the change to I'm not sure I understand what's in the response body of the undocumented payload, though. But that's only because I don't understand exactly when I assume that the response body was not fully buffered, since this would create a risk of high memory consumption. I thus assume that not a single byte of response body was consumed, otherwise it would throw Hence the undocumented payload is only returned based on the headers of the response, and this will never change in the future. All unexpected data in the response body itself will never return Do I understand well? If so, I'm very happy with this PR! EDIT. Yes, that's exactly how |
For example, if you OpenAPI document defines responses for 200, 400, and 500, and you receive 401, you'll get an
Correct,
Yes, exactly. The response HTTP status code is how we decide the handling. If the status code is undocumented, you get the raw data. If it's documented, we unwrap the way that the OpenAPI document tells us. If you receive a documented response, but with body data that don't fit the documented structure, an error will be thrown.
I believe so - please just confirm again that the above fits well with your understanding 🙂 |
Perfect! This was a quick win, enabled by a good initial design (the smoothest butter developers can dream of) 🙂👍 |
Motivation
Fixes #299.
Depends on apple/swift-openapi-runtime#90 landing first and getting released, and the version dependency being bumped here.Runtime dependency bumped to 1.1.0.
Modifications
Adapted to the runtime changes, added
headerFields
andbody
properties toUndocumentedPayload
.Now, the generated code actually also forwards the values to it.
Result
Easier access to the raw response data if an undocumented response is returned.
Test Plan
Adapted snippet and file-based reference tests, and also the unit tests of the generated code (PetstoreConsumerTests).