I use @openapitools/openapi-generator-cli(v2.1.7) to generate the API library on client side.
It works pretty well, except I am not able to format the code generated as I want.
I just noticed there is a new option that allows to configure the spaces as mentioned in the example ("spaces": 2):
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "4.3.1",
"storageDir": "~/my/custom/storage/dir", // optional
"generators": { // optional
"v2.0": { // any name you like (just printed to the console log)
"generatorName": "typescript-angular",
"output": "#{cwd}/output/v2.0/#{ext}/#{name}",
"glob": "examples/v2.0/{json,yaml}/*.{json,yaml}",
"additionalProperties": {
"ngVersion": "6.1.7",
"npmName": "restClient",
"supportsES6": "true",
"npmVersion": "6.9.0",
"withInterfaces": true
}
},
"v3.0": { // any name you like (just printed to the console log)
"generatorName": "typescript-fetch",
"output": "#{cwd}/output/v3.0/#{ext}/#{name}",
"glob": "examples/v3.0/petstore.{json,yaml}"
}
}
}
}
This sounds great!
The problem is that I am not able to use the configuration file as specified in the official page:
If openapi-generator-cli generate is called without further arguments, then the configuration is automatically used to generate your code.
When I do that:
openapi-generator-cli generate
I keep stuck with an error:
[error] Required option '-i' is missing
And if I add the -i parameter, for example:
openapi-generator-cli generate -i http://localhost:8081/v2/api-docs
Then the "openapitools.json" file is ignored and overwritten by the default configuration:
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "4.3.1"
}
}
I also tried to do it the way I've used to do it up to now plus adding the parameter "-spaces=2":
openapi-generator-cli generate -i http://localhost:8081/v2/api-docs -g typescript-angular -o src/app/tools/openapi -spaces=2
But again it didn't work, plus I have now a useless file (openapitools.json) annoying my obsessive-compulsive disorder!
For info, my npm version (npm -v) is:
6.14.8
And I am using the current last Angular version:
11.0.0
v2.0 | v3.0
under key"input-spec":"http://localhost:port/whatever"
– Ague