Bug Report Checklist
Description
When schema components are defined with lowercase names (e.g., item, itemList), the Python generator does not generate model files, but the generated API files still try to import these models, causing ModuleNotFoundError at runtime.
openapi-generator version
7.10.0 (via openapi-generator-cli)
OpenAPI declaration file content or url
Minimal reproduction (fails):
openapi: 3.0.0
info:
title: Minimal Repro
version: 1.0.0
paths:
/items:
get:
operationId: getItems
responses:
'200':
description: List of items
content:
application/json:
schema:
$ref: '#/components/schemas/itemList'
/items/{id}:
get:
operationId: getItem
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: Single item
content:
application/json:
schema:
$ref: '#/components/schemas/item'
components:
schemas:
item:
type: object
properties:
id:
type: string
name:
type: string
itemList:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/item'
Same spec with PascalCase names (works):
Replace item with Item and itemList with ItemList - models are generated correctly.
Generation Details
openapi-generator-cli generate \
--generator-name python \
--input-spec spec.yaml \
--output output \
--additional-properties=packageName=repro,library=httpx,generateSourceCodeOnly=true
Steps to reproduce
- Save the minimal spec above as
spec.yaml
- Run the generation command
- Observe that
models/ directory contains only __init__.py (no model files)
- Observe that
api/default_api.py contains:
from repro.models.item import Item
from repro.models.item_list import ItemList
- Try to import:
python -c "from repro.api.default_api import DefaultApi"
Expected behavior
Model files should be generated for schemas regardless of casing:
models/item.py with class Item
models/item_list.py with class ItemList
Actual behavior
- No model files are generated
- API files import non-existent models
- Runtime error:
ModuleNotFoundError: No module named 'repro.models.item'
Related issues/PRs
None found.
Suggest a fix
The generator should normalize schema names and generate model files regardless of the original casing in the OpenAPI spec.
Bug Report Checklist
Description
When schema components are defined with lowercase names (e.g.,
item,itemList), the Python generator does not generate model files, but the generated API files still try to import these models, causingModuleNotFoundErrorat runtime.openapi-generator version
7.10.0 (via
openapi-generator-cli)OpenAPI declaration file content or url
Minimal reproduction (fails):
Same spec with PascalCase names (works):
Replace
itemwithItemanditemListwithItemList- models are generated correctly.Generation Details
Steps to reproduce
spec.yamlmodels/directory contains only__init__.py(no model files)api/default_api.pycontains:python -c "from repro.api.default_api import DefaultApi"Expected behavior
Model files should be generated for schemas regardless of casing:
models/item.pywith classItemmodels/item_list.pywith classItemListActual behavior
ModuleNotFoundError: No module named 'repro.models.item'Related issues/PRs
None found.
Suggest a fix
The generator should normalize schema names and generate model files regardless of the original casing in the OpenAPI spec.