Reorganize wrapComponents, fix CommonMark
This commit is contained in:
@@ -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",
|
||||
|
||||
24
src/core/plugins/oas3/helpers.js
Normal file
24
src/core/plugins/oas3/helpers.js
Normal file
@@ -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 <Component {...props}></Component>
|
||||
} else {
|
||||
return <Ori {...props}></Ori>
|
||||
}
|
||||
} else {
|
||||
console.warn("OAS3 wrapper: couldn't get spec")
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
5
src/core/plugins/oas3/wrap-components/index.js
Normal file
5
src/core/plugins/oas3/wrap-components/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import Markdown from "./markdown"
|
||||
|
||||
export default {
|
||||
Markdown
|
||||
}
|
||||
5
src/core/plugins/oas3/wrap-components/markdown.js
Normal file
5
src/core/plugins/oas3/wrap-components/markdown.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import React from "react"
|
||||
import ReactMarkdown from "react-markdown"
|
||||
import { OAS3ComponentWrapFactory } from "../helpers"
|
||||
|
||||
export default OAS3ComponentWrapFactory(({ source }) => <ReactMarkdown source={source} />)
|
||||
Reference in New Issue
Block a user