swagger-api / swagger-api/swagger-parser

Bug in PropertyDeserializer when "enum":null

Open
#390 2 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

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.