Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional-properties serialization example/documentation #25

Closed
ltomes opened this issue Sep 25, 2019 · 7 comments
Closed

additional-properties serialization example/documentation #25

ltomes opened this issue Sep 25, 2019 · 7 comments

Comments

@ltomes
Copy link
Contributor

ltomes commented Sep 25, 2019

I am looking for (and am willing to make a PR) documenting the correct way to submit multiple additional properties to @openapitools/openapi-generator-cli from an npm script.

The example in the readme for using additional-properties only illustrates using a single property.

"my-awesome-script-name": "openapi-generator generate -i docs/openapi.yaml -g typescript-angular -o generated-sources/openapi --additional-properties=\"ngVersion=6.1.7\""

Could I get an example of an array of additional properties being used?
I will be happy to make a pr enhancing the example in the readme once I know what is required.

I would like to pass multiple properties defined in my generator type.

Examples of serialization issues experienced:

[error] Found unexpected parameters: [npmName=restClient,, supportsES6=true,, npmVersion=6.9.0,, withInterfaces=tr
ue]

"my-awesome-script-name": "openapi-generator generate -i docs/openapi.yaml -g typescript-angular -o generated-sources/openapi --additional-properties="ngVersion=6.1.7 npmName=restClient supportsES6=true npmVersion=6.9.0 withInterfaces=true"
Results in:

[error] Found unexpected parameters: [npmName=restClient, supportsES6=true, npmVersion=6.9.0, withInterfaces=true]

Could someone post an example of what additional-properties is expecting here?

Additional info:
The java tests around this seem to be expecting a map:
https://github.com/OpenAPITools/openapi-generator/blob/046db19a8590f3557ae1e04be75792bbeb39cb69/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypescriptAngularAdditionalPropertiesIntegrationTest.java#L36

List of keys we should be able to access from additional-properties:
https://openapi-generator.tech/docs/generators/typescript-angular

I have also tried using -p instead of --additional-properties as per the docs and got the same results above.

Edit: It appears the whitespace is important for the additional-properties keys.
This works for me:

"my-awesome-script-name": "openapi-generator generate -i docs/openapi.yaml -g typescript-angular -o generated-sources/openapi --additional-properties=ngVersion=6.1.7,npmName=restClient,supportsES6=true,npmVersion=6.9.0,withInterfaces=true"

I can make a pr that adds an example like this to the readme, that will hopefully save other developers a few hours of debugging.

@wing328
Copy link
Member

wing328 commented Oct 2, 2019

Please open an issue in https://github.com/OpenAPITools/openapi-generator instead as your question is about the underlying JAR (openapi-generator-cli.jar) instead of this wrapper.

@wing328 wing328 closed this as completed Oct 2, 2019
@wing328
Copy link
Member

wing328 commented Oct 2, 2019

I can make a pr that adds an example like this to the readme, that will hopefully save other developers a few hours of debugging.

Yes please. We welcome that.

@thril
Copy link

thril commented May 18, 2020

Edit: It appears the whitespace is important for the additional-properties keys.
This works for me:

"my-awesome-script-name": "openapi-generator generate -i docs/openapi.yaml -g typescript-angular -o generated-sources/openapi --additional-properties=ngVersion=6.1.7,npmName=restClient,supportsES6=true,npmVersion=6.9.0,withInterfaces=true"

Thanks for this example. I was beginning to get a bit frustrated that I couldn't get it working, but you saved me!

@ltomes
Copy link
Contributor Author

ltomes commented May 18, 2020

Yeah it took quite a while to find the configuration it wanted. I just put out a pr that updates the base readme so hopefully others discover the correct syntax faster than you and I.

@kay-schecker
Copy link
Contributor

Please also see the new configuration file. It will handle that topic carefully for u.

@BobbyLarone
Copy link

Adding additional properties with : --additional-properties=ngVersion=6.1.7,npmName=restClient didn't work for me.

Adding quotes after the '=' sign and at the end made it work again. So now it looks like this
--additional-properties="ngVersion=6.1.7,npmName=restClient"

@xazos79
Copy link

xazos79 commented Apr 5, 2023

Adding additional properties with : --additional-properties=ngVersion=6.1.7,npmName=restClient didn't work for me.

Adding quotes after the '=' sign and at the end made it work again. So now it looks like this --additional-properties="ngVersion=6.1.7,npmName=restClient"

Thanks BobbyLarone, this was my problem too. Usage page doesn't mention this requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants