OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.9k stars 6.58k forks source link

[BUG] [PYTHON] Regression: missing imports for response models #18932

Open kj4tmp opened 5 months ago

kj4tmp commented 5 months ago

Bug Report Checklist

Description

docker image openapitools/openapi-generator-cli:v7.5.0 is OK docker image openapitools/openapi-generator-cli:latest is BAD docker image openapitools/openapi-generator-cli:latest-release is BAD

Imports for response models are missing from the generated class definition in python.

v7.5.0 OK example:

# coding: utf-8

"""
    vsi-terhw-piplc-battery-test

    piplc-battery-test

    The version of the OpenAPI document: 0.0.4
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501

import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictBytes, StrictFloat, StrictInt, StrictStr
from typing import Any, Dict, Optional, Union
from typing_extensions import Annotated
from vsi_terhw_piplc_battery_test.models.response_search import ResponseSearch
from vsi_terhw_piplc_battery_test.models.response_value import ResponseValue
from vsi_terhw_piplc_battery_test.models.single_commander_lock_state_response_model import SingleCommanderLockStateResponseModel

from vsi_terhw_piplc_battery_test.api_client import ApiClient, RequestSerialized
from vsi_terhw_piplc_battery_test.api_response import ApiResponse
from vsi_terhw_piplc_battery_test.rest import RESTResponseType

class BatteryTestApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client

    @validate_call
    async def check_my_auth_lock_check_my_auth_get(
        self,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> SingleCommanderLockStateResponseModel:
        """Check My Auth

In the OK example, notice that SingleCommanderLockStateResponseModel is imported.

Here is the bad example (versions after v7.5.0)

# coding: utf-8

"""
    vsi-terhw-piplc-battery-test

    piplc-battery-test

    The version of the OpenAPI document: 0.0.3
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501

import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictBytes, StrictFloat, StrictInt, StrictStr
from typing import Any, Dict, Optional, Union
from typing_extensions import Annotated

from vsi_terhw_piplc_battery_test.api_client import ApiClient, RequestSerialized
from vsi_terhw_piplc_battery_test.api_response import ApiResponse
from vsi_terhw_piplc_battery_test.rest import RESTResponseType

class BatteryTestApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client

    @validate_call
    async def check_my_auth_lock_check_my_auth_get(
        self,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> SingleCommanderLockStateResponseModel:
        """Check My Auth

notice that in the BAD example, the SingleCommanderLockStateResponseModel is not imported, and produces the following error on import:

Traceback (most recent call last):
  File "/workspaces/piplc-scripts/scripts/battery-test/bt_example.py", line 13, in <module>
    import vsi_terhw_piplc_battery_test as bt
  File "/usr/local/lib/python3.11/site-packages/vsi_terhw_piplc_battery_test/__init__.py", line 20, in <module>
    from vsi_terhw_piplc_battery_test.api.cicd_api import CICDApi
  File "/usr/local/lib/python3.11/site-packages/vsi_terhw_piplc_battery_test/api/__init__.py", line 6, in <module>
    from vsi_terhw_piplc_battery_test.api.battery_test_api import BatteryTestApi
  File "/usr/local/lib/python3.11/site-packages/vsi_terhw_piplc_battery_test/api/battery_test_api.py", line 28, in <module>
    class BatteryTestApi:
  File "/usr/local/lib/python3.11/site-packages/vsi_terhw_piplc_battery_test/api/battery_test_api.py", line 56, in BatteryTestApi
    ) -> SingleCommanderLockStateResponseModel:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
NameError: name 'SingleCommanderLockStateResponseModel' is not defined
openapi-generator version

docker image openapitools/openapi-generator-cli:v7.5.0 is OK docker image openapitools/openapi-generator-cli:latest is BAD docker image openapitools/openapi-generator-cli:latest-release is BAD

OpenAPI declaration file content or url
{"openapi":"3.1.0","info":{"title":"vsi-terhw-piplc-battery-test","description":"piplc-battery-test","version":"0.0.4"},"paths":{"/opcua/search/":{"get":{"tags":["battery-test"],"summary":"Opcua Search","description":"Find a node in the OPCUA server by its display name and return the nodeid.","operationId":"opcua_search_opcua_search__get","security":[{"HTTPBasic":[]}],"parameters":[{"name":"displayname","in":"query","required":true,"schema":{"type":"string","description":"display name of node to find","title":"Displayname"},"description":"display name of node to find","example":"temperature_setpoint_1"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"string","$ref":"#/components/schemas/ResponseSearch"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/opcua/nodes/":{"post":{"tags":["battery-test"],"summary":"Opcua Write","description":"Write to an OPCUA node on the server using its nodeid or displayname.\nYou must provide at least one. If both are provided, the displayname will be used.\n\nuse 'True', 'False' for bools.\nWrite numbers (12.23, etc.) for ints, reals","operationId":"opcua_write_opcua_nodes__post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"nodeid","in":"query","required":false,"schema":{"type":"string","description":"The node id of the node","title":"Nodeid"},"description":"The node id of the node","example":"n=3,i=46"},{"name":"displayname","in":"query","required":false,"schema":{"type":"string","description":"display name of node to find","title":"Displayname"},"description":"display name of node to find","example":"temperature_setpoint_1"},{"name":"value","in":"query","required":true,"schema":{"type":"string","description":"The value to be written to the node.","title":"Value"},"description":"The value to be written to the node.","example":"12.43"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["battery-test"],"summary":"Opcua Read","description":"Read the value of an OPCUA node using its nodeid or its displayname.\nYou must provide at least one. If both are provided, the displayname will be used.","operationId":"opcua_read_opcua_nodes__get","security":[{"HTTPBasic":[]}],"parameters":[{"name":"nodeid","in":"query","required":false,"schema":{"type":"string","description":"The node id of the node","title":"Nodeid"},"description":"The node id of the node","example":"n=3,i=46"},{"name":"displayname","in":"query","required":false,"schema":{"type":"string","description":"display name of node to find","title":"Displayname"},"description":"display name of node to find","example":"temperature_setpoint_1"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"string","$ref":"#/components/schemas/ResponseValue"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/opcua/nodes/ints":{"get":{"tags":["battery-test"],"summary":"Opcua Read Int","operationId":"opcua_read_int_opcua_nodes_ints_get","security":[{"HTTPBasic":[]}],"parameters":[{"name":"displayname","in":"query","required":true,"schema":{"type":"string","title":"Displayname"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"integer","title":"Response 200 Opcua Read Int Opcua Nodes Ints Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["battery-test"],"summary":"Opcua Write Int","operationId":"opcua_write_int_opcua_nodes_ints_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"displayname","in":"query","required":true,"schema":{"type":"string","title":"Displayname"}},{"name":"value","in":"query","required":true,"schema":{"type":"integer","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/opcua/nodes/floats":{"get":{"tags":["battery-test"],"summary":"Opcua Read Float","operationId":"opcua_read_float_opcua_nodes_floats_get","security":[{"HTTPBasic":[]}],"parameters":[{"name":"displayname","in":"query","required":true,"schema":{"type":"string","title":"Displayname"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Opcua Read Float Opcua Nodes Floats Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["battery-test"],"summary":"Opcua Write Float","operationId":"opcua_write_float_opcua_nodes_floats_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"displayname","in":"query","required":true,"schema":{"type":"string","title":"Displayname"}},{"name":"value","in":"query","required":true,"schema":{"type":"number","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/opcua/nodes/bools":{"get":{"tags":["battery-test"],"summary":"Opcua Read Bool","operationId":"opcua_read_bool_opcua_nodes_bools_get","security":[{"HTTPBasic":[]}],"parameters":[{"name":"displayname","in":"query","required":true,"schema":{"type":"string","title":"Displayname"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Opcua Read Bool Opcua Nodes Bools Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["battery-test"],"summary":"Opcua Write Bool","operationId":"opcua_write_bool_opcua_nodes_bools_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"displayname","in":"query","required":true,"schema":{"type":"string","title":"Displayname"}},{"name":"value","in":"query","required":true,"schema":{"type":"boolean","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/opcua/nodes/strs":{"get":{"tags":["battery-test"],"summary":"Opcua Read Str","operationId":"opcua_read_str_opcua_nodes_strs_get","security":[{"HTTPBasic":[]}],"parameters":[{"name":"displayname","in":"query","required":true,"schema":{"type":"string","title":"Displayname"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"string","title":"Response 200 Opcua Read Str Opcua Nodes Strs Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["battery-test"],"summary":"Opcua Write Str","operationId":"opcua_write_str_opcua_nodes_strs_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"displayname","in":"query","required":true,"schema":{"type":"string","title":"Displayname"}},{"name":"value","in":"query","required":true,"schema":{"type":"string","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/lock/check_my_auth":{"get":{"tags":["battery-test"],"summary":"Check My Auth","description":"example method to check your own authentication against\n\nif you are authenticated, it will return the same as get_lock_state.\nIf the tool is currently unlocked, it will return status code 400.\nIf the tool is currently locked, and you provided incorrect credentials, it will return status code 401.","operationId":"check_my_auth_lock_check_my_auth_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SingleCommanderLockStateResponseModel","type":"string"}}}}},"security":[{"HTTPBasic":[]}]}},"/lock/force_unlock":{"delete":{"tags":["battery-test"],"summary":"Force Unlock Unsafe","description":"unsafe!! remove any lock, regardless of if you are authorized","operationId":"force_unlock_unsafe_lock_force_unlock_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SingleCommanderLockStateResponseModel","type":"string"}}}}}}},"/lock/unlock":{"delete":{"tags":["battery-test"],"summary":"Unlock","description":"remove your own lock and release tool for use by others","operationId":"unlock_lock_unlock_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SingleCommanderLockStateResponseModel","type":"string"}}}}},"security":[{"HTTPBasic":[]}]}},"/lock/":{"get":{"tags":["battery-test"],"summary":"Get Lock State","description":"get the current lock state as json","operationId":"get_lock_state_lock__get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"string","$ref":"#/components/schemas/SingleCommanderLockStateResponseModel"}}}}}},"post":{"tags":["battery-test"],"summary":"Lock","description":"lockout the tool for everyone except you","operationId":"lock_lock__post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"timeout_seconds","in":"query","required":true,"schema":{"type":"number","title":"Timeout Seconds"}},{"name":"message","in":"query","required":false,"schema":{"type":"string","default":"","title":"Message"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"string","$ref":"#/components/schemas/SingleCommanderLockStateResponseModel"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/script-executor/start":{"post":{"tags":["battery-test","Script Executor"],"summary":"Start Script","operationId":"start_script_script_executor_start_post","responses":{"204":{"description":"Successful Response"}},"security":[{"HTTPBasic":[]}]}},"/script-executor/stop":{"post":{"tags":["battery-test","Script Executor"],"summary":"Stop Script","operationId":"stop_script_script_executor_stop_post","responses":{"204":{"description":"Successful Response"}},"security":[{"HTTPBasic":[]}]}},"/script-executor/content":{"get":{"tags":["battery-test","Script Executor"],"summary":"Read Script Contents","operationId":"read_script_contents_script_executor_content_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","title":"Response 200 Read Script Contents Script Executor Content Get"}}}}},"security":[{"HTTPBasic":[]}]},"post":{"tags":["battery-test","Script Executor"],"summary":"Upload Script","operationId":"upload_script_script_executor_content_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_upload_script_script_executor_content_post"}}},"required":true},"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBasic":[]}]}},"/script-executor/state":{"get":{"tags":["battery-test","Script Executor"],"summary":"Read Script State","operationId":"read_script_state_script_executor_state_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","title":"Response 200 Read Script State Script Executor State Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/script-executor/output":{"get":{"tags":["battery-test","Script Executor"],"summary":"Read Script Output","operationId":"read_script_output_script_executor_output_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","title":"Response 200 Read Script Output Script Executor Output Get"}}}}},"security":[{"HTTPBasic":[]}]},"delete":{"tags":["battery-test","Script Executor"],"summary":"Delete Script Output","operationId":"delete_script_output_script_executor_output_delete","responses":{"204":{"description":"Successful Response"}},"security":[{"HTTPBasic":[]}]}},"/channels/TC1":{"get":{"tags":["battery-test"],"summary":"Get Tc1","operationId":"get_TC1_channels_TC1_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Tc1 Channels Tc1 Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/TC2":{"get":{"tags":["battery-test"],"summary":"Get Tc2","operationId":"get_TC2_channels_TC2_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Tc2 Channels Tc2 Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/TC3":{"get":{"tags":["battery-test"],"summary":"Get Tc3","operationId":"get_TC3_channels_TC3_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Tc3 Channels Tc3 Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/TC4":{"get":{"tags":["battery-test"],"summary":"Get Tc4","operationId":"get_TC4_channels_TC4_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Tc4 Channels Tc4 Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/K1_HTR_1":{"get":{"tags":["battery-test"],"summary":"Get K1 Htr 1","operationId":"get_K1_HTR_1_channels_K1_HTR_1_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Get K1 Htr 1 Channels K1 Htr 1 Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/K2_HTR_2":{"get":{"tags":["battery-test"],"summary":"Get K2 Htr 2","operationId":"get_K2_HTR_2_channels_K2_HTR_2_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Get K2 Htr 2 Channels K2 Htr 2 Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/battery_enable":{"get":{"tags":["battery-test"],"summary":"Get Battery Enable","operationId":"get_battery_enable_channels_battery_enable_get","security":[{"HTTPBasic":[]}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Get Battery Enable Channels Battery Enable Get"}}}}}},"post":{"tags":["battery-test"],"summary":"Set Battery Enable","operationId":"set_battery_enable_channels_battery_enable_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"value","in":"query","required":true,"schema":{"type":"boolean","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/channels/RTD1":{"get":{"tags":["battery-test"],"summary":"Get Rtd1","operationId":"get_RTD1_channels_RTD1_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Rtd1 Channels Rtd1 Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/RTD2":{"get":{"tags":["battery-test"],"summary":"Get Rtd2","operationId":"get_RTD2_channels_RTD2_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Rtd2 Channels Rtd2 Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/RTD3":{"get":{"tags":["battery-test"],"summary":"Get Rtd3","operationId":"get_RTD3_channels_RTD3_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Rtd3 Channels Rtd3 Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/RTD_median":{"get":{"tags":["battery-test"],"summary":"Get Rtd Median","operationId":"get_RTD_median_channels_RTD_median_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Rtd Median Channels Rtd Median Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/battery_voltage":{"get":{"tags":["battery-test"],"summary":"Get Battery Voltage","operationId":"get_battery_voltage_channels_battery_voltage_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Battery Voltage Channels Battery Voltage Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/temp_control_enabled":{"get":{"tags":["battery-test"],"summary":"Get Temp Control Enabled","operationId":"get_temp_control_enabled_channels_temp_control_enabled_get","security":[{"HTTPBasic":[]}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Get Temp Control Enabled Channels Temp Control Enabled Get"}}}}}},"post":{"tags":["battery-test"],"summary":"Set Temp Control Enabled","operationId":"set_temp_control_enabled_channels_temp_control_enabled_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"value","in":"query","required":true,"schema":{"type":"boolean","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/channels/temp_control_bang_low":{"get":{"tags":["battery-test"],"summary":"Get Temp Control Bang Low","operationId":"get_temp_control_bang_low_channels_temp_control_bang_low_get","security":[{"HTTPBasic":[]}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Temp Control Bang Low Channels Temp Control Bang Low Get"}}}}}},"post":{"tags":["battery-test"],"summary":"Set Temp Control Bang Low","operationId":"set_temp_control_bang_low_channels_temp_control_bang_low_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"value","in":"query","required":true,"schema":{"type":"number","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/channels/temp_control_bang_high":{"get":{"tags":["battery-test"],"summary":"Get Temp Control Bang High","operationId":"get_temp_control_bang_high_channels_temp_control_bang_high_get","security":[{"HTTPBasic":[]}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Temp Control Bang High Channels Temp Control Bang High Get"}}}}}},"post":{"tags":["battery-test"],"summary":"Set Temp Control Bang High","operationId":"set_temp_control_bang_high_channels_temp_control_bang_high_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"value","in":"query","required":true,"schema":{"type":"number","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/channels/batt_prot_overtemp":{"get":{"tags":["battery-test"],"summary":"Get Batt Prot Overtemp","operationId":"get_batt_prot_overtemp_channels_batt_prot_overtemp_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Get Batt Prot Overtemp Channels Batt Prot Overtemp Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/batt_prot_overtemp_setpoint":{"get":{"tags":["battery-test"],"summary":"Get Batt Prot Overtemp Setpoint","operationId":"get_batt_prot_overtemp_setpoint_channels_batt_prot_overtemp_setpoint_get","security":[{"HTTPBasic":[]}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Batt Prot Overtemp Setpoint Channels Batt Prot Overtemp Setpoint Get"}}}}}},"post":{"tags":["battery-test"],"summary":"Set Batt Prot Overtemp Setpoint","operationId":"set_batt_prot_overtemp_setpoint_channels_batt_prot_overtemp_setpoint_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"value","in":"query","required":true,"schema":{"type":"number","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/channels/batt_prot_undertemp":{"get":{"tags":["battery-test"],"summary":"Get Batt Prot Undertemp","operationId":"get_batt_prot_undertemp_channels_batt_prot_undertemp_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Get Batt Prot Undertemp Channels Batt Prot Undertemp Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/batt_prot_undertemp_setpoint":{"get":{"tags":["battery-test"],"summary":"Get Batt Prot Undertemp Setpoint","operationId":"get_batt_prot_undertemp_setpoint_channels_batt_prot_undertemp_setpoint_get","security":[{"HTTPBasic":[]}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Batt Prot Undertemp Setpoint Channels Batt Prot Undertemp Setpoint Get"}}}}}},"post":{"tags":["battery-test"],"summary":"Set Batt Prot Undertemp Setpoint","operationId":"set_batt_prot_undertemp_setpoint_channels_batt_prot_undertemp_setpoint_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"value","in":"query","required":true,"schema":{"type":"number","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/channels/batt_prot_overvolt":{"get":{"tags":["battery-test"],"summary":"Get Batt Prot Overvolt","operationId":"get_batt_prot_overvolt_channels_batt_prot_overvolt_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Get Batt Prot Overvolt Channels Batt Prot Overvolt Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/batt_prot_overvolt_setpoint":{"get":{"tags":["battery-test"],"summary":"Get Batt Prot Overvolt Setpoint","operationId":"get_batt_prot_overvolt_setpoint_channels_batt_prot_overvolt_setpoint_get","security":[{"HTTPBasic":[]}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Batt Prot Overvolt Setpoint Channels Batt Prot Overvolt Setpoint Get"}}}}}},"post":{"tags":["battery-test"],"summary":"Set Batt Prot Overvolt Setpoint","operationId":"set_batt_prot_overvolt_setpoint_channels_batt_prot_overvolt_setpoint_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"value","in":"query","required":true,"schema":{"type":"number","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/channels/batt_prot_undervolt":{"get":{"tags":["battery-test"],"summary":"Get Batt Prot Undervolt","operationId":"get_batt_prot_undervolt_channels_batt_prot_undervolt_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Get Batt Prot Undervolt Channels Batt Prot Undervolt Get"}}}}},"security":[{"HTTPBasic":[]}]}},"/channels/batt_prot_undervolt_setpoint":{"get":{"tags":["battery-test"],"summary":"Get Batt Prot Undervolt Setpoint","operationId":"get_batt_prot_undervolt_setpoint_channels_batt_prot_undervolt_setpoint_get","security":[{"HTTPBasic":[]}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"number","title":"Response 200 Get Batt Prot Undervolt Setpoint Channels Batt Prot Undervolt Setpoint Get"}}}}}},"post":{"tags":["battery-test"],"summary":"Set Batt Prot Undervolt Setpoint","operationId":"set_batt_prot_undervolt_setpoint_channels_batt_prot_undervolt_setpoint_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"value","in":"query","required":true,"schema":{"type":"number","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/channels/batt_prot_triggered":{"get":{"tags":["battery-test"],"summary":"Get Batt Prot Triggered","operationId":"get_batt_prot_triggered_channels_batt_prot_triggered_get","security":[{"HTTPBasic":[]}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"boolean","title":"Response 200 Get Batt Prot Triggered Channels Batt Prot Triggered Get"}}}}}},"post":{"tags":["battery-test"],"summary":"Set Batt Prot Triggered","description":"Clear a battery protection triggered by sending false or manually trigger battery protection by sending true.","operationId":"set_batt_prot_triggered_channels_batt_prot_triggered_post","security":[{"HTTPBasic":[]}],"parameters":[{"name":"value","in":"query","required":true,"schema":{"type":"boolean","title":"Value"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/CICD/openapi-json-ready":{"get":{"tags":["battery-test","CICD"],"summary":"Check Openapi Json Ready","description":"returns status code 200 when openapi json is ready, else status code 503","operationId":"check_openapi_json_ready_CICD_openapi_json_ready_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"string"}}}}}}},"/CICD/version":{"get":{"tags":["battery-test","CICD"],"summary":"Get Api Version","description":"returns str of app.version (ex: \"0.0.3\")","operationId":"get_api_version_CICD_version_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"string","title":"Response 200 Get Api Version Cicd Version Get"}}}}}}}},"components":{"schemas":{"Body_upload_script_script_executor_content_post":{"properties":{"file":{"type":"string","format":"binary","title":"File"}},"type":"object","required":["file"],"title":"Body_upload_script_script_executor_content_post"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ResponseSearch":{"properties":{"display_name":{"type":"string","title":"Display Name"},"node_id":{"type":"string","title":"Node Id"}},"type":"object","required":["display_name","node_id"],"title":"ResponseSearch","example":{"display_name":"n_cycles_completed","node_id":"n=3,b=0x013451"}},"ResponseValue":{"properties":{"display_name":{"type":"string","title":"Display Name"},"node_id":{"type":"string","title":"Node Id"},"value":{"anyOf":[{"type":"number"},{"type":"integer"},{"type":"string"},{"type":"boolean"}],"title":"Value"}},"type":"object","required":["display_name","node_id","value"],"title":"ResponseValue","example":{"display_name":"n_cycles_completed","node_id":"n=3,b=0x013451","value":12.43}},"SingleCommanderLockStateResponseModel":{"properties":{"is_locked":{"type":"boolean","title":"Is Locked"},"username":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Username"},"message":{"type":"string","title":"Message","default":""},"locked_since":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Locked Since"},"timeout":{"type":"string","format":"duration","title":"Timeout","default":"PT0S"}},"type":"object","required":["is_locked"],"title":"SingleCommanderLockStateResponseModel","example":[{"is_locked":true,"locked_since":"2023-11-27T22:20:21.625963","message":"stay away!","timeout":"PT300S","username":"jeff"}]},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"HTTPBasic":{"type":"http","scheme":"basic"}}}}
Generation Details

OK generation

docker run --rm \
  --user $(id -u):$(id -g) \
  -v ./:/local/ \
  openapitools/openapi-generator-cli:v7.5.0 \
  generate \
  -i /local/openapi.json \
  -o /local/python \
  --ignore-file-override /local/.openapi-generator-ignore \
  -c /local/openapi-generator-config.yaml \

BAD generation:

docker run --rm \
  --user $(id -u):$(id -g) \
  -v ./:/local/ \
  openapitools/openapi-generator-cli:latest-release \
  generate \
  -i /local/openapi.json \
  -o /local/python \
  --ignore-file-override /local/.openapi-generator-ignore \
  -c /local/openapi-generator-config.yaml \

my openapi generator config yaml looks like this

generatorName: python
additionalProperties:
  packageVersion: "{version}"
  packageName: "{args.package_name}"
  hideGenerationTimestamp: false
  generateSourceCodeOnly: false
  library: asyncio
  disallowAdditionalPropertiesIfNotPresent: false
Steps to reproduce
Related issues/PRs
Suggest a fix
VonUniGE commented 4 months ago

I've reproduced this issue locally: missing imports with latest and latest-release and no error with version 7.5.0.

james-emerton commented 1 week ago

I'm also seeing this issue in 7.7.0 and 7.9.0 (and I think I also had it with 7.5.0.)

I was generating an async version of the ory-client package and across the whole codebase there was only a single missing import (HealthStatus in metadata_api.py). (I also see the same issue using the urllib3 library flavour.)

It appears to me that this is affecting response types that only need to be imported because they're being used in a type hint.