Closed BastiOfBerlin closed 7 years ago
@BastiOfBerlin have you tried the npmName
option to customize the package name?
npmName
The name under which you want to publish generated npm package
Ref: java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l typescript-angular2
@wing328 this works indeed and was a mistake on my side.
@BastiOfBerlin np. Let us know if you've further question or feedback.
(we've just added Swagger Codegen to ProductHunt: https://www.producthunt.com/posts/swagger-codegen, please upvote if you find Swagger Codegen useful)
Description
The title of an API seems to be used as the npm module's name more or less directly. Unfortunately, the conventions for that name attribute are more restrictive than those for API title. Specifically, npm's docs states that:
This leads to invalid package.json files. As a consequence, it is not possible to include the module as a dependency using npm.
Swagger-codegen version
2.2.2-SNAPSHOT as of 2017-01-23
Swagger declaration file content
Produced package.json
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i "http://localhost:8080/swaggerfile" -l typescript-angular2 -c "swagger-codegen-config.ts.json" --additional-properties npmVersion=1.0.0 -o ".\generated-api"
Suggest a Fix
I suggest converting the title in the following way(s) before using it as the module's name:
Maybe it would be best to also strip out any non-URL-safe characters?