Bug Report Checklist
Description
When setting disallowAdditionalPropertiesIfNotPresent tofalse it generates models with missing imports, disallowing generating the models without manual edits.
Here's snippet from the code
from __future__ import annotations
import pprint
import re # noqa: F401
import json
# ------------------------------------------------------
# Here should be: from typing import Any, Dict, Optional
# ------------------------------------------------------
from typing import Optional
from pydantic import BaseModel, Field, StrictBool
class Object(BaseModel):
"""
Minimal object
"""
var_property: Optional[StrictBool] = Field(False, alias="property", description="Property")
additional_properties: Dict[str, **Any] = {}
__properties = ["property"]
...
openapi-generator version
Latest docker image
openapi-generator-cli 7.0.0-SNAPSHOT
commit : 7252d1a
built : -999999999-01-01T00:00:00+18:00
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
OpenAPI declaration file content or url
Minimal example
Generation Details
The code was generated by following command:
generate -i /local/openapi.yml -g python --additional-properties=disallowAdditionalPropertiesIfNotPresent=false
That should translate to
generatorName: python
outputDir: ./out/python/
inputSpec: https://gist.github.com/jakubno/fcc0709d18a4cc548e20d6499222fd14
templateDir: modules/openapi-generator/src/main/resources/python
additionalProperties:
packageName: minimal_example
disallowAdditionalPropertiesIfNotPresent: false
Steps to reproduce
Just generate the code from the minimal example and the file ./out/python/openapi_client/models/object.py will be missing imports from Typing, explicitly from typing import Any, Dict
Related issues/PRs
Didn't find any
Suggest a fix
Add the imports if the property disallowAdditionalPropertiesIfNotPresent is set to false.
Bug Report Checklist
Description
When setting
disallowAdditionalPropertiesIfNotPresenttofalseit generates models with missing imports, disallowing generating the models without manual edits.Here's snippet from the code
openapi-generator version
Latest docker image
OpenAPI declaration file content or url
Minimal example
Generation Details
The code was generated by following command:
That should translate to
Steps to reproduce
Just generate the code from the minimal example and the file
./out/python/openapi_client/models/object.pywill be missing imports fromTyping, explicitlyfrom typing import Any, DictRelated issues/PRs
Didn't find any
Suggest a fix
Add the imports if the property
disallowAdditionalPropertiesIfNotPresentis set tofalse.