swagger-api / swagger-api/swagger-parser
swagger-parser-v2-converter converts default value for array incorrectly
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
For a schema of type array, the default value must be an array (obviously), not a string.
For input that has a default value of type array (correct), the swagger-parser-v2-converter produces an OpenAPI v3 file that has a default value of type string (wrong).
How to reproduce:
- Store this file as v2.yaml.
- Store this file as ConvertOpenAPIV2ToV3.java.
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
-
Run it with two arguments, namely the absolute file name from step 1 and the absolute file name of the destination file.
-
The output I got is:
As you can see, it has
default: '["registration"]'
Instead it should have
default: ["registration"]
or, equivalently,
default:
- registration
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied v2.yaml through ConvertOpenAPIV2ToV3.java and inspect the swagger-parser-v2-converter handling of schema default values. Confirm the generated v3.yaml preserves an array default as an array rather than serializing it as a 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
- 45/100