openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

Set OpenAPIConfig BASE field through the npx command

Open martinshhh opened this issue 2 years ago • 2 comments

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.

martinshhh avatar Aug 04 '23 16:08 martinshhh

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.

dagadbm avatar Mar 12 '24 14:03 dagadbm

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

mrlubos avatar Mar 13 '24 17:03 mrlubos