tdegrunt / jsonschema

JSON Schema validation
Other
1.83k stars 263 forks source link

Typescript types do not allow using draft 7 as a schema #401

Open PythonCoderAS opened 3 months ago

PythonCoderAS commented 3 months ago

Trying to use this to validate autogenerated JSON Schemas, and getting an error. So I have the Draft 7 schema inside of an object, and trying to use it as the `schema parameter results in the following error:

Argument of type '{ $schema: string; $id: string; title: string; definitions: { schemaArray: { type: string; minItems: number; items: { $ref: string; }; }; nonNegativeInteger: { type: string; minimum: number; }; nonNegativeIntegerDefault0: { ...; }; simpleTypes: { ...; }; stringArray: { ...; }; }; type: string[]; properties: { ...; }...' is not assignable to parameter of type 'Schema'.
  Types of property 'properties' are incompatible.
    Type '{ $id: { type: string; format: string; }; $schema: { type: string; format: string; }; $ref: { type: string; format: string; }; $comment: { type: string; }; title: { type: string; }; description: { type: string; }; ... 39 more ...; not: { ...; }; }' is not assignable to type '{ [name: string]: Schema; }'.
      Property '"default"' is incompatible with index signature.
        Type 'boolean' has no properties in common with type 'Schema'