Skip to content
Merged
Changes from all commits
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
26 changes: 25 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@
<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 application/octet-stream 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 isOctetStreamType = contentType.startsWith("application/octet-stream")
const description = isOctetStreamType && 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 +93,8 @@
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
SwaggerUIBundle.plugins.DownloadUrl,
RequestBodySchemaDescription
],
layout: "StandaloneLayout"
})
Expand Down
Loading