Skip to content

fix(operation): recognize wildcard HTTP status codes as documented responses#10833

Open
yogeshwaran-c wants to merge 1 commit intoswagger-api:masterfrom
yogeshwaran-c:fix/undocumented-response-wildcard-status-codes
Open

fix(operation): recognize wildcard HTTP status codes as documented responses#10833
yogeshwaran-c wants to merge 1 commit intoswagger-api:masterfrom
yogeshwaran-c:fix/undocumented-response-wildcard-status-codes

Conversation

@yogeshwaran-c
Copy link
Copy Markdown

Description

When an OpenAPI spec defines responses using HTTP status code ranges like 4XX or 5XX, individual status codes within that range (e.g., 401, 404, 500) were being incorrectly marked as "Undocumented" in the live response section.

The existing check in operation.jsx only matched exact status code strings (e.g., "401") and the "default" key. This change adds a fallback check for range patterns (1XX, 2XX, 3XX, 4XX, 5XX) as defined in the OpenAPI specification.

Motivation and Context

Fixes #6175

The OpenAPI specification supports HTTP status code ranges using patterns like 4XX (see describing-responses). When a server returns a 401 response and the spec defines 4XX, the response should be recognized as documented.

How Has This Been Tested?

  • Verified the logic correctly computes the range pattern (e.g., "401" -> "4XX")
  • Tested edge cases: exact match takes precedence, range match used as fallback, and "default" still works as final fallback
  • Status codes that don't match any pattern are still correctly marked as undocumented

Screenshots (if appropriate):

N/A - logic change only

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.

…sponses

When a response like 4XX is defined in the spec, individual status codes
within that range (e.g. 401, 404) should not be marked as "Undocumented".
The existing check only matched exact status code strings and "default".
This adds a fallback check for range patterns (1XX, 2XX, 3XX, 4XX, 5XX)
per the OpenAPI specification.

Fixes swagger-api#6175
@yogeshwaran-c yogeshwaran-c force-pushed the fix/undocumented-response-wildcard-status-codes branch from d6f9d70 to 2c32c5f Compare April 20, 2026 08:57
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.

Undocument response with 4XX responses

1 participant