Repository metrics
- Stars
- (3,783 stars)
- PR merge metrics
- (PR metrics pending)
Description
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Linux executable
Client library/SDK language
PHP
Describe the bug
Generating coded in PHP, when in the openapi we have a definition of a component (B) inside another component (A) the class name is generated concatenating parent component with underscores (A_B). This generated name can collide with the name of another component, so the generated class overwrites the existing one.
For example, in we have an openapi with a component test_case and a component test, that includes another component called case.
"definitions": { "test_case": { "properties": { "name": { "example": 1, "type": "integer" }, "uuid": { "example": "e22e3261-2bcf-4ca8-acc7-819cf9f19548", "type": "string" } }, "type": "object" }, "test": { "properties": { "case": { "properties": { "name2": { "example": 2, "type": "integer" }, "uuid2": { "example": "6d5b5321-c25c-4dbb-a3e1-da0a506131d2", "type": "string" } } } }, "type": "object" } }
When we generate code, we have only two classes:
- Test
- Test_case The class Test_case has been generated for component case having properties name2 and uuid2, but overwritten by the generation of component test_case having properties name and uuid eventually, so we have lost the functionality of component case.
Class name generation for inline components should check if a class already exists and, in that case, rename it.
Expected behavior
In the example:
"definitions": { "test_case": { "properties": { "name": { "example": 1, "type": "integer" }, "uuid": { "example": "e22e3261-2bcf-4ca8-acc7-819cf9f19548", "type": "string" } }, "type": "object" }, "test": { "properties": { "case": { "properties": { "name2": { "example": 2, "type": "integer" }, "uuid2": { "example": "6d5b5321-c25c-4dbb-a3e1-da0a506131d2", "type": "string" } } } }, "type": "object" } }
After generation code, we should have 3 classes instead of only 2:
- Test
- Test_case
- Test_case1 (or any other name different from the existing Test_case)
How to reproduce
Use the attached openapi description and generate code in PHP.
Open API description file
{
"basePath": "/api",
"consumes": [
"application/json",
"application/hal+json"
],
"info": {
"contact": {
"name": "Test",
"url": "https://test.lan"
},
"title": "ONTAP REST API Online Reference",
"version": "v1"
},
"paths": {
"/tests_cases": {
"get": {
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/test_case"
}
}
}
}
},
"/tests": {
"get": {
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/test"
}
}
}
}
}
},
"produces": [
"application/json",
"application/hal+json"
],
"schemes": [
"https"
],
"security": [
{
"simple": []
}
],
"securityDefinitions": {
"simple": {
"type": "basic"
}
},
"swagger": "2.0",
"definitions": {
"test_case": {
"properties": {
"name": {
"example": 1,
"type": "integer"
},
"uuid": {
"example": "e22e3261-2bcf-4ca8-acc7-819cf9f19548",
"type": "string"
}
},
"type": "object"
},
"test": {
"properties": {
"case": {
"properties": {
"name2": {
"example": 2,
"type": "integer"
},
"uuid2": {
"example": "6d5b5321-c25c-4dbb-a3e1-da0a506131d2",
"type": "string"
}
}
}
},
"type": "object"
}
}
}
Kiota Version
1.21.0
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
- OS: Ubuntu 22.04
Debug output
</details>
### Other information
_No response_