apideck-libraries / better-ajv-errors

Human-friendly JSON Schema validation for APIs 👮‍♀️
MIT License
41 stars 6 forks source link

Accept Ajv's `JSONSchemaType` as the schema option #24

Open voxpelli opened 1 year ago

voxpelli commented 1 year ago

As noted by eg. the team behind workbox, currently it's not supported to use a schema that's typed with Ajv's JSONSchemaType when sending in a schema to this module.

Since it does work in practice, would it be possible to set a more liberal type definition for the schema arg, so that the JSONSchemaType can be accepted as well?

elsmr commented 1 year ago

Hi @voxpelli thanks for reporting, I wasn't aware of that type. I'll have a look in the coming days!

voxpelli commented 1 year ago

@elsmr Did you get a chance to look at this?

mike-lischke commented 9 months ago

Additionally, schemas created with "ts-json-schema-generator" are considered not being compatible, even though it works well. The error is:

 Property '"IConfiguration"' is incompatible with index signature.
        Type '{ additionalProperties: boolean; description: string; properties: { lexer: { $ref: string; description: string; }; main: { $ref: string; description: string; }; }; required: string[]; type: string; }' is not assignable to type 'JSONSchema6Definition'.
          Type '{ additionalProperties: boolean; description: string; properties: { lexer: { $ref: string; description: string; }; main: { $ref: string; description: string; }; }; required: string[]; type: string; }' is not assignable to type 'JSONSchema6'.
            Types of property 'type' are incompatible.
              Type 'string' is not assignable to type 'JSONSchema6TypeName | JSONSchema6TypeName[] | undefined'.