-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master?
- Have you searched for related issues/PRs?
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=trueSteps 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.pycontains: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.pywith classItemmodels/item_list.pywith classItemList
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.
Metadata
Metadata
Assignees
Labels
No labels