json-schema-org / json-schema-org/website

🐛 Bug: getScopesOfParsedJsonSchema ignores $ref, oneOf, anyOf, allOf, definitions — incomplete scope generation

Open
#1,971 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🐛 Bug Status: Triage
Dominant language
HTML
Stars
169
Forks
484
Avg merge
2d 2h
Merged PRs (30d)
6

Description

Describe the bug

The utility getScopesOfParsedJsonSchema.ts currently handles only shallow
properties and does not support many core JSON Schema constructs.

Affected file

website/lib/getScopesOfParsedJsonSchema.ts

Problem

The function does not recursively walk or merge scopes for:

  • $ref
  • oneOf / anyOf / allOf
  • definitions / $defs
  • nested items[]
  • patternProperties
  • additionalProperties

As a result, valid JSON Schemas produce incomplete scopes, which affects tools
relying on this output.

Example schema that breaks
Steps To Reproduce
How to reproduce
  1. Use the following schema:

{
"type": "object",
"properties": {
"name": { "type": "string" },
"details": {
"oneOf": [
{
"type": "object",
"properties": {
"age": { "type": "number" }
}
},
{
"$ref": "#/definitions/extraInfo"
}
]
}
},
"definitions": {
"extraInfo": {
"type": "object",
"properties": {
"hobby": { "type": "string" }
}
}
}
}

  1. Call the function:
    getScopesOfParsedJsonSchema(parsedSchema)
Actual Output

[
{ jsonPath: "$", scope: "type-definition" },
{ jsonPath: "$['properties']['name']", scope: "type-definition" }
]

Expected Output

Should also include scopes inside:

  • oneOf
  • $ref (resolved via definitions)
    So expected scopes include:
  • details.age
  • details.hobby
Expected Behavior

Expected:
Scopes should include name, details.age, details.hobby.

Actual:
Only name is returned.

Suggested improvement

Add recursive handling for combinators and reference resolution:

if (schema.oneOf) { /* ... */ }
if (schema.allOf) { /* ... */ }
if (schema.$ref) { /* ... */ }

### Screenshots

_No response_

### Device Information [optional]

```markdown
- OS:
- Browser:
- version:
Are you working on this issue?

Yes

Do you think this work might require an [Architectural Decision Record (ADR)]? (significant or noteworthy)

Yes

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 in website/lib/getScopesOfParsedJsonSchema.ts at getScopesOfParsedJsonSchema and reproduce the supplied schema containing oneOf, $ref, and definitions. Trace how scopes are generated for shallow properties, then define coverage for the listed schema constructs. Done means the output includes name, details.age, and details.hobby, along with the other requested constructs.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.