Bug Report Checklist
Description
When using snake case names for OpenAPI components such as operation IDs and schema names, the Python generator seems to normalize segments that contain a single character by combining them (e.g. test_s_t becomes test_st).
This can also lead to name collisions, which can break generation for otherwise valid schemas. While there seems to be a fallback for colliding operation IDs, when schema names collide in this way, only one of the schemas is generated and the API code attempts to import the missing model.
openapi-generator version
v7.25.0
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Schema Name Collision Reproducer
version: 1.0.0
paths:
/first:
get:
operationId: get_first_model
responses:
'200':
description: First model
content:
application/json:
schema:
$ref: '#/components/schemas/test_st'
/second:
get:
operationId: get_second_model
responses:
'200':
description: Second model
content:
application/json:
schema:
$ref: '#/components/schemas/test_s_t'
components:
schemas:
test_st:
type: object
properties:
first:
type: string
test_s_t:
type: object
properties:
second:
type: integer
Generation Details
From the languages I tested, this issue only seems to occur with Python.
Steps to reproduce
Generate a Python client using the provided OpenAPI declaration.
Only one TestSt model is generated, while default_api.py contains an invalid import for TestST:
from openapi_client.models.test_st import TestST
from openapi_client.models.test_st import TestSt
There is no TestST model generated, so the resulting client cannot be imported.
The issue can also be observed in the generated response type for the second operation, which references TestST even though only TestSt exists.
Related issues/PRs
Suggest a fix
I am not familiar enough with the generator code to suggest an appropriate fix, but applying the same fallback solution used for operation IDs to schema models would at least fix the specific issue described here.
This case is obviously unlikely to occur naturally, but a simple workaround is to rename the affected components so that their normalized model names do not collide.
Bug Report Checklist
Description
When using snake case names for OpenAPI components such as operation IDs and schema names, the Python generator seems to normalize segments that contain a single character by combining them (e.g.
test_s_tbecomestest_st).This can also lead to name collisions, which can break generation for otherwise valid schemas. While there seems to be a fallback for colliding operation IDs, when schema names collide in this way, only one of the schemas is generated and the API code attempts to import the missing model.
openapi-generator version
v7.25.0
OpenAPI declaration file content or url
Generation Details
From the languages I tested, this issue only seems to occur with Python.
Steps to reproduce
Generate a Python client using the provided OpenAPI declaration.
Only one
TestStmodel is generated, whiledefault_api.pycontains an invalid import forTestST:There is no
TestSTmodel generated, so the resulting client cannot be imported.The issue can also be observed in the generated response type for the second operation, which references
TestSTeven though onlyTestStexists.Related issues/PRs
Suggest a fix
I am not familiar enough with the generator code to suggest an appropriate fix, but applying the same fallback solution used for operation IDs to schema models would at least fix the specific issue described here.
This case is obviously unlikely to occur naturally, but a simple workaround is to rename the affected components so that their normalized model names do not collide.