Skip to content

Nullable in OAS 3.1 rendered as "'null'" string instead of "null" #689

@mjpieters

Description

@mjpieters

Nullable fields should be rendered as "type": ["fieldType", "null"], not ["fieldType", "'null'"].

The field converter currently includes quotes around null in the literal string value, see

attributes["type"] = make_type_list(ret.get("type")) + ["'null'"]

which results in JSON like this:

          "created_at": {
            "type": [
              "string",
              "'null'"
            ],
            "format": "date-time",
            "readOnly": true
          },

or as YAML:

       created_at:
          type:
            - string
            - '''null'''
          format: date-time
          readOnly: true

While the type string should be a string (and not None in Python, null in JSON or YAML), the extra quotes there are an error.

To fix, please drop the extra quotes in the value:

                attributes["type"] = make_type_list(ret.get("type")) + ["null"] 

Also see

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions