diff --git a/packages/swagger-ui-plugins/plugins/layout/base-layout.plugin.ts b/packages/swagger-ui-plugins/plugins/layout/base-layout.plugin.ts index 0da1698..f77bc9b 100644 --- a/packages/swagger-ui-plugins/plugins/layout/base-layout.plugin.ts +++ b/packages/swagger-ui-plugins/plugins/layout/base-layout.plugin.ts @@ -7,6 +7,7 @@ import { wrapJsonschemaStringArrayComponent } from "../form/wrap-jsonschema-stri import OperationSummary from "../operations/operation-summary.component"; import OperationTag from "../operations/operation-tag.component"; import { updateFields } from "../operations/reducers/update-fields.reducer.js"; +import { wrapRequestBody } from "../operations/request-body.component"; import { wrapResponseBody } from "../operations/response-body.component"; import { wrapClear } from "../operations/wrap-clear"; import { wrapExecute } from "../operations/wrap-execute"; @@ -42,6 +43,7 @@ export const BaseLayoutPlugin = (system: System) => { execute: wrapExecute, clear: wrapClear, responseBody: wrapResponseBody, + RequestBody: wrapRequestBody, JsonSchema_string: wrapJsonschemaStringComponent, JsonSchema_array: wrapJsonschemaStringArrayComponent } diff --git a/packages/swagger-ui-plugins/plugins/operations/request-body.component.tsx b/packages/swagger-ui-plugins/plugins/operations/request-body.component.tsx new file mode 100644 index 0000000..151d103 --- /dev/null +++ b/packages/swagger-ui-plugins/plugins/operations/request-body.component.tsx @@ -0,0 +1,26 @@ +import { OrderedMap } from "immutable"; +import { FunctionComponent } from "react"; + +import type { System } from "../../interfaces/System"; + +export function wrapRequestBody(Base: FunctionComponent>) { + return (props: System & { requestBody?: any; contentType: any; specPath: any }) => { + const { getComponent, requestBody, specPath } = props; + const ModelExample = getComponent("modelExample"); + const requestBodyContent = requestBody?.get("content") ?? OrderedMap(); + const contentType = props.contentType || requestBodyContent.keySeq().first() || ""; + const mediaTypeValue = requestBodyContent.get(contentType) ?? OrderedMap(); + + return ( + } + includeWriteOnly={true} + /> + ); + }; +}