swagger-api / swagger-api/swagger-parser
Bug in PropertyDeserializer when "enum":null
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Hi,
I was parsing a swagger file, and the parse is crashing. By debugging it, I ended up in the class PropertyDeserializer where there is the code
private static List<String> getEnum(JsonNode node, PropertyBuilder.PropertyId type) {
final List<String> result = new ArrayList<String>();
JsonNode detailNode = getDetailNode(node, type);
if (detailNode != null) {
ArrayNode an = (ArrayNode) detailNode;
this does crash when you have a node with {"enum":null} as the branch is taken (NullNode) in that if statement. A quick fix should be just adding something like "&& detailNode instanceof ArrayNode"
Note: I originally reported this issue at https://github.com/swagger-api/swagger-core/issues/2100#issuecomment-275878181 but was told to open it here
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 in PropertyDeserializer.getEnum, where a swagger node with "enum":null reaches the ArrayNode cast. Reproduce parsing with that input and verify that the parser completes without crashing; add regression coverage if the surrounding project structure provides an appropriate test location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100