openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

Path parameter and query parameter with same name results in duplicate property

Open michael-pxr opened this issue 2 years ago • 2 comments

Describe the bug I have an OAS where an endpoint has a path parameter and a query parameter with the same name:

    "/some/endpoint/with/event/{eventId}": {
      "get": {
        ...
        "operationId": "getCategoryGroupEventUsingGET",
        "parameters": [
          ...
          {
            "name": "eventId",
            "in": "path",
            "description": "event Id",
            "required": true,
            "type": "string"
          },
          ...
          {
            "name": "eventId",
            "in": "query",
            "required": false,
            "type": "string"
          },
          ...

This produces a method that takes as argument an object with duplicate properties:

    public getCategoryGroupEventUsingGet({
        ...
        eventId,
        ...
        eventId,
        ...
    }: {
        ...
        /**
         * event Id
         */
        eventId: string,
        ...
        eventId?: string,
        ...
    }): CancelablePromise<BetOfferResponse> {

This produces the error the name `eventId` is bound more than once in this parameter list.

How should I deal with an OAS that contains an endpoint with a path parameter and query parameter with the same name?

This OAS is maintained by a third party. So ideally I would not like to make any changes to the OAS.

michael-pxr avatar Oct 25 '23 12:10 michael-pxr

I'll look at this @michael-pxr

mrlubos avatar Mar 15 '24 13:03 mrlubos

@michael-pxr this is fixed in @nicolas-chaulet/openapi-typescript-codegen! 🎉

mrlubos avatar Mar 16 '24 04:03 mrlubos