swagger-api / swagger-api/swagger-ui

Extensions not being ignored properly by editor

Open
#3,757 3 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

As you will see with the provided evil, but valid swagger, there a number of things done incorrectly due to extensions not being properly ignored and being parsed as things like paths or responses.
editor.swagger.io parses and validates the swagger, but shows things like "x-an-extension-fake-path" as paths rather than ignoring them as they are extensions.
editor2.swagger.io fails to even parse the swagger document as it tries to read extensions as a variety of different object types instead of ignoring them
(for example the following error seems to be due to trying to read path.consumes from an extension which is null or a primative.

✖ Unknown Error
Cannot read property 'consumes' of undefined
Q A
Bug or feature request? bug
Which Swagger/OpenAPI version? 2.0
Which Swagger-Editor version? editor.swagger.io and editor2.swagger.io as of 13/10/2017
Which browser & version? chrome 61
Which operating system? windows 10
Demonstration API definition

https://gist.github.com/alasdairhurst/a1073a85d3df4bc800e143a4d31dd168

Expected Behavior

Swagger document is parsed correctly. Extensions are not displayed as paths, responses or any other type of object.

Current Behavior

extensions are not ignored by whatever is parsing the swagger, and the UI displays extensions as paths.

Possible Solution

Extensions should be ignored in every location that they are allowed. They should not be parsed as, or show up as parameters, paths, responses and any other types of object.
The provided swagger document should parse correctly and not display and extensions. It should also display all parameters and paths as expected.

Context

Tried to make a swagger for my own project which would allow project developers to find issues with the way swagger is handled. Instead, found issues with the official tools.

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 loading the linked demonstration API definition in editor.swagger.io and editor2.swagger.io, then compare how extension keys are treated as paths, responses, or other objects. Done means the Swagger 2.0 document parses correctly, extensions are ignored in every allowed location, and valid paths and parameters display without extension entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.