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

Two endpoints with same name conflicting data type #541

Closed
danilofuchs opened this issue May 6, 2024 · 1 comment
Closed

Two endpoints with same name conflicting data type #541

danilofuchs opened this issue May 6, 2024 · 1 comment
Labels
bug 🔥 Something isn't working

Comments

@danilofuchs
Copy link

danilofuchs commented May 6, 2024

Description

We have two endpoints with the same name:
changeUserPassword (user facing) and changeUserPassword (management only, different payload), the generated API only has one ChangeUserPasswordData without an id parameter:

export type ChangeUserPasswordData = {
  requestBody: {
    current_password: string;
    new_password: string;
  };
};

#538 should have fixed this

@hey-api/openapi-ts 0.43.2

OpenAPI specification (optional)

The management endpoint has an id parameter

    "/users/change-password": {
      "post": {
        "operationId": "changeUserPassword",
        "tags": [
          "App"
        ],
        "description": "Changes a user's password.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "current_password": {
                    "type": "string"
                  },
                  "new_password": {
                    "type": "string"
                  }
                },
                "required": [
                  "current_password",
                  "new_password"
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "deprecated": false,
        "parameters": []
      }
    },
    
    "/management/users/{id}/change-password": {
      "post": {
        "operationId": "changeUserPassword",
        "tags": [
          "Management App Users"
        ],
        "description": "Change user password",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "current_password": {
                    "type": "string"
                  },
                  "new_password": {
                    "type": "string"
                  }
                },
                "required": [
                  "current_password",
                  "new_password"
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "deprecated": false,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },

Configuration

openapi-ts -i https://test.com/openapi.json -o src/server/test-api --name TestApi --client fetch --format prettier

System information (optional)

No response

@danilofuchs danilofuchs added the bug 🔥 Something isn't working label May 6, 2024
@danilofuchs danilofuchs changed the title Two type definitions with the same name Two endpoints with same name conflicting data type May 6, 2024
@mrlubos
Copy link
Member

mrlubos commented May 6, 2024

@danilofuchs this is because of the duplicate operationId in your OpenAPI specification. From Swagger docs

operationId is an optional unique string used to identify an operation. If provided, these IDs must be unique among all operations described in your API

Assuming you have control over your spec, this should be fixed on the API side

@mrlubos mrlubos closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants