-
Notifications
You must be signed in to change notification settings - Fork 9.2k
fix: ignore rendering responses with extensions in the schema #10592
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
fix: ignore rendering responses with extensions in the schema #10592
Conversation
src/core/components/responses.jsx
Outdated
<tbody> | ||
{ | ||
responses.entrySeq().map( ([code, response]) => { | ||
responses.filter((_, key) => !key.startsWith("x-")).entrySeq().map( ([code, response]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we rewrite and reuse logic from core/utils
to filter extensions?
const extensionRegExp = /^x-/
export const isExtension = (key) => extensionRegExp.test(key)
export const getExtensions = (defObj) => {
if(Map.isMap(defObj)) {
return defObj.filter((v, k) => isExtension(k))
}
return Object.keys(defObj).filter((key) => isExtension(key))
}
responses.filter((_, key) => !key.startsWith("x-")).entrySeq().map( ([code, response]) => { | |
responses.filter((_, key) => !isExtension(key)).entrySeq().map( ([code, response]) => { |
hey @DarkMatter-999 could we address an issue where we don't have any responses besides extension? Currently we display an empty table but no table should be displayed in such case openapi: 3.1.0
paths:
/hello:
get:
responses:
x-tenant: acme
info:
title: prout-quarkus API
version: 1.0-SNAPSHOT |
Hi @robert-hebel-sb, thanks for the review. |
## [5.29.4](v5.29.3...v5.29.4) (2025-10-10) ### Bug Fixes * **core:** refactor UNSAFE_ lifecycle methods in ContentType and OperationContainer ([#10373](#10373)) ([2814709](2814709)), closes [#10212](#10212) * ignore rendering responses with extensions in the schema ([#10592](#10592)) ([23e3e00](23e3e00)) * include script in body ([#10593](#10593)) ([456274c](456274c)) * update vulnerable libxml2 to 2.13.9-r0 ([#10600](#10600)) ([8138154](8138154)) * use h1 for title heading to improve accessibility ([#10598](#10598)) ([c0bd7b6](c0bd7b6)), closes [#10480](#10480)
🎉 This PR is included in version 5.29.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This PR fixes a rendering bug in the Responses when using custom OpenAPI extensions (
x-*
) inside the responses object.Motivation and Context
fixes #10561
Swagger UI previously attempted to render all entries in the responses object, including custom extensions like
x-tenant
as actual HTTP responses.How Has This Been Tested?
Manually tested with an OpenAPI 3.1.0 spec containing
x-tenant
under responsesVerified that the Responses section renders correctly and without errors
Confirmed that valid responses (200, 500, etc.) still display as expected
Ran relevant tests, no regressions observed.
Environment:
OS: Linux
Browser: Chromium 139
Swagger UI:
master
BranchSchema used for testing:
Screenshots (if appropriate):
Before:
After:
Checklist
My PR contains...
My changes...
Documentation
Automated tests