Skip to content

[PHP] Invalid classes generated if models start with a digit #2392

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

Closed
willemstuursma opened this issue Mar 16, 2016 · 4 comments
Closed

[PHP] Invalid classes generated if models start with a digit #2392

willemstuursma opened this issue Mar 16, 2016 · 4 comments

Comments

@willemstuursma
Copy link

Some of the models start with a digit. E.g. a small part from my definition:

          "400": {
            "description": "Bad Request Data",
            "schema": {
              "$ref": "#/definitions/400ResponseModel"
            }
          },
          "401": {
            "description": "Unauthorized request",
            "schema": {
              "$ref": "#/definitions/401ResponseModel"
            }
          },

Apparently this works fine in some languages but for the PHP client it generates invalid classnames since PHP classes are not allowed to start with a digit:

/**
 * 400ResponseModel Class Doc Comment
 *
 * @category    Class
 * @description 
 * @package     Supplier\Cybersource
 * @author      http://github.com/swagger-api/swagger-codegen
 * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
 * @link        https://github.com/swagger-api/swagger-codegen
 */
class 400ResponseModel implements ArrayAccess
{
    /**
      * Array of property to type mappings. Used for (de)serialization 
      * @var string[]
      */
    static $swaggerTypes = array(
    /* ... */
@wing328
Copy link
Contributor

wing328 commented Mar 16, 2016

@willemstuursma thanks for reporting the issue. Similar to reserved keyword, we'll prepend "Model" to to the model name that starts with number.

@wing328
Copy link
Contributor

wing328 commented Mar 16, 2016

The fix has been merged into master. Please pull the latest and give it a try.

@wing328 wing328 closed this as completed Mar 16, 2016
@willemstuursma
Copy link
Author

Thanks. This looks like a good solution. I am not really sure how I can get the master .jar file? I used the wagger-codegen-cli-2.1.5.jar from the maven repos before.

@wing328
Copy link
Contributor

wing328 commented Mar 19, 2016

@willemstuursma please do the following

git clone https://github.com/swagger-api/swagger-codegen.git
cd swagger-codegen
mvn package
ls ./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar

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

No branches or pull requests

2 participants