Comments (3)
Hi @laurensvm,
this sounds similar to #522 - would that cover your use case as well?
from swift-openapi-generator.
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, ErrorResponse
is a generic response that is consumed by the calling SwiftUI component.
I think having a generic Output such as OpenAPIResult
in the example has added value in order to handle generic errors and to avoid code duplication. Right now I have to handle the possible Components.Responses.ErrorResponse
's in each of the routes separately. The alternative is to ignore the error using try? await self.client?.GetComments(path: .init(id: id)).ok.body.json
, but I feel like this solution disregards a lot of useful information.
Is it expected to do this for all the routes?
Thanks again for this package, I'm still very much a fan.
from swift-openapi-generator.
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.
from swift-openapi-generator.
Related Issues (20)
- bug/regression: latest yams results in incomplete generation of types HOT 10
- Logging and HTTPBody HOT 3
- Merging oneOf with many compatible enums of a single value HOT 10
- anyOf encoder does not include discriminator's `parameterName` leading to incorrect encoding HOT 2
- Is there a workaround to deal with slow compilation times for a very large openapi file? HOT 3
- Empty arrays are omitted from query params HOT 5
- Support for `multipart/mixed`? HOT 1
- When a delete path do not have responses content an error generated HOT 2
- Add ability to attach protocols to generated models HOT 9
- Make the generator usable on very big specs HOT 3
- Old and new examples HOT 3
- visionOS can't use HOT 4
- How to convert the binary obtained from the server into a playable Data type? HOT 2
- HTTPTypes linker error if multiple targets use open API generator HOT 2
- Getting "any has no effect on concrete type 'Error'" HOT 6
- Need to be able to support multiple OpenAPI specs HOT 2
- Tutorial doc text color issue on light theme HOT 1
- Check for updated spec before generating HOT 2
- Warnings due to `@frozen` attribute on non-public enums with Xcode 16 Beta 3 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-openapi-generator.