From 7deff73eea91a5cf84337eb837ddb169d9a8eaf5 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Thu, 1 Jun 2017 09:34:42 -0700 Subject: [PATCH] (Actually) display callbacks --- .../plugins/oas3/components/callbacks.jsx | 31 ++++++++++++++++++ src/core/plugins/oas3/components/index.js | 7 ++++ .../plugins/oas3/components/request-body.jsx | 29 +++++++++++++++++ src/core/plugins/oas3/index.js | 5 ++- .../oas3/wrap-components/parameters.jsx | 32 +++++-------------- 5 files changed, 77 insertions(+), 27 deletions(-) create mode 100644 src/core/plugins/oas3/components/callbacks.jsx create mode 100644 src/core/plugins/oas3/components/index.js create mode 100644 src/core/plugins/oas3/components/request-body.jsx diff --git a/src/core/plugins/oas3/components/callbacks.jsx b/src/core/plugins/oas3/components/callbacks.jsx new file mode 100644 index 00000000..82bfd7b9 --- /dev/null +++ b/src/core/plugins/oas3/components/callbacks.jsx @@ -0,0 +1,31 @@ +import React from "react" + +export default ({ callbacks, getComponent }) => { + const Markdown = getComponent("Markdown") + + if(!callbacks) { + return No callbacks + } + + let callbackElements = callbacks.map((callback, callbackName) => { + return
+

{callbackName}

+ { callback.map((pathItem, pathItemName) => { + return
+

{pathItemName}

+ { pathItem.map((operation, method) => { + return
{JSON.stringify(operation)}
+ }) } +
+ }) } +
+ // return
+ //

{name}

+ // {callback.description && } + //
{JSON.stringify(callback)}
+ //
+ }) + return
+ {callbackElements} +
+} diff --git a/src/core/plugins/oas3/components/index.js b/src/core/plugins/oas3/components/index.js new file mode 100644 index 00000000..f6c2174d --- /dev/null +++ b/src/core/plugins/oas3/components/index.js @@ -0,0 +1,7 @@ +import Callbacks from "./callbacks" +import RequestBody from "./request-body" + +export default { + Callbacks, + RequestBody +} diff --git a/src/core/plugins/oas3/components/request-body.jsx b/src/core/plugins/oas3/components/request-body.jsx new file mode 100644 index 00000000..d4b58cb7 --- /dev/null +++ b/src/core/plugins/oas3/components/request-body.jsx @@ -0,0 +1,29 @@ +import React from "react" +import { OrderedMap } from "immutable" + + +export default ({ requestBody, getComponent, specSelectors }) => { + const Markdown = getComponent("Markdown") + const Model = getComponent("model") + + const requestBodyDescription = (requestBody && requestBody.get("description")) || null + const requestBodyContent = (requestBody && requestBody.get("content")) || new OrderedMap() + + return
+ { requestBodyDescription && +

{requestBodyDescription}

+ } + { !requestBodyContent.count() ?

No content

: + requestBodyContent.map((mediaTypeValue, key) => ( +
+

{key}

+ +
+ )).toArray() + } +
+} diff --git a/src/core/plugins/oas3/index.js b/src/core/plugins/oas3/index.js index 575cc61b..f8827455 100644 --- a/src/core/plugins/oas3/index.js +++ b/src/core/plugins/oas3/index.js @@ -1,13 +1,12 @@ // import reducers from "./reducers" // import * as actions from "./actions" import * as wrapSelectors from "./wrap-selectors" +import components from "./components" import wrapComponents from "./wrap-components" export default function() { return { - components: { - - }, + components, wrapComponents, statePlugins: { spec: { diff --git a/src/core/plugins/oas3/wrap-components/parameters.jsx b/src/core/plugins/oas3/wrap-components/parameters.jsx index 566c4c14..d87d7fe4 100644 --- a/src/core/plugins/oas3/wrap-components/parameters.jsx +++ b/src/core/plugins/oas3/wrap-components/parameters.jsx @@ -94,22 +94,20 @@ class Parameters extends Component { const ParameterRow = getComponent("parameterRow") const TryItOutButton = getComponent("TryItOutButton") - const Model = getComponent("model") + const Callbacks = getComponent("Callbacks", true) + const RequestBody = getComponent("RequestBody", true) const isExecute = tryItOutEnabled && allowTryItOut const requestBody = operation.get("requestBody") - const requestBodyDescription = (requestBody && requestBody.get("description")) || null - const requestBodyContent = (requestBody && requestBody.get("content")) || new OrderedMap() - return (
-
this.toggleTab("parameters")} className={this.state.parametersVisible ? "tab-item active" : "tab-item"}> +
this.toggleTab("parameters")} className={`tab-item ${this.state.parametersVisible && "active"}`}>

Parameters

-
this.toggleTab("callbacks")} className="tab-item"> +
this.toggleTab("callbacks")} className={`tab-item ${this.state.callbackVisible && "active"}`}>

Callbacks

@@ -147,31 +145,17 @@ class Parameters extends Component { }
: "" } - {this.state.callbackVisible ?
- covfefe + {this.state.callbackVisible ?
+
: "" } { - requestBody && + requestBody && this.state.parametersVisible &&

Request body

- { requestBodyDescription && -

{requestBodyDescription}

- } - { !requestBodyContent.count() ?

No content

: - requestBodyContent.map((mediaTypeValue, key) => ( -
-

{key}

- -
- )).toArray() - } +
}