Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,30 @@
<script src="./dist/swagger-ui-bundle.js"> </script>
<script src="./dist/swagger-ui-standalone-preset.js"> </script>
<script>
// A plugin to render the schema description for binary media types in the RequestBody component.
// rather than showing "Example values are not available for <type> media types."
const RequestBodySchemaDescription = () => ({
wrapComponents: {
RequestBody: (Original, system) => (props) => {
const React = system.React
const contentType = props.contentType || ""
const isBinaryMediaType = ["application/octet-stream", "image/", "audio/", "video/"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"image/", "audio/", "video/" why do we need these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified in 13b98c8

.some((mediaType) => contentType.startsWith(mediaType))
const description = isBinaryMediaType && props.requestBody
? props.requestBody.getIn(["content", contentType, "schema", "description"])
: null
if (!description) {
return React.createElement(Original, props)
}
const Markdown = system.getComponent("Markdown", true)
return React.createElement("div", null,
React.createElement("div", {className: "request-body-schema-description"},
React.createElement(Markdown, {source: description})),
React.createElement(Original, props))
}
}
})

window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
Expand All @@ -70,7 +94,8 @@
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
SwaggerUIBundle.plugins.DownloadUrl,
RequestBodySchemaDescription
],
layout: "StandaloneLayout"
})
Expand Down
Loading