-
Notifications
You must be signed in to change notification settings - Fork 61
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
[PROPOSAL] Build architecture for spec and client generation #74
Comments
Will raise a PR soon for publishing specs. |
We have a number of ongoing PoCs [1], [2], [3] to try out client generation for different programming languages and specs (Smithy, OpenAPI). We are still debating on what is the best approach here (should we use Smithy, OpenAPI or something else completely) but I think the one large key problems is not getting enough attention: crafting the Smithy / OpenAPI / ... specs. As far as I can tell, all our PoCs craft them by hand, including this repo [4], this is huge effort. But we already have a large chunk of API specs here https://github.com/opensearch-project/OpenSearch/tree/main/rest-api-spec/src/main/resources/rest-api-spec/api, inherited from Elasticsearch. Shouldn't we consider to benefit from it and try to convert them into Smithy / OpenAPI specs? [1] opensearch-project/opensearch-java#336 |
@reta Absolutely! I missed adding that in my proposal that we can explore on how Let me add it in this in the proposal too. |
Late to this issue, but had some thoughts. First, it may be easier to think of API specs being built, released, and follow semver that can match what they specify if that relationship is 1:1, or have their own version if it's 1:many. This way if a mistake was made in the specs for OpenSearch 2.6.0, it can be corrected, but we can distinguish API specs between before and after correction. I envision that this repo gets built and released, possibly just on GitHub. IMO this step is missing from the above proposal. The GitHub pages hosted website can be a result of publishing a released version of the API specs and I like the idea of enabling it to be consumed by a Swagger UI. |
We have this workflow in most clients now, closing. |
What/Why
What are you proposing?
A build architecture for API spec generation and code generation for OpenSearch.
Description
Smithy models in this repo are used to generate Smithy and OpenAPI specs for the OpenSearch APIs. Smithy is an open source IDL which is protocol agnostic, extensible and supports code generation. (See opensearch-project/OpenSearch#1590)
Smithy models are converted to Smithy and OpenAPI specs during build. These specs can be hosted to view and edit and further be used for client and server generation.
What users have asked for this feature?
What problems are you trying to solve?
What is the developer experience going to be?
What is the user experience going to be?
Publish OpenSearch API specs
This proposal talks about hosting OpenSearch API specs on Github Pages. A Github workflow will be triggered when a change is made to the Smithy models. This workflow will build the models and if there is a change to the API specs, it will create a pull request to update the specs hosted in the repo and in turn update the specs on Github Pages. OpenAPI specs will be available to view using Swagger UI.
Similar process can be followed for hosting Smithy specs.
Other options explored
Client Generation
Using the above hosted API specs, client APIs can be generated using an open-api generator or a custom generator. Smithy specs can be used to generate APIs using smithy language generators. Client generators will reside in each client repo. Although what kind of generators can be used to generate clients is a separate proposal for each client (see opensearch-project/opensearch-java#284, opensearch-project/opensearch-ruby#139) which is out of scope for this proposal, this proposal talks about linking the process of how a change in API specs results in incremental API generation for clients.
A Github workflow in each client will be triggered when a change is detected in the API specs (a workflow in one repository can trigger an action in another repository see https://github.com/orgs/community/discussions/26323). The workflow will run the generator using the hosted API specs and a pull request will be created by the workflow to update the generated code.
TODO: Once a generator is ready for a client, implement CI for the client as mentioned above.
Server Route Generation
Similar CI workflow like client generation can be used for server route generation. The generators for server are out of scope of this proposal.
Why should it be built? Any reason not to?
What will it take to execute?
Any remaining open questions?
OpenSearch
repo so they are a better representation of the server or should they live inopensearch-api-specification
as a separate entity which represents both server and clients?rest-api-spec
to create Smithy/OpenAPI specs? - To benefit from the already existing rest-api-spec, a PR is out which converts the rest-api-spec to Smithy models using a translator.The text was updated successfully, but these errors were encountered: