openapi-contrib / openapi-schema-to-json-schema

Due to the OpenAPI v3.0 and JSON Schema discrepancy, you can use this JS library to convert OpenAPI Schema objects to proper JSON Schema.
https://www.npmjs.com/package/@openapi-contrib/openapi-schema-to-json-schema
MIT License
242 stars 20 forks source link

Duplicate element in enum #34

Closed mjameswh closed 2 years ago

mjameswh commented 2 years ago

If an OpenAPI definition contains an enum property that is 1) nullable and 2) that explicitly contains null in its enum values list, then the converted JSON Schema will have the value null twice in its enum definition, which makes it fail in AJV.

Example input

{
    "type": "object",
    "properties": {
        "lastError": {
            "type": "string",
            "enum": ["referenceError", "configurationError", "unexpectedError", null],
            "nullable": true
        }
    }
}

Current output

    ...
    "enum": ["referenceError", "configurationError", "unexpectedError", null, null],
    ...
github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 3.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: