Bug Report Checklist
Description
When a schema name starts with a number and has an object property, then the class name for that object property starts with a number.
This is not allowed in PHP.
For the example below two model classes are created.
- Model3dPosition
- 3dPositionPosition
The first model gets the Model prefix to fix the name. The second one however doesn't get this prefix.
openapi-generator version
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: modelWithANumber
description: Example of a model generated with a number as first character
version: 1.0.0
paths:
/:
get:
operationId: first
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/3d-position'
description: This route breaks
components:
schemas:
3d-position:
type: object
properties:
position:
type: object
properties:
x:
type: integer
y:
type: integer
z:
type: integer
Generation Details
I used the following docker command:
docker run --rm --user "$UID:$(id -g)" \
-v "$PWD":/local \
openapitools/openapi-generator-cli:v7.24.0 generate \
-i "/local/api.yml" \
-g php-nextgen \
-c /local/generate-nextgen.json \
-o /local/nextgen/
Steps to reproduce
- Generate the api as described above.
- Check the model directory (src/Model)
- See error for 3dPositionPosition.php.
- Optionally lint using
php -l
Related issues/PRs
I couldn't find anyting.
Suggest a fix
I think the logic that adds Model as a prefix should be expanded to also check the names for sub nested models.
This logic may also be missing for other generators
Bug Report Checklist
Description
When a schema name starts with a number and has an object property, then the class name for that object property starts with a number.
This is not allowed in PHP.
For the example below two model classes are created.
The first model gets the
Modelprefix to fix the name. The second one however doesn't get this prefix.openapi-generator version
OpenAPI declaration file content or url
Generation Details
I used the following docker command:
Steps to reproduce
php -lRelated issues/PRs
I couldn't find anyting.
Suggest a fix
I think the logic that adds
Modelas a prefix should be expanded to also check the names for sub nested models.This logic may also be missing for other generators