Skip to content

Draft **2020-12**: Error while parsing the schema  #164

@rajsenthil

Description

@rajsenthil

I have this below json schema drafted with version 2020-12. I tested online here and also using this golang package. The schema is successfully parsed and could validate the json.
Using schemasafe I am getting error Error: Unexpected keywords mixed with const or enum: ["maxLength","minLength"] at #/properties/productType

Can you please check and see if there is any fix for this?

Jsonschema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$ref": "#/$defs/Product",
  "$defs": {
    "Product": {
      "properties": {
        "id": {
          "type": "integer"
        },
        "productType": {
          "type": "string",
          "enum": [
            "Simple",
            "Configurable",
            "Grouped",
            "Virtual",
            "Bundle"
          ],
          "maxLength": 20,
          "minLength": 1,
          "title": "product type",
          "description": "product type",
          "default": "Simple",
          "examples": [
            "Bundle",
            "Configurable"
          ]
        },
        "product_date": {
          "type": "string",
          "format": "date-time",
          "description": "Product date must be valid"
        },
        "productPrice": {
          "$ref": "#/$defs/ProductPrice"
        },
        "tags": {
          "type": "object",
          "a": "b",
          "foo": [
            "bar",
            "bar1"
          ]
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id",
        "productType",
        "product_date",
        "productPrice"
      ]
    },
    "ProductPrice": {
      "properties": {
        "regularPrice": {
          "type": "number"
        },
        "markedPrice": {
          "type": "number"
        },
        "discount": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "regularPrice",
        "markedPrice"
      ]
    }
  }
}

I am getting error while parsing this jsonschema
Error: Unexpected keywords mixed with const or enum: ["maxLength","minLength"] at #/properties/productType

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