swagger-api / swagger-api/swagger-parser

swagger-parser-v2-converter converts overridden parameter incorrectly

Open
#1,281 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

In OpenAPI v2, parameters can be defined in an operation and at the path item level. The precedence rule is stated in OpenAPI v2: "If a parameter is already defined at the Path Item, the new definition will override it, but can never remove it." That is, a definition at the operation level hides the corresponding definition at the path item level.

The swagger-parser-v2-converter, during conversion to v3, implements it the other way around.

How to reproduce:

  1. Store this file as v2.yaml.

v2.yaml.gz

  1. Store this file as ConvertOpenAPIV2ToV3.java.

ConvertOpenAPIV2ToV3.java.gz

Compile it with a classpath that contains
slf4j-api-1.5.8.jar
slf4j-jdk14-1.5.8.jar
jackson-core-2.9.9.jar
jackson-dataformat-yaml-2.9.9.jar
jackson-databind-2.9.9.jar
jackson-annotations-2.9.9.jar
commons-io-1.4.jar
commons-lang3-3.1.jar
swagger-models-2.0.8.jar
swagger-parser-v3-2.0.12.jar
swagger-core-2.0.8.jar
swagger-parser-core-2.0.12.jar
swagger-parser-v2-converter-2.0.12.jar
swagger-parser-1.0.44.jar
swagger-core-1.5.22.jar
swagger-models-1.5.22.jar
snakeyaml.jar

  1. Run it with two arguments, namely the absolute file name from step 1 and the absolute file name of the destination file.

  2. The output I got is:

v3.yaml.gz

As you can see, it has produced a parameter with type: string, where it should have produced a parameter with type: integer.

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 with the swagger-parser-v2-converter entry point and reproduce the conversion using the attached v2.yaml and ConvertOpenAPIV2ToV3.java files. Compare the generated v3.yaml with the expected operation-level override, then verify that the overridden parameter retains type: integer rather than type: string.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.