Ask HN: Is anyone using REST API code generator in production?
I'm aware of some comparisons conducted a while ago on some API code generators listed below but these comparisons seem to be outdated:
- apimatic.io: https://apimatic.io
- AutoRest: https://github.com/Azure/AutoRest
- Swagger Codegen: https://github.com/swagger-api/swagger-codegen
- OpenAPI-CodeGen: https://github.com/Mermade/openapi-codegen
- OpenAPI Generator: https://github.com/OpenAPITools/openapi-generator
- go-swagger: https://github.com/go-swagger/go-swagger
Is anyone using these tools in their environment? Any caveat?
16 comments
[ 3.8 ms ] story [ 58.5 ms ] threadI've had a lot of experience with REST & JSON API and those "generators" or abstraction people create always end up being very inflexible. With GraphQL, you have full control on what you return, as well full control over how you want to change your data. Easy to avoid n+1 etc. Maybe that's just me, but I think this question is already answered. Took us a few years to discover a better way.
I've been using GraphQL for the last 2 years and haven't had ANY complaints so far. It doesn't try to push you some mindset of how should things look like and instead just try to get out of the way, enabling you do craft requests and responses as you'd like. Of course, with that power, you need to make sure that things stay consistent, but that problem also exists for REST/JSON API's.
Glad to know you have very positive experience with GraphQL so far.
OpenAPI Generator is a fork of Swagger Codegen. The fork took place in May 2018 - a year ago. For the reasons behind the fork, please refer to the Q&A (https://github.com/OpenAPITools/openapi-generator/blob/maste...).
Fast forward to today, we just released OpenAPI Generator v4.0.0 - the 20th release since the fork, thanks to the awesome contributions from the vibrant developer community. Please refer to the release note (https://github.com/OpenAPITools/openapi-generator/releases/t...) for more information about the release.
For a list of companies and open-source projects using OpenAPI Generator in production, please refer to the project's README (https://github.com/OpenAPITools/openapi-generator/#4---compa...).
I hope you will find OpenAPI Generator useful in your work and personal projects.
The list looks impressive and I look forward to more users sharing their real life experience adopting these code generators.
Kudos to your work on open-source projects.
Openapi-generator is opinionated when it comes to how the data model classes are defined, and the feature set depends on which underlying HTTP library you choose (Jersey, Feign, Retrofit, OkHttp, etc), so we needed to invest some time when getting started to make necessary adjustments. But overall it has proven to be robust and meet our needs.
You can still find some user stories in the following Reddit posts (hidden from public):
- https://www.reddit.com/r/programming/comments/bps96v/questio...
- https://www.reddit.com/r/programming/comments/bq64ek/compare...
We wanted to ensure our APIs were backwards compatible and we felt like the best way to ensure that would be by making them contract led. This also means that we can design our APIs and write the spec files and get feedback without having to implement anything.
So our APIs are defined by the swagger spec files.
The open API generator was perfect for this as it meant we could write our spec files, and then generate interfaces for our spring boot application based on the swagger spec files.
Then to implement the API all we need to do is implement the interfaces that the open API generator generated for us.
The generator is very flexible (the mustache files allow you to modify what gets generated) and the community - particularly wing328hk were very helpful.
We submitted a number of pull requests with changes that helped make things a bit smoother for us, and require less custom configuration of the generator. The development community was very active and happy to provide feedback and accept our pull requests.
All in all I would definitely recommend a contract led approach (and the open API generator) for developing RESTful APIs.