Coder Social home page Coder Social logo

Comments (12)

RicoSuter avatar RicoSuter commented on August 14, 2024

Can you provide a sample schema and sample data?

from njsonschema.

dyetube avatar dyetube commented on August 14, 2024

You want me to include the models? I don't have the actual Schema, I use var schema = JsonSchema4.FromType<ReportItem>(); and var schemaData = schema.ToJson(); to build the schema from my models and then var errors = schema.Validate(JSend.JsonString); to get the errors.

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

Can you post the schemaData and JSend.JsonString content here (or is it confidential)?

from njsonschema.

dyetube avatar dyetube commented on August 14, 2024

here ya go:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "typeName": "ReportItem",
  "additionalProperties": false,
  "required": [
    "ReportID",
    "RequiresFilter",
    "MimeType",
    "ExternalID",
    "CreatedBy",
    "ExecutionScript",
    "ExecutionParameter",
    "Columns"
  ],
  "properties": {
    "ReportID": {
      "type": "string",
      "format": "guid"
    },
    "RequiresFilter": {
      "type": "boolean"
    },
    "MimeType": {
      "type": "string"
    },
    "ExternalID": {
      "type": "string"
    },
    "CreatedBy": {
      "type": "string",
      "format": "date-time"
    },
    "ExecutionScript": {
      "type": "string"
    },
    "ExecutionParameter": {
      "type": "string"
    },
    "ExecutionOrderBy": {
      "type": [
        "null",
        "string"
      ]
    },
    "DynamicFilters": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "object",
        "typeName": "DynamicFilter",
        "additionalProperties": false,
        "required": [
          "ID",
          "Script",
          "ScriptOrderBy",
          "Fields",
          "ScriptParams"
        ],
        "properties": {
          "ID": {
            "type": "string"
          },
          "Script": {
            "type": "string"
          },
          "ScriptOrderBy": {
            "type": "string"
          },
          "Fields": {
            "type": "string"
          },
          "ScriptParams": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "array",
                "boolean",
                "integer",
                "null",
                "number",
                "object",
                "string"
              ]
            }
          }
        }
      }
    },
    "RequiresOrgID": {
      "type": "boolean"
    },
    "ReportFilter": {
      "oneOf": [
        {
          "$ref": "#/definitions/QueryFilter"
        },
        {
          "type": "null"
        }
      ]
    },
    "ReportRules": {
      "oneOf": [
        {
          "$ref": "#/definitions/QueryRule"
        },
        {
          "type": "null"
        }
      ]
    },
    "Columns": {
      "type": "array",
      "items": {
        "type": "object",
        "typeName": "QueryColumn",
        "additionalProperties": false,
        "required": [
          "isrequired",
          "column_name"
        ],
        "properties": {
          "isrequired": {
            "type": "boolean"
          },
          "column_name": {
            "type": "string"
          }
        }
      }
    }
  },
  "definitions": {
    "QueryFilter": {
      "type": "object",
      "typeName": "QueryFilter",
      "additionalProperties": false,
      "required": [
        "display_errors",
        "allow_empty",
        "plugins",
        "filters"
      ],
      "properties": {
        "display_errors": {
          "type": "boolean"
        },
        "allow_empty": {
          "type": "boolean"
        },
        "plugins": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "filters": {
          "type": "array",
          "items": {
            "type": "object",
            "typeName": "Filter",
            "additionalProperties": false,
            "required": [
              "id",
              "label",
              "type",
              "operators"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "operators": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "input": {
                "type": [
                  "null",
                  "string"
                ]
              },
              "values": {
                "type": [
                  "null",
                  "object"
                ],
                "additionalProperties": {
                  "type": [
                    "array",
                    "boolean",
                    "integer",
                    "null",
                    "number",
                    "object",
                    "string"
                  ]
                }
              },
              "validation": {
                "oneOf": [
                  {
                    "$ref": "#/definitions/Validation"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "unique": {
                "type": "boolean"
              },
              "description": {
                "type": [
                  "null",
                  "string"
                ]
              }
            }
          }
        }
      }
    },
    "QueryRule": {
      "type": "object",
      "typeName": "QueryRule",
      "additionalProperties": false,
      "properties": {
        "condition": {
          "type": [
            "null",
            "string"
          ]
        },
        "rules": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object",
            "typeName": "Rule",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": [
                  "null",
                  "string"
                ]
              },
              "operator": {
                "type": [
                  "null",
                  "string"
                ]
              },
              "value": {
                "type": [
                  "null",
                  "object"
                ]
              },
              "readonly": {
                "type": "boolean"
              },
              "condition": {
                "type": [
                  "null",
                  "string"
                ]
              }
            }
          }
        }
      }
    },
    "Validation": {
      "type": "object",
      "typeName": "Validation",
      "additionalProperties": false,
      "properties": {
        "min": {
          "type": "integer"
        },
        "step": {
          "type": "number",
          "format": "double"
        }
      }
    }
  }
}

from njsonschema.

dyetube avatar dyetube commented on August 14, 2024

If I use something simple like {"Key": "Value"} as the json to compare this schema against, that's when I get the error. I'm doing a workaround, but would rather have this work properly if possible.

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

Ok, ill check this asap

from njsonschema.

dyetube avatar dyetube commented on August 14, 2024

Sweet. Thanks again!

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

The validation is correct, the error is not a property but an object error and the path is null because it applies to the root object. I added a unit test for your case and appended # to the error Path. This way all paths start with # (= root) and this error on the root object has # in the Path property...

efd8a8d

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

Do you expect something else?

from njsonschema.

dyetube avatar dyetube commented on August 14, 2024

Wasn't thinking about the fact that it's an object and therefore has no path. What I am doing actually works just fine. Thanks for the help.

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

In the next version, each path will start with # (same as in a JSON ref) it will never be null.. Is this a problem for you?

from njsonschema.

dyetube avatar dyetube commented on August 14, 2024

This shouldn't be a problem. I'm iterating through the errors and adding them to an array using an Results.Add(new JsonReportErrors { ErrorKind = error.Kind.ToString(), ErrorPath = error.Path.ToString() }); statement and that was erroring out because of the null. Now that it will have a # and not be null, I'll be good.

from njsonschema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.