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.29k stars 6.44k forks source link

[BUG] [Python] Path contains several parameters, only the first parameter is assigned the correct schema #19059

Open ryou90 opened 2 months ago

ryou90 commented 2 months ago

Bug Report Checklist

Description

If path contains several parameters, only the first parameter is assigned the correct schema, the remaining parameters are all assigned the Any type.

If the parameter is an array, this information is lost. In the generated Python client api, the parameters are therefore not declared in the "_collection_formats" variable. Arrays are therefore not serialized properly!

openapi-generator version

Tested with all versions 7.4.0 and higher

OpenAPI declaration file content or url

Excerpt from my the openapi 3.1 json file. Generated by python Litestar Framework

Path /apps. A number of apps should be displayed. Several id filters are available for selection

        "/apps": {
            "get": {
                "tags": [
                    "Apps"
                ],
                "summary": "List apps",
                "description": "Retrieve the apps.",
                "operationId": "list_apps",
                "parameters": [
                    {
                        "name": "ids",
                        "in": "query",
                        "schema": {
                            "oneOf": [
                                {
                                    "type": "null"
                                },
                                {
                                    "items": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "type": "array"
                                }
                            ]
                        },
                        "required": false,
                        "deprecated": false,
                        "allowEmptyValue": false,
                        "allowReserved": false
                    },
                    {
                        "name": "workspace_ids",
                        "in": "query",
                        "schema": {
                            "oneOf": [
                                {
                                    "type": "null"
                                },
                                {
                                    "items": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "type": "array"
                                }
                            ]
                        },
                        "required": false,
                        "deprecated": false,
                        "allowEmptyValue": false,
                        "allowReserved": false
                    },
                    {
                        "name": "category_ids",
                        "in": "query",
                        "schema": {
                            "oneOf": [
                                {
                                    "type": "null"
                                },
                                {
                                    "items": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "type": "array"
                                }
                            ]
                        },
                        "required": false,
                        "deprecated": false,
                        "allowEmptyValue": false,
                        "allowReserved": false
                    },
                    {
                        "name": "publisher_ids",
                        "in": "query",
                        "schema": {
                            "oneOf": [
                                {
                                    "type": "null"
                                },
                                {
                                    "items": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "type": "array"
                                }
                            ]
                        },
                        "required": false,
                        "deprecated": false,
                        "allowEmptyValue": false,
                        "allowReserved": false
                    },
                ],
Generation Details
openapi-generator-cli version-manager set 7.7.0
openapi-generator-cli generate -i "${SPEC_FILE}" \
    -g python \
    -c ./config/client/python.yml.proc.yml \
    --inline-schema-options SKIP_SCHEMA_REUSE=true \

The python.yml.proc.yml file contains:

projectName: Example
packageName: example
packageVersion: 0.1.0
library: asyncio
disallowAdditionalPropertiesIfNotPresent: false

Result: Excerpt:

...
    @validate_call
    async def list_apps(
        self,
        ids: Optional[List[StrictStr]] = None,
        workspace_ids: Optional[Any] = None, # <---------------- !
        category_ids: Optional[Any] = None, # <---------------- !
        publisher_ids: Optional[Any] = None, # <---------------- !
 ) -> ListApps200Response:

...

    def _list_apps_serialize(
        self,
        ids,
        workspace_ids,
        category_ids,
        publisher_ids,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: Dict[str, str] = {
            "ids": "multi",
         # Missing workspace_ids, category_ids and so on  <---------------- !
        }
Steps to reproduce
Related issues/PRs
Suggest a fix
ryou90 commented 3 weeks ago

Any news on this? Issue still exists in current version 7.8.0