diff --git a/src/core/components/response.jsx b/src/core/components/response.jsx index e25cbce5..dd14a228 100644 --- a/src/core/components/response.jsx +++ b/src/core/components/response.jsx @@ -79,14 +79,15 @@ export default class Response extends React.Component { const ContentType = getComponent("contentType") var sampleResponse + var schema if(isOAS3()) { let oas3SchemaForContentType = response.getIn(["content", this.state.responseContentType, "schema"]) sampleResponse = oas3SchemaForContentType ? getSampleSchema(oas3SchemaForContentType.toJS(), this.state.responseContentType, { includeReadOnly: true }) : null - var schema = oas3SchemaForContentType ? inferSchema(oas3SchemaForContentType.toJS()) : null + schema = oas3SchemaForContentType ? inferSchema(oas3SchemaForContentType.toJS()) : null } else { sampleResponse = schema ? getSampleSchema(schema, contentType, { includeReadOnly: true }) : null - var schema = inferSchema(response.toJS()) + schema = inferSchema(response.toJS()) } let example = getExampleComponent( sampleResponse, examples, HighlightCode ) diff --git a/src/core/components/version-stamp.jsx b/src/core/components/version-stamp.jsx index 19e58ae3..262cc023 100644 --- a/src/core/components/version-stamp.jsx +++ b/src/core/components/version-stamp.jsx @@ -1,5 +1,12 @@ import React from "react" +import PropTypes from "prop-types" -export default ({ version }) => { +const VersionStamp = ({ version }) => { return
 { version } 
} + +VersionStamp.propTypes = { + version: PropTypes.string.isRequired +} + +export default VersionStamp diff --git a/src/core/plugins/oas3/components/callbacks.jsx b/src/core/plugins/oas3/components/callbacks.jsx index f2e3c325..5414f59f 100644 --- a/src/core/plugins/oas3/components/callbacks.jsx +++ b/src/core/plugins/oas3/components/callbacks.jsx @@ -1,8 +1,9 @@ import React from "react" +import PropTypes from "prop-types" -export default (props) => { +const Callbacks = (props) => { let { callbacks, getComponent } = props - const Markdown = getComponent("Markdown") + // const Markdown = getComponent("Markdown") const Operation = getComponent("operation", true) if(!callbacks) { @@ -10,10 +11,10 @@ export default (props) => { } let callbackElements = callbacks.map((callback, callbackName) => { - return
+ return

{callbackName}

{ callback.map((pathItem, pathItemName) => { - return
+ return
{ pathItem.map((operation, method) => { return { {callbackElements}
} + +Callbacks.propTypes = { + getComponent: PropTypes.function.isRequired, + callbacks: PropTypes.array.isRequired + +} + +export default Callbacks diff --git a/src/core/plugins/oas3/components/operation-link.jsx b/src/core/plugins/oas3/components/operation-link.jsx index 1007658c..6f9eef0a 100644 --- a/src/core/plugins/oas3/components/operation-link.jsx +++ b/src/core/plugins/oas3/components/operation-link.jsx @@ -1,6 +1,8 @@ import React, { Component } from "react" +import PropTypes from "prop-types" +import ImPropTypes from "react-immutable-proptypes" -export default class OperationLink extends Component { +class OperationLink extends Component { render() { const { link, name } = this.props @@ -26,3 +28,10 @@ function padString(n, string) { .map((line, i) => i > 0 ? Array(n + 1).join(" ") + line : line) .join("\n") } + +OperationLink.propTypes = { + link: ImPropTypes.orderedMap.isRequired, + name: PropTypes.String +} + +export default OperationLink diff --git a/src/core/plugins/oas3/components/request-body.jsx b/src/core/plugins/oas3/components/request-body.jsx index e3c73ecc..f1b87897 100644 --- a/src/core/plugins/oas3/components/request-body.jsx +++ b/src/core/plugins/oas3/components/request-body.jsx @@ -1,9 +1,11 @@ import React from "react" +import PropTypes from "prop-types" +import ImPropTypes from "react-immutable-proptypes" import { OrderedMap } from "immutable" import { getSampleSchema } from "core/utils" -export default ({ requestBody, getComponent, specSelectors, contentType }) => { +const RequestBody = ({ requestBody, getComponent, specSelectors, contentType }) => { const Markdown = getComponent("Markdown") const ModelExample = getComponent("modelExample") const HighlightCode = getComponent("highlightCode") @@ -29,3 +31,12 @@ export default ({ requestBody, getComponent, specSelectors, contentType }) => { />
} + +RequestBody.propTypes = { + requestBody: ImPropTypes.orderedMap.isRequired, + getComponent: PropTypes.function.isRequired, + specSelectors: PropTypes.object.isRequired, + contentType: PropTypes.string.isRequired +} + +export default RequestBody diff --git a/src/core/plugins/oas3/wrap-components/model.jsx b/src/core/plugins/oas3/wrap-components/model.jsx index 080c8b1c..f2b56416 100644 --- a/src/core/plugins/oas3/wrap-components/model.jsx +++ b/src/core/plugins/oas3/wrap-components/model.jsx @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from "react" +import React, { Component } from "react" +import PropTypes from "prop-types" import { OAS3ComponentWrapFactory } from "../helpers" import { Model } from "core/components/model" diff --git a/src/core/plugins/oas3/wrap-components/online-validator-badge.js b/src/core/plugins/oas3/wrap-components/online-validator-badge.js index 63750943..e893abb6 100644 --- a/src/core/plugins/oas3/wrap-components/online-validator-badge.js +++ b/src/core/plugins/oas3/wrap-components/online-validator-badge.js @@ -1,4 +1,3 @@ -import React from "react" import { OAS3ComponentWrapFactory } from "../helpers" // We're disabling the Online Validator Badge until the online validator diff --git a/src/core/plugins/oas3/wrap-components/parameters.jsx b/src/core/plugins/oas3/wrap-components/parameters.jsx index 3306a4af..e735085e 100644 --- a/src/core/plugins/oas3/wrap-components/parameters.jsx +++ b/src/core/plugins/oas3/wrap-components/parameters.jsx @@ -1,12 +1,9 @@ -import React, { Component, PropTypes } from "react" +import React, { Component } from "react" +import PropTypes from "prop-types" import Im, { Map } from "immutable" import ImPropTypes from "react-immutable-proptypes" import { OAS3ComponentWrapFactory } from "../helpers" -const mapRequestBody = (iterable, fn) => iterable.entries().filter(Im.Map.isMap).map((val) => { - return fn(val.get(0), val.get(1)) -}) - // More readable, just iterate over maps, only const eachMap = (iterable, fn) => iterable.valueSeq().filter(Im.Map.isMap).map(fn) diff --git a/src/core/plugins/oas3/wrap-components/try-it-out-button.jsx b/src/core/plugins/oas3/wrap-components/try-it-out-button.jsx index 0ae20dc7..61b9771d 100644 --- a/src/core/plugins/oas3/wrap-components/try-it-out-button.jsx +++ b/src/core/plugins/oas3/wrap-components/try-it-out-button.jsx @@ -1,4 +1,3 @@ -import React from "react" import { OAS3ComponentWrapFactory } from "../helpers" export default OAS3ComponentWrapFactory(() => { diff --git a/src/core/plugins/spec/selectors.js b/src/core/plugins/spec/selectors.js index 1e06e277..fbc12764 100644 --- a/src/core/plugins/spec/selectors.js +++ b/src/core/plugins/spec/selectors.js @@ -49,8 +49,10 @@ export const spec = state => { export const isOAS3 = createSelector( // isOAS3 is stubbed out here to work around an issue with injecting more selectors // in the OAS3 plugin, and to ensure that the function is always available. + // It's not perfect, but our hybrid (core+plugin code) implementation for OAS3 + // needs this. //KS spec, - spec => false + () => false ) export const info = createSelector( diff --git a/test/.eslintrc b/test/.eslintrc index 9808c3b2..3067bb51 100644 --- a/test/.eslintrc +++ b/test/.eslintrc @@ -1,2 +1,5 @@ env: mocha: true +rules: + "react/prop-types": 1 # bah humbug + "no-unused-vars": 1 # unused vars in tests can be useful for indicating a full signature diff --git a/test/core/system/system.js b/test/core/system/system.js index 4736e3a4..ada3a93b 100644 --- a/test/core/system/system.js +++ b/test/core/system/system.js @@ -326,7 +326,7 @@ describe("bound system", function(){ }) - describe('wrapSelectors', () => { + describe("wrapSelectors", () => { it("should wrap a selector and provide a reference to the original", function(){ // Given @@ -427,7 +427,7 @@ describe("bound system", function(){ wrapSelectors: { wow: (ori, system) => (dogeState) => { // Then - expect(dogeState.toJS().abc).toEqual('123') + expect(dogeState.toJS().abc).toEqual("123") done() return ori() + " wrapper" }