Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest daft version 2020-12 is not supported #158

Open
rajsenthil opened this issue Sep 14, 2023 · 2 comments
Open

Latest daft version 2020-12 is not supported #158

rajsenthil opened this issue Sep 14, 2023 · 2 comments

Comments

@rajsenthil
Copy link

I tried to create the yup schema using the 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", "message": { "required": "Product date is required", "type": "Correct format of Product Date Of Birth is yyyy-mm-ddTHH:MM:SSZ as 2006-01-02T15:04:05Z" } }, "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 validated the json schema here and it works good.
With schema-to-yup, I think it supports until draft-07 because I am getting an error invalid schema: must be type: "object", was type: undefined when trying to build buildYup(data, config) using above json-schema.
It will be helpful if you please confirm, if the draft was the issue or any other probable cause.

@rajsenthil
Copy link
Author

rajsenthil commented Sep 14, 2023

Sorry that I cannot change the above format and pasted below

{
  "$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",
          "message": {
            "required": "Product date is required",
            "type": "Correct format of Product Date Of Birth is yyyy-mm-ddTHH:MM:SSZ as 2006-01-02T15:04:05Z"
          }
        },
        "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"
      ]
    }
  }
}

@kristianmandrup
Copy link
Owner

Yes, it does not support $defs with $ref and $schema. If this is a critical feature for your needs you are welcome to help me implement support for it. I think the easiest workaround for now would be to normalize it to match previous draft expectations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants