swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.05k stars 6.03k forks source link

[PHP] Bug - composerVendorName & composerProjectName options not working #4923

Closed ido567 closed 7 years ago

ido567 commented 7 years ago
Description

It seems like the composerVendorName & composerProjectName options are not working. The options is passed by -D{optionName} in the command which is listed below, but the "name" in the composer.json is not effected.

At the end, the generated name in the composer.json is generated by git-user-id & get-repo-id instead of my custom options.

Expected result: autodesk/client Real result: Developer-Autodesk/forge-api-php-client

Swagger-codegen version

I'm not so sure how to check the version, The this command java -jar swagger-codegen-cli.jar version results 2.2.2-SNAPSHOT

Command line used for generation

generate -i swagger-specs/swagger.json -l php -o php --git-user-id=Developer-Autodesk --git-repo-id=forge-api-php-client -DcomposerVendorName=autodesk -DcomposerProjectName=client -DpackagePath=AutodeskClient

Suggest a Fix

Seems like the options is not detected in PhpClientCodegen. The condition below is negative.

if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
    this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
} else {
    additionalProperties.put(COMPOSER_PROJECT_NAME, composerProjectName);
}
ido567 commented 7 years ago

Apparently that custom options should be concatenated like: -DoptionA=1,optionB=2 instead of -DoptionA=1 -DoptionB=2