swagger-api / swagger-api/swagger-ui

Path item $refs override inline operations instead of merging

Open
#3,664 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P2 type: bug version: 3.x
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 2.0, 3.0.0
Which Swagger-UI version? 3.2.0
How did you install Swagger-UI? http://editor.swagger.io
Which browser & version? Chrome 61
Which operating system? Windows 7
Demonstration API definition

2.0 spec:

swagger: '2.0'
info:
  version: 0.0.0
  title: Path item $ref test

paths:
  /foo:
    get:
      responses:
        200:
          description: OK

  /foo2:
    $ref: '#/paths/~1foo'
    post:
      summary: Create a foo2
      responses:
        201:
          description: Created

3.0 spec:

openapi: 3.0.0
info:
  version: 0.0.0
  title: Path item $ref test

paths:
  /foo:
    get:
      responses:
        '200':
          description: OK

  /foo2:
    $ref: '#/paths/~1foo'
    post:
      summary: Create a foo2
      responses:
        '201':
          description: Created
Expected Behavior

/foo2 displays both GET (added by $ref) and POST (defined inline).

Current Behavior

/foo2 displays GET only.

Context

According to https://github.com/OAI/OpenAPI-Specification/issues/1038#issuecomment-295594246, when a path item contains a $ref, the referenced operation is added (merged) to other operations in this path. Unlike regular JSON references, path item $refs are not supposed to override their sibling elements.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in Swagger UI with the 2.0 and 3.0.0 API definitions shown in the report, focusing on how the /foo2 path item is resolved. Done means /foo2 displays both the referenced GET operation and its inline POST operation instead of only GET.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.