Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 of 6 tasks
ryou90 opened this issue Jul 3, 2024 · 0 comments

Comments

@ryou90
Copy link

ryou90 commented Jul 3, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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

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 ryou90 changed the title [BUG] Description [BUG] [Python] Path contains several parameters, only the first parameter is assigned the correct schema Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant