Open JaredCE opened 1 year ago
Are you sure it's not indentation / {
[
mismatches (as above in red) which are causing your issues. This project isn't opinionated about type
being present AFAIR.
Hey @MikeRalphson. I don't believe there are any mismatches there, if i copy and paste the first example into runkit.com as:
const a = {
anyOf: [
{ type: 'array', items: { type: 'string' } },
{
type: 'object',
additionalProperties: { enum: [ 'commonjs', 'module' ] }
}
],
default: [ 'cjs', 'mjs', 'js' ]
}
It doesn't complain about mismatching brackets.
I'm seeing a similar issue from a user of my library here: https://github.com/JaredCE/serverless-openapi-documenter/issues/89
Where type is not defined in the object but in the allOf
. Running the as-is schema here https://www.jsonschemavalidator.net/s/EexTxvSB shows it to be valid, but it seems your openAPI validator claims the schema is invalid.
I'm messing about right now, but if i get time later i'll try and put together a small reproducible...
I wonder if it's the presence of default
without a direct sibling type
that is triggering a rule for OAS 3.0 that defaults must be of the right type. What version of the library are you using?
"oas-validator": "^5.0.8",
this is a reproducible, but runkit.com is terrible at outputting the error, so you might want to run it locally:
I've corrected the OpenAPI syntax and confirmed that it is the presence of default
that is triggering the error. In this case you/the OP should move the default
into the anyOf
subschemas.
One thing you could do is set options.laxDefaults
to true
, as per https://github.com/Mermade/oas-kit/blob/main/docs/options.md#options-documentation
Checklist
Detailed Description
I'm trying to understand the opinionated nature of the validator library. It seems like it forces some things on to you like:
will fail because it is missing a
type
field, even though the specs don't seem to suggest it's required. Equally if i try to massage an if/then/else into a valid draft-04 from:to
it will complain that
needs to be in its own schema components reference.
Other stuff