Redocly / Redocly/redocly-cli

Support deep traversal of schema in nested visitors

Open
#362 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p3 Type: Enhancement
Dominant language
TypeScript
Stars
1.5k
Forks
228
Avg merge
1d 14h
Merged PRs (30d)
48

Description

Is your feature request related to a problem? Please describe.
When you define a rule using nested visitor, for example, Response: { Schema: ... }, per documentaion:

It will be executed only for the first level of Schema Object.

Thus, if you want to check schema's properties and sub-properties, you have to do deep traversal manually.

Describe the solution you'd like
As I understand it, the main advantage of nested visitors is scoping. For example, when you want to lint schema properties only in response or request bodies, but not in parameters. Doing deep traversal manually isn't worth it, because there might be refs, allOf/oneOf/anyOf.
In comparison, when using Schema without nesting, the rule is checked against each individual property. It would be great to have the same behaviour in nested visitors too.

Describe alternatives you've considered
Currently we use non-nested Schema visitor. We tried two approaches to detect that schema comes from parameters:

  • parent check: ctx.parent?.in → too naive and prone to false positives and negatives
  • pointer check: /\/parameters\/\d+(?:(?:\/)|(?:\/.+\/))schema/.test(ctx.location.absolutePointer) → doesn't work with refs

In the end, right now we simply use ignore file.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the nested visitor and Schema visitor handling described in the issue, including how refs and allOf/oneOf/anyOf are traversed. Done means a nested Schema visitor reaches nested properties while remaining scoped to its request or response context, without requiring manual traversal.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.