diff --git a/package.json b/package.json index e7fda271..9e59b82b 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "react-height": "^2.0.0", "react-hot-loader": "1.3.1", "react-immutable-proptypes": "2.1.0", + "react-markdown": "^2.5.0", "react-motion": "0.4.4", "react-object-inspector": "0.2.1", "react-redux": "^4.x.x", diff --git a/src/core/plugins/oas3/helpers.js b/src/core/plugins/oas3/helpers.js new file mode 100644 index 00000000..b4d29a85 --- /dev/null +++ b/src/core/plugins/oas3/helpers.js @@ -0,0 +1,24 @@ +import React from "react" + +const SUPPORTED_OPENAPI_VERSIONS = ["3.0.0-rc0"] + +export function isOAS3(jsSpec) { + return !!jsSpec.openapi && SUPPORTED_OPENAPI_VERSIONS.indexOf(jsSpec.openapi) > -1 +} + +export function OAS3ComponentWrapFactory(Component) { + return (Ori, system) => (props) => { + if(system && system.specSelectors && system.specSelectors.specJson) { + const spec = system.specSelectors.specJson().toJS() + + if(isOAS3(spec)) { + return + } else { + return + } + } else { + console.warn("OAS3 wrapper: couldn't get spec") + return null + } + } +} diff --git a/src/core/plugins/oas3/index.js b/src/core/plugins/oas3/index.js index 8c40c8ae..575cc61b 100644 --- a/src/core/plugins/oas3/index.js +++ b/src/core/plugins/oas3/index.js @@ -1,13 +1,14 @@ // import reducers from "./reducers" // import * as actions from "./actions" import * as wrapSelectors from "./wrap-selectors" -// import * as wrapActions from "./wrap-actions" +import wrapComponents from "./wrap-components" export default function() { return { components: { }, + wrapComponents, statePlugins: { spec: { // wrapActions, diff --git a/src/core/plugins/oas3/wrap-components/index.js b/src/core/plugins/oas3/wrap-components/index.js new file mode 100644 index 00000000..4fb3e02b --- /dev/null +++ b/src/core/plugins/oas3/wrap-components/index.js @@ -0,0 +1,5 @@ +import Markdown from "./markdown" + +export default { + Markdown +} diff --git a/src/core/plugins/oas3/wrap-components/markdown.js b/src/core/plugins/oas3/wrap-components/markdown.js new file mode 100644 index 00000000..5c80275d --- /dev/null +++ b/src/core/plugins/oas3/wrap-components/markdown.js @@ -0,0 +1,5 @@ +import React from "react" +import ReactMarkdown from "react-markdown" +import { OAS3ComponentWrapFactory } from "../helpers" + +export default OAS3ComponentWrapFactory(({ source }) => )