-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Description
Q&A (please complete the following information)
- OS: macOS
- Browser: Chrome
- Version: 90.0.4430.93
- Method of installation: npm
- Swagger-UI version: [e.g. 3.47.1]
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Swagger/OpenAPI definition is not relevant for this issue bug here is a sample:
openapi: "3.0.1"
paths:
/my-endpoint:
get:
operationId: getMyAwesomeEndpoint
responses:
"200":
description: "Successful operation"Swagger-UI configuration options:
import SwaggerUI from 'swagger-ui'
SwaggerUI({
spec: spec,
deepLinking: true,
dom_id: '#swagger',
plugins: [
{
wrapComponents: {
info: (Original, { React, getComponents }) => (props) => {
return React.createElement("div", null, [
React.createElement("h3", {key: 1}, "Hello world! I am above the Info component"),
React.createElement(Original, Object.assign({key: 2}, props)),
])
}
}
},
{
wrapComponents: {
info: (Original, { React, getConfig }) => (props) => {
return React.createElement("div", null, [
React.createElement(Original, Object.assign({key: 2}, props)),
React.createElement("h4", {key: 1}, "Hello world! I am below the Info component") ,
])
}
}
}
]
});Describe the bug you're encountering
When multiple plugins are configured with wrapComponents entry on the same core component (info for example), only the last one is applied.
I was expected all of them to be applied in a chain pattern. They should end up being embedded according to where the Original component is applied.
So, in this example I should see both my titles before and after the info content.
Fix
I pinpointed the issue on system.js where plugins are combined.
As systemExtend() is called with an empty object for dest, we can't retrieve the existing components.
I was able to fix this issue by replacing .reduce(systemExtend, {}) with .reduce(systemExtend, toolbox.getComponents()) on system.js
WDYT ?