ferdikoomen / openapi-typescript-codegen

NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification
MIT License
2.98k stars 526 forks source link

Set OpenAPIConfig BASE field through the npx command #1680

Open martinshhh opened 1 year ago

martinshhh commented 1 year ago

Not sure if this is already possible, but my idea was to be able to set the BASE field on OpenAPIConfig through the npx command, something like: npx openapi-typescript-codegen --input api-docs.json --output ./generated --basePath "pets-service"

The reason for this is because whenever the BE makes changes to the API I need to generate the clients again, and when I do this I need to change everytime the OpenAPI.ts BASE field to the one I want. Since I'm using a proxy on my requests, I cannot have the server-endpoint being set there due to CORS, that's why I change it.

This or a way to not make changes on the OpenAPI.ts file whenever we generate the clients.

dagadbm commented 8 months ago

This is extremely important else I have no way to even generate controllers for different environments : test/staging/prod.

ideally the BASE should just be set to '' and that's it.

mrlubos commented 8 months ago

Sharing the fix here for visibility https://github.com/nicolas-chaulet/openapi-typescript-codegen/issues/43#issuecomment-1993646116