-
Notifications
You must be signed in to change notification settings - Fork 127
Protocol where each Output
conforms to
#574
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
Comments
Hi @laurensvm, this sounds similar to #522 - would that cover your use case as well? |
Hi @czechboy0 , Thanks for your quick response. Yes, this middleware should cover the logging/tracing part of the use case. However, I would also like to present the errors in a standardized way to the UI. In the example, I think having a generic Output such as Is it expected to do this for all the routes? Thanks again for this package, I'm still very much a fan. |
The challenge here is that every operation might have completely different set of responses, and those responses might have different payloads. So you as the user familiar with your OpenAPI document can write a type like OpenAPIResult, but the generator can't know - because it treats every operation separately. So my current recommendation would be to write an extensions/macro for your own project, with the requirement that all operations have identical non-success responses, and get some value out of it that way. And if you have ideas of how the generator could help here, please do share them. But I don't see a straightforward way to provide what you're asking right now in a way that generalizes to all OpenAPI docs. |
Question
I would like to write one
wrapError
function that takes a genericOutput
and handles all the errors. For this I think we'd need to have a protocol to which allOutput
enums conform to. For instance:I am not an advanced enough Swift programmer to know if this would actually work. I'm trying to avoid copying error handling logic for each of my routes. Perhaps you have any other solutions?
Many thanks
The text was updated successfully, but these errors were encountered: