OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.88k stars 6.59k forks source link

[REQ] Allow for the CLI to watch for spec file changes, and generate on demand #3982

Open arciisine opened 5 years ago

arciisine commented 5 years ago

Is your feature request related to a problem? Please describe.

Currently, I run a project in which model/controller classes are monitored in real time, and the spec.json is updated automatically as any changes are made. The desire is to marry this with front-end development, and allow for dynamic updating of API clients. This aims to provide a seamless integration between making model changes in the API, and having the API client reflect those changes near instantly.

Describe the solution you'd like

What I'm proposing is to add a watch flag, (-w, --watch) to the cli. When in watch mode, the cli will generate the code on initial startup, and will remain running listening for changes to the spec file. When any changes are detected, the code generation will execute again, producing the updated client output.

Describe alternatives you've considered

I've toyed with this in a few manners, but generally the latency is high with having to restart the cli (and JVM) on every execution.

arciisine commented 5 years ago

I have a working PR in a fork if that helps the conversation. https://github.com/arciisine/openapi-generator/pull/1/files

NateRadebaugh commented 1 year ago

@wing328 is this a feature that's possible to get merged in? It looks like @arciisine has a workable solution but it's a bunch of years ago so likely may need a different solution these days?

arciisine commented 1 year ago

I'm still actively using it, and have to rebuild/republish some docker images every so often to pick up the latest client generators. I was actually considering dropping support for this generator in my framework due to this not getting landed after so long.

I'm going to update the PR against the latest in case this may get landed.