Swagger-codegen: PHP Namespace Is Not API-Specific

Created on 11 Jul 2015  路  4Comments  路  Source: swagger-api/swagger-codegen

Right now, the generated PHP client SDK uses a generic namespace (SwaggerClient) and generic class names for some of the classes (Configuration, for example). This could cause conflicts if multiple Swagger based API SDKs were included in a single project.

The namespace of the generated API SDKs should be specific to the API itself, either generated automatically from the API name, or specified manually.

PHP

Most helpful comment

@andrewmunsell may I know if you've tested the PHP client in the develop_2.0 branch? You can also customize the PHP client via a config.json, e.g.

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
  -i http://petstore.swagger.io/v2/swagger.json \
  -l php \
  -o /var/tmp/php/ \
  -c /var/tmp/config.json

and here is the available option in the config.json

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l php

CONFIG OPTIONS
    modelPackage
        package for generated models

    apiPackage
        package for generated api classes

    packagePath
        main package name for classes

    srcBasePath
        directory directory under packagePath to serve as source root

All 4 comments

@andrewmunsell may I know if you've tested the PHP client in the develop_2.0 branch? You can also customize the PHP client via a config.json, e.g.

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
  -i http://petstore.swagger.io/v2/swagger.json \
  -l php \
  -o /var/tmp/php/ \
  -c /var/tmp/config.json

and here is the available option in the config.json

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l php

CONFIG OPTIONS
    modelPackage
        package for generated models

    apiPackage
        package for generated api classes

    packagePath
        main package name for classes

    srcBasePath
        directory directory under packagePath to serve as source root

@wing328 @andrewmunsell

I have filed a PR to fix this here: https://github.com/swagger-api/swagger-codegen/pull/977

Thanks @who. The PR has been merged into develop_2.0 branch.

@andrewmunsell please test to see if you're happy with the latest PHP client in develop_2.0 branch.

@andrewmunsell we're closing this issue since we've not heard from you. Please open a new one if needed.

Was this page helpful?
0 / 5 - 0 ratings