hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.28k stars 102 forks source link

Some config options cannot be set through cli flags #870

Open JordanWeatherby opened 2 months ago

JordanWeatherby commented 2 months ago

Description

Hello, I have been working through the migration guide and have hit a roadblock due to changes in config settings

We have many different backend services at different URLS that we generate from, and as far as I can tell it is not possible for us to use one config file and set the input URL separately each run.

Our package.json looks something like this:

"generate": "yarn run generate:facts && yarn run generate:users"
"_generate:base": "openapi-ts --client axios --name AppClient --schemas false --enums typescript",
"generate:facts": "yarn run _generate:base --input https://facts.foobar.com/openapi.json --output ./src/generated/facts",
"generate:users": "yarn run _generate:base --input https://users.foobar.com/openapi.json --output ./src/generated/users",

Since the enums option has been moved in the config file to be under types, it does not appear to be possible to set the enums through the command line anymore, I have tried ---types.enum javascript, --types \\{enums:\\ 'javascript'\\} etc.

Hope you can help

Reproducible example or configuration

No response

OpenAPI specification (optional)

No response

System information (optional)

No response

mrlubos commented 2 months ago

Hey @JordanWeatherby that's correct, I'd need to add support for nested configuration flags

JordanWeatherby commented 2 months ago

Thanks @mrlubos!

I actually just realised it is possible to use a config file and overwrite the input and output values in the cli, so this unblocks my use case

Still think it is useful to be able to set these directly without a config file though so I will leave this issue open.

mrlubos commented 2 months ago

Yep, agreed

bhperry commented 2 months ago

One issue I've noticed with setting output via command line flag is that it overwrites the entire output block to a string even if it was previously an object. So you can't configure formatter/linter options in the file and then set just the output dir at runtime (and there does not seem to be formatter/linter CLI options yet)

bhperry commented 2 months ago

I have a script that handles checking if the openapi files are up-to-date with a dry-run mode by swapping the output dir and comparing. But unforatunately I can't do that and also have formatter settings.