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
OpenAPI generator for reactive data client? #312
Comments
This is a great idea! At Coinbase we generate our definitions from protos, which works great! Doing something similar for OpenAPI, would be great, and if you open source it - probably benefit many other people! We would happily link to such a generator in the docs, as we consider codegen the best way to work with APIs at scale. The hardest part is probably creating the schema. Someone did some similar work on this for normalizr, which has an almost identical API https://github.com/eightcard/openapi-to-normalizr. This project might be helpful for any endeavors in this area. |
Thank you for the pointers @ntucker! |
@AndrewPrifer do you plan to implement it? I have some experience with https://github.com/OpenAPITools/openapi-generator and can probably help with the implementation of such a generator. |
@jamakase that’s great news! We are planning to make a generator! However after some thinking we decided to for now just start implementing the resource definitions by hand and see what we learn. We decided on this because of how flexible rest(-like) APIs can be. It’d of course be trivial to support neatly arranged resources that can be 1 to 1 translated to resource definitions that don’t override anything besides If you already have a clear idea or prior experience with rest-hooks though, we’re always open to collaboration, it’s just that we’re still building up experience with it. TLDR; we are absolutely planning to write a generator, but we’re taking some time to learn first. |
Hi @ntucker, would you mind sharing an overview on how you use protos to generate entities? |
@krunicn Sure! They key is identifying which messages are entities and then how they make a primary key. The easiest way to do this if you have control over your API is to simply designate a given field (like 'id') to always mean a primary. In this case, your codegen would simply check for existence of the field and if so create an Entity. Since they are all the same id, you can create an IDEntity base class to extend from. Alternatively if you don't have that level of control, you can use the annotation system to specify the primary key. |
Hi, I’m evaluating rest-hooks for a new project. We already use OpenAPI/Swagger. Does it sound like a good idea to write an OpenAPI generator to transform the OpenAPI definitions into rest-hooks resource definitions? That way there’d be a single source of truth for all things API. Has anyone had a similar setup? Did it work? Do you think it could work? Thank you for your answers!
The text was updated successfully, but these errors were encountered: