Bug Report Checklist
Description
When using the generated client from the following yaml, I got an error in file paginated_result_tax_collection_dto.py that the class is not defined.
NameError: name 'ResultsTupleInput' is not defined
If we check the file paginated_result_tax_collection_dto.py , we can see the ResultTuple class is declared after its use
XXX
PaginatedResultTaxCollectionDtoDictInput = typing.TypedDict(
'PaginatedResultTaxCollectionDtoDictInput',
{
"count": int,
"results": typing.Union[
ResultsTupleInput,
ResultsTuple
],
}
)
XXX
class ResultsTuple(
typing.Tuple[
my_object_dto.MyObjectDtoDict,
...
]
):
def __new__(cls, arg: typing.Union[ResultsTupleInput, ResultsTuple], configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None):
return Results.validate(arg, configuration=configuration)
openapi-json-schema-generator version
3.3.0
OpenAPI declaration file content or url
The original yaml was generated by FastAPI
{
"openapi": "3.1.0",
"info": {
"title": "my-service",
"version": "0.1.0"
},
"paths": {
"/api/hello": {
"get": {
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaginatedResult_MyObjectDto_"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"PaginatedResult_MyObjectDto_": {
"properties": {
"count": {
"type": "integer",
"title": "Count"
},
"results": {
"items": {
"$ref": "#/components/schemas/MyObjectDto"
},
"type": "array",
"title": "Results"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"count",
"results"
],
"title": "PaginatedResult[MyObjectDto]"
},
"MyObjectDto": {
"properties": {
"id": {
"type": "string",
"format": "uuid",
"title": "id"
}
},
"additionalProperties": false,
"type": "object",
"title": "MyObjectDto"
}
}
}
}
Generation Details
Generated through docker:
docker run --rm -v ./:/local openapijsonschematools/openapi-json-schema-generator-cli:3.3.0 generate -i /local/my-service.yml -g python -o /local/out
Steps to reproduce
Generate the client, import it and try to call the api, the code does not start
Suggest a fix
The class is actually defined, it seems the order is the problem
Bug Report Checklist
Description
When using the generated client from the following yaml, I got an error in file
paginated_result_tax_collection_dto.pythat the class is not defined.NameError: name 'ResultsTupleInput' is not definedIf we check the file
paginated_result_tax_collection_dto.py, we can see theResultTupleclass is declared after its useopenapi-json-schema-generator version
3.3.0
OpenAPI declaration file content or url
The original yaml was generated by FastAPI
Generation Details
Generated through docker:
docker run --rm -v ./:/local openapijsonschematools/openapi-json-schema-generator-cli:3.3.0 generate -i /local/my-service.yml -g python -o /local/outSteps to reproduce
Generate the client, import it and try to call the api, the code does not start
Suggest a fix
The class is actually defined, it seems the order is the problem