5 ms·
I'm a very heavy OAS user across languages (C#, Java, TypeScript, Python). I've tried both the client and server generators for many languages, and the output
by smt88 7y ago
I'm a very heavy OAS user across languages (C#, Java, TypeScript, Python).
I've tried both the client and server generators for many languages, and the output was always unusable garbage.
It's bettee to just write your own server and use OAS for validation and type defs.
- hardwaresofton 7y agoYeah I disagree -- I personally found the TypeScript client to be quite usable, but maybe you've hit more edge cases than I have! Are there any issues for these corner cases you've filed that could use more attention? I don't maintain openapi-generator but I can definitely forward them to the maintainers
- kbenson 7y agoIt depends on both the target language (in that the quality of what's generated is variable, and the benefit it gains you is also variable based on how easy it is to get something usable in that language), and how well they defined the API using the spec. I've had a few times where the spec had slight inconsistencies and bugs that made working through and debugging the generated output take as long or longer than it would take to implement a client from scratch for the 20% of the API I actually need.
- fyp 7y agoI am currently evaluating whether I want to use the generators for a typescript node.js/react project. Which typescript generator are you using? Do you use typescript on the backend too and if so is it easy to keep the generated type definitions in sync? Also for backend what do you use for json schema validation?
- wing328hk 7y agoI would recommend the `typescript-angular` generator as a starting point for evaluation as it's pretty active and we just added Angular 9 support.
- hardwaresofton 7y agoI used and like typescript-axios
- dnautics 7y agoThis might sound crazy but I wound up writing my own generator and was quite happy with the result (and use it in prod).
- james_s_tayler 7y agoHow much effort was it? I actually don't the that's such a bad idea.
- dnautics 7y agoIt was about three weeks of coding (in addition to normal duties), I had to write two libraries: https://github.com/ityonemo/Exonerate/ https://github.com/ityonemo/Exonerate/ https://github.com/ityonemo/Exaggerate/ https://github.com/ityonemo/Exaggerate/
- hopia 7y agoWith OpenAPI spec < 3 there's no support for sum types. This at least for me lead to semi heavy refactoring of the client lib (for Dart lang).
- nmfisher 7y agoHaving used the TypeScript client generator and contributed the F#/Giraffe and F#/Azure Functions server generators, I disagree :) Do you literally mean unusable, or it just didn't fit your stylistic preference?
- smt88 7y agoFor some languages, it doesn't even compile. For others, there are OAS features (e.g. allOf, anyOf) that weren't handled correctly. I actually still haven't found a single implementation of a OAS consumer (mock server, type generator, etc.) that implements the whole spec correctly.
- nmfisher 7y agoOK, well it's certainly not intended to support the whole OAS spec (and indeed, the ones I contributed certainly don't, just the parts I needed at that specific point in time). This is particularly the case with OAS2->3. The intention is that people use the generators as a base, and if there's something you need that's not implemented, you write the implementation and contribute it back. No single person is going to implement 100% of the spec in their day job, so as an open source project, coverage will be patchy until enough people extend the implementation to cover their own API surface area. I don't think "it doesn't cover the whole spec" is fair grounds for criticism (though out-of-the-box generator errors are another story).
- smt88 7y ago> I don't think "it doesn't cover the whole spec" is fair grounds for criticism (though out-of-the-box generator errors are another story) A spec is useless if it's not fully implemented by any library. Also, I'm fine with imperfect FOSS, but it's frustrating to not know that implementation is incomplete or what exactly is missing. You end up doing trial and error. All I'm saying is that OAS generators are not net time savers, which you supported yourself by saying that sometimes fixing an implementation is up to the user. That's not a criticism of any person, just a fact.
- kelnos 7y agoWe built guardrail[0] because we weren't happy with the output of the reference generators. We only support Java (Dropwizard) and Scala (akka-http, http4s, and endpoints.js) so far, however. [0] https://github.com/twilio/guardrail https://github.com/twilio/guardrail
- hardwaresofton 7y agoLove to see efforts like this -- if you all build a better java generator (and there's the reference ones to fall back on), the whole community benefits.
- james_s_tayler 7y agoAgreed. We have opted to write our own clients so we have full control over how the HTTP calls happen, but we use the models generated by OAS tooling as a happy medium.
- glun 7y agoI've been investigating their generators for work these last two days, and their java generators produce code that doesn't even compile -- when ran on their own schema examples! Total garbage. OneOf (for the polymorphism aspect of inheritance) is the feature that breaks every single one of them.
- wing328hk 7y agoWe just added oneOf support to the Java client generator a few weeks ago. The enhancement will be included in the upcoming 4.3.0 release. You can give it a try with the latest snapshot version for the time being. Ref: https://github.com/OpenAPITools/openapi-generator/pull/5120 https://github.com/OpenAPITools/openapi-generator/pull/5120
- Cthulhu_ 7y agoI've had multiple experiences with the generators. I've used it purely to generate the models themselves, doing the APIs (which were usually straightforward REST calls anyway) directly. I've also written customized templates that removed a lot of the cruft (iirc the JS or TS generator decided to output an API client in three different flavors). Of course the problem there was that the particular generator did not have all code generation in (overridable) templates, but also some hardcoded.