-
-
Couldn't load subscription status.
- Fork 7.3k
Open
Labels
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 to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When using --model-name-prefix or suffix, the generated code has two issues:
- when models are used within other models the suffix is duplicated
- when models are used within other models the models are not imported (imports are not present)
class ApiObj(BaseModel):
"""
ApiObj
""" # noqa: E501
prop1: Optional[ApiApiProp1] = None
prop2: Optional[ApiApiProp2] = None
__properties: ClassVar[List[str]] = ["prop1", "prop2"]The generator outputs these warnings:
[main] WARN o.o.c.l.AbstractPythonCodegen - Failed to lookup model in createImportMapOfSet ApiApiProp1
[main] WARN o.o.c.l.AbstractPythonCodegen - Failed to lookup model in createImportMapOfSet ApiApiProp2
[main] ERROR o.o.c.l.AbstractPythonCodegen - Failed to look up ApiApiProp1 from the imports (map of set) of models.
[main] ERROR o.o.c.l.AbstractPythonCodegen - Failed to look up ApiApiProp1 from the imports (map of set) of models.
[main] ERROR o.o.c.l.AbstractPythonCodegen - Failed to look up ApiApiProp2 from the imports (map of set) of models.
[main] ERROR o.o.c.l.AbstractPythonCodegen - Failed to look up ApiApiProp2 from the imports (map of set) of models.
...
openapi-generator version
generator cli 7.14.0
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: ''
version: ''
paths: {}
components:
schemas:
Obj:
type: object
properties:
prop1:
$ref: '#/components/schemas/Prop1'
prop2:
$ref: '#/components/schemas/Prop2'
Prop1:
type: object
properties:
name:
type: string
Prop2:
type: object
properties:
name:
type: string
Generation Details
npx @openapitools/openapi-generator-cli generate -g python-fastapi -i api2.yaml --model-name-prefix Api -o ./packages/python-fastapi2