swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
778 stars 525 forks source link

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

Open muehmar opened 1 year ago

muehmar commented 1 year ago

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.