Skip to content

[PHP] Non-leading numbers removed from generated classnames #4211

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
careys7 opened this issue Nov 17, 2016 · 4 comments
Closed

[PHP] Non-leading numbers removed from generated classnames #4211

careys7 opened this issue Nov 17, 2016 · 4 comments

Comments

@careys7
Copy link

careys7 commented Nov 17, 2016

Description

Trying to generate classes for the Magento 2 schema JSON (which has other issues that need addressing within the schema itself), the versioning that Magento has applied to their API gets removed. I wonder if this should be supported in swagger-codegen?

For example: catalogAttributeSetRepositoryV1 gets converted to an API class of : CatalogAttributeSetRepositoryVApi. The classname CatalogAttributeSetRepositoryV1Api would be legal in PHP (just not if the first character of the class was a number).

Swagger-codegen version

2.2.2-SNAPSHOT

Swagger declaration file content or url

http://devdocs.magento.com/swagger/schemas/latest-2.0.schema.json

{
  "tags": [
    {
      "name": "storeStoreRepositoryV1",
      "description": "Store repository interface"
    },
  ]
}
Command line used for generation

Using jimschubert/swagger-codegen-cli:

docker-compose.yml:

  swagger:
    image: jimschubert/swagger-codegen-cli
    volumes:
      - ./swagger/config:/root/config
      - ./swagger/schema:/root/schema
      - ./swagger/export:/root/export

config.json:

{
  "variableNamingConvention" : "camelCase",
  "invokerPackage" : "SwaggerClient\\MagentoEnterprise212",
  "packagePath" : "MagentoEnterprise212",
  "composerProjectName" : "swaggerclient-magentoenterprise212",
  "gitUserId" : "test"
}

Command:

docker-compose run --rm swagger generate \
            -i /root/schema/magento2/schema.json \
            -l php \
            -o /root/export/result/ \
            -c /root/config/magento2/config.json
Steps to reproduce
  1. Create docker-compose file with service shown above, with host sub-directories shown (./swagger/config,./swagger/schema,./swagger/export)
  2. Download Magento 2 schema to ./swagger/schema/schema.json
  3. Create config.json in ./swagger/config/config.json with contents shown above
  4. Run above command
Related issues

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

Magento 2 - PR 7446 - addressing issue with schema generation.

Suggest a Fix
@wing328 wing328 added this to the v2.2.2 milestone Nov 19, 2016
@wing328
Copy link
Contributor

wing328 commented Nov 19, 2016

@careysizer agreed with you that non-leading numbers should not be removed.

I'll try to fix it over the weekend. Will keep you posted.

@wing328
Copy link
Contributor

wing328 commented Nov 20, 2016

@careysizer I did a test with the latest master but couldn't repeat the issue. Here is partial result:

[main] INFO io.swagger.codegen.AbstractGenerator - writing file /var/tmp/php/tag3/SwaggerClient-php/lib/Api/CatalogAttributeSetRepositoryV1Api.php
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /var/tmp/php/tag3/SwaggerClient-php/test/Api/CatalogAttributeSetRepositoryV1ApiTest.php
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /var/tmp/php/tag3/SwaggerClient-php/docs/Api/CatalogAttributeSetRepositoryV1Api.md

Did you try building the local JAR based on the latest master?

@careys7
Copy link
Author

careys7 commented Nov 21, 2016

Thanks @wing328 - I tested with latest master (I was at cafcf51) and looks like that's working for me too.

@wing328
Copy link
Contributor

wing328 commented Nov 21, 2016

Glad to hear that it's working for you.

@wing328 wing328 closed this as completed Nov 21, 2016
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