Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(core): SpecFilter follows ApiResponse $ref to avoid pruning referenced schemas #4977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kuntal1461 wants to merge 5 commits into swagger-api:master
base: master
Choose a base branch
Loading
from kuntal1461:master

Conversation

@kuntal1461
Copy link
Contributor

@kuntal1461 kuntal1461 commented Sep 28, 2025

Fixes #4960

Pull Request

Thank you for contributing to swagger-core!


Description

Bug fix: SpecFilter.removeBrokenReferenceDefinitions did not follow ApiResponse.$ref, so schemas reachable only through #/components/responses/* were considered unreferenced and pruned.
This PR teaches the pruning pass to resolve ApiResponse.$ref and traverse the resolved response's headers and content to collect schema refs, ensuring those schemas are retained.

What changed (minimal patch):

  • In addApiResponseSchemaRef(...), add a $ref branch:
    • Resolve simple name via RefUtils.extractSimpleName(ref).getLeft()
    • Mark the referenced ApiResponse component as used
    • Traverse resolved headers and content to collect schema refs
  • No signature changes to existing helper methods; no behavioral changes outside pruning.

Fixes: #4960

Type of Change

  • 🐛 Bug fix

Checklist

  • The PR title is descriptive
  • The code builds and passes tests locally (mvn clean install)
  • I have added/updated tests as needed (see Test Plan below)
  • I have added/updated documentation where applicable
  • I have linked related issues (if any)

Test Plan

Manual verification:

  1. Define an operation with:
    @ApiResponse(responseCode = "404", ref = "#/components/responses/MyCustomSchema")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug]: SpecFilter skips the ApiResponse#$ref field

1 participant

AltStyle によって変換されたページ (->オリジナル) /