swagger-api / swagger-api/swagger-parser
[suggestion] - Add defaults for easier transition from old parser to new one
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Hi,
I'm in the process of updating a tool that was using the old swagger parser (master) to use the new one (2.0). As expected, I had to make a lot of changes to use new classes that replaced old ones. Something I noticed that could have made this transition easier was if the following methods would return some values by default instead of null (thus triggering NPE)
Operation#getParameters() could return an empty list when nothing was defined. Seems like old parser used to do that.
RequestBody#getRequired() could return false when nothing was defined. Seems like it used to behave like that.
Those 2 things would have avoided some changes to the code. I will update this issue if I run into more things as I make progress in the migration.
Thanks,
Gaston
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 locating Operation#getParameters() and RequestBody#getRequired() in the Java parser model. Check how each behaves when the corresponding value is absent, then inspect the existing tests for these model classes. Done means both methods return the requested defaults without breaking the parser's handling of explicitly provided values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100