Skip to content

fix(oas31): resolve schema refs regardless of expand depth#10806

Open
maruthang wants to merge 1 commit intoswagger-api:masterfrom
maruthang:fix/issue-10336-discriminator-allof-refs
Open

fix(oas31): resolve schema refs regardless of expand depth#10806
maruthang wants to merge 1 commit intoswagger-api:masterfrom
maruthang:fix/issue-10336-discriminator-allof-refs

Conversation

@maruthang
Copy link
Copy Markdown

Description

Simplify the schema resolution condition in the OAS 3.1 Models component to trigger resolution whenever the Models section is open and schemas haven't been resolved yet, regardless of defaultModelsExpandDepth.

Previously, the useEffect only requested resolution of ["components", "schemas"] when defaultModelsExpandDepth > 1 OR when at least one schema was individually expanded in the layout state. With the default depth of 1, $ref values in allOf (used with discriminator patterns) were never resolved, causing "could not resolve reference" errors.

Motivation and Context

Fixes #10336

The defaultModelsExpandDepth config should control UI expansion depth, not whether schema references get resolved. Schemas need to be resolved to render correctly regardless of expansion depth.

How Has This Been Tested?

  • Added 5 regression tests covering:
    • Resolution requested with defaultModelsExpandDepth=1 (the bug scenario)
    • Resolution NOT requested when already resolved
    • Resolution NOT requested when the section is closed
    • Resolution for the exact discriminator+allOf pattern from the issue
    • All schema entries are rendered
  • All 834 unit tests pass

Screenshots (if appropriate):

N/A

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

The Models section useEffect only triggered schema resolution when
defaultModelsExpandDepth > 1 or a schema was individually expanded.
With the default depth of 1, discriminator + allOf $ref values were
never resolved. Simplify the condition to resolve whenever the
section is open and schemas are not yet resolved.

Fixes swagger-api#10336
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to resolve references in schema

1 participant