Describe the bug
AJV validation error when using a discriminator with a schema property that uses allOf + not pattern instead of explicit enum values. The discriminator expects the mapped schema's discriminator property to have const or enum, but the AlternativeInstrument schema uses a more complex constraint pattern.
‼️ Error: Ajv error: discriminator: "properties/method" must have "const" or "enum"
To Reproduce
- Given the
openapi.yaml file with the AlternativeInstrument schema that uses allOf + not:
AlternativeInstrument:
properties:
method:
allOf:
- $ref: '#/components/schemas/AlternativePaymentMethods'
- not:
enum:
- payment-card
- paypal
- ach
- And the
openapi.arazzo.yaml workflow file
- Run:
redocly respect openapi.arazzo.yaml
- See the error:
Ajv error: discriminator: "properties/method" must have "const" or "enum"
Expected behavior
The schema should br validated successfully.
Logs
Workflow name: test-cash-payment
stepId - create-cash-instrument
✗ schema check
Ajv error: discriminator: "properties/method" must have "const" or "enum"
OpenAPI description
Redocly version(s)
2.20.4
Node.js version(s)
v24
OS, environment
macOs
Additional context
If we use directly enum without allOf + not pattern everything works as expected.
⚠️ We found, that the issue comes from different $ref resolving between respect and lint commands. Because respect $ref is dereferenced, but lint is not.
Lint registers schemas via addSchema/loadSchemaSync with inlineRefs: false.
Respect receives a fully dereferenced schema (refs already resolved inline).
complex-schema-repro.zip
Describe the bug
AJV validation error when using a discriminator with a schema property that uses allOf + not pattern instead of explicit enum values. The discriminator expects the mapped schema's discriminator property to have const or enum, but the AlternativeInstrument schema uses a more complex constraint pattern.
To Reproduce
openapi.yamlfile with the AlternativeInstrument schema that uses allOf + not:openapi.arazzo.yamlworkflow fileredocly respect openapi.arazzo.yamlAjv error: discriminator: "properties/method" must have "const" or "enum"Expected behavior
The schema should br validated successfully.
Logs
OpenAPI description
Redocly version(s)
2.20.4
Node.js version(s)
v24
OS, environment
macOs
Additional context
⚠️ We found, that the issue comes from different
If we use directly enum without
allOf+notpattern everything works as expected.$refresolving betweenrespectandlintcommands. Because respect $ref is dereferenced, but lint is not.Lint registers schemas via addSchema/loadSchemaSync with inlineRefs: false.
Respect receives a fully dereferenced schema (refs already resolved inline).
complex-schema-repro.zip