backstage / community-plugins

Community plugins for Backstage
Apache License 2.0
111 stars 80 forks source link

[Plugin] OpenApi Generator as templater for scaffolder plugin #266

Open kiranpatel11 opened 3 years ago

kiranpatel11 commented 3 years ago

Summary

For API-First approach, OpenApi generator is a convenient way to bootstrap a project with actual rest endpoints and data model included in code generation in a dynamic way.

The feature can be enhancement to scaffolder-backend plugin or a separate plugin to provide openapi-generator as templater.

https://github.com/OpenAPITools/openapi-generator https://www.npmjs.com/package/@openapitools/openapi-generator-cli

Context

Most of the templates are static in nature with include HelloWorld kind of examples, which often serve purpose of reference implementation and need to be removed after initial code generation. OpenApi Generator takes api definition as input and code generation can be made more dynamic and useful for actual usecase and implementation standards.

freben commented 3 years ago

So with the new version of templates, you are free to make your own actions that run as part of the scaffolding. Sounds to me like it might be interesting to make an action that can run the openapi generator. You can either add that as a custom action of your own, or contribute it to open source. I suppose that the user will want to select from a number of different API definitions then? How do you envision that the user flow would look, should the user supply a URL to an API definition in their version control system when filling out the template form?

kiranpatel11 commented 3 years ago

Here is an example cli usage

openapi-generator-cli generate -g ruby -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /var/tmp/ruby-client

Yes, all these options can be supplied by filling out template form.

Indeed, actions are now more appropriate to address such needs.