swagger-api / swagger-api/swagger-parser

Confusing log-warning and warning message in result for property named `null`

Open
#1,921 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

The following schema logs a warning message
Error snake-parsing yaml content with an exception: java.lang.IllegalArgumentException: Null key for a Map not allowed in JSON (use a converting NullKeySerializer?) (through reference chain: java.util.LinkedHashMap["components"]->java.util.LinkedHashMap["schemas"]->java.util.LinkedHashMap["User"]->java.util.LinkedHashMap["properties"]->java.util.LinkedHashMap["null"])

with the newest version of the parser (2.1.13). The message for the exception is also returned as part of the messages in the parse-result.

But the returned OpenAPI class is correct, i.e. the parsing itself worked.

openapi: "3.0.0"
info: { }

paths: { }

components:
  schemas:
    User:
      properties:
        null:
          type: string

It seems like, parsing the yml with snake-yml failed, which results in the log-warning and the warning message, but the fallback with jackson worked. I would prefer having no log-warning and no warning message in case the parsing is done successfully. There is nothing one can do as a user to prevent the warning (if the property name should be null) nor is it clear if there is really a problem or not with the parsing.

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

No file or test is named in the issue. Reproduce the supplied OpenAPI YAML with the parser, then inspect the YAML fallback and parse-result warning path; done means a valid parse with a property named null produces neither warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, json, yaml
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.