Respect doesn't resolve complex constraint pattern
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 228
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 48
Description
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.yamlfile 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.yamlworkflow 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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with openapi.yaml, openapi.arazzo.yaml, and redocly respect openapi.arazzo.yaml. Compare how respect resolves the referenced schemas with how lint registers them using inlineRefs: false, then verify that the allOf-plus-not discriminator schema validates successfully without the Ajv const-or-enum error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, cli, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100