Skip to content

Conversation

kuntal1461
Copy link

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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