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

'duplicated mapping key' error occurred, if set same paths with different method (OAS3) #5984

Closed
qzrt opened this issue May 4, 2020 · 5 comments

Comments

@qzrt
Copy link

qzrt commented May 4, 2020

'duplicated mapping key' error occurred, if set same paths with different method (OAS3)

Steps to reproduce the behavior:

  1. Docker Run swagger-ui with yaml file below
  2. Then See errors 'duplicated mapping key'

Q&A

  • OS: OSX High Sierra
  • Browser: Safari
  • Version: 13.1
  • Method of installation: docker run
  • Swagger-UI version: 3.18.3
  • Swagger/OpenAPI version: OpenAPI 3.0

Example Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  description: bug test
  version: "1.0"
  title: sample
tags:
  - name: user
    description: user
paths:
  /user:
    post:
      tags:
        - user
      summary: User Register
      description: ""
      operationId: UserPost
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                password:
                  type: string
        required: true
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
        "400":
          description: エラー
          content:
            application/json:
              schema:
                type: object
                properties:
                    message:
                        type: string
  /user:
    delete:
      tags:
        - user
      summary: User Deletion
      description: ""
      operationId: UserDelete
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
        required: true
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
        "400":
          description: エラー
          content:
            application/json:
              schema:
                type: object
                properties:
                    message:
                        type: string
@hkosova
Copy link
Contributor

hkosova commented May 4, 2020

This is not a valid API definition.

Each path must be listed only once, and all HTTP methods applicable to that path must be listed under that path, as follows:

paths:
  /user:
    post:
      ...
    delete:
       ...

@hkosova hkosova closed this as completed May 4, 2020
@vegassw
Copy link

vegassw commented Jan 19, 2021

Thanks a lot

@KODEASDFX
Copy link

스크린샷 2021-04-28 오전 11 01 07

paths:
/epg-stbservice:
get:
tags:
- WEPG
summary: IF-WEPG-301
parameters:
- name: m
in: query
description: 메서드 명
required: false
schema:
type: string
get:
tags:
- WEPG
summary: IF-WEPG-303 #요약개념 -> 설명
parameters:

There is a problem with duplicate mapping keys Why?

@hkosova
Copy link
Contributor

hkosova commented Apr 28, 2021

@gi-hu-se You can't have two get inside a path (or, in general, multiple instances of the same HTTP method). If you are designing a new API, split this path into two different paths, each with its own get.

Here's a related feature request in the OpenAPI Specification repository:
OAI/OpenAPI-Specification#182

@8ivek
Copy link

8ivek commented May 23, 2021

This is not a valid API definition.

Each path must be listed only once, and all HTTP methods applicable to that path must be listed under that path, as follows:

paths:
  /user:
    post:
      ...
    delete:
       ...

Thanks for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants