From 70f53e5d62373337f05b825051033840fee836de Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 9 Aug 2017 15:35:11 -0700 Subject: [PATCH 01/10] Update issue template Lifted from the wonderful Babel issue template: https://github.com/babel/babel/issues/new --- .github/issue_template.md | 64 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 1b519695..7c82949d 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -1,3 +1,61 @@ -When reporting an issue, please provide the following details: -- swagger-ui version -- a swagger file reproducing the issue + + + + + +| Q | A +| ------------------------------- | ------- +| Bug or feature request? | +| Which Swagger/OpenAPI version? | +| Which Swagger-UI version? | +| How did you install Swagger-UI? | +| Which broswer & version? | +| Which operating system? | + + +### Demonstration spec + + + +```yaml +your: "spec goes here" +``` + +### Configuration (browser query string, constructor, config.yaml) + + +```js +{ + "your": { "constructorConfig": "here" } +} +``` + +`?yourQueryStringConfig=here` + +### Expected Behavior + + + +### Current Behavior + + + +### Possible Solution + + + +### Context + + From ff8ac0d42eed685c8f840c8db41e14e39e23219e Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 9 Aug 2017 15:37:09 -0700 Subject: [PATCH 02/10] LESS typos --- .github/issue_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 7c82949d..56cdc05f 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -4,7 +4,7 @@ Thanks for filing an issue 😄 ! Before you submit, please read the following: Search open/closed issues before submitting since someone might have asked the same thing before! Issues on GitHub are only related to problems of Swagger-UI itself. We'll try to offer support -here for you use case, but we can't offer help with projects that use Swagger-UI indirectly, +here for your use case, but we can't offer help with projects that use Swagger-UI indirectly, like Springfox or swagger-node. Likewise, we can't accept features or bugs in the Swagger/OpenAPI specifications themselves, From c35a904918ee8bce71ca1c0fb0000932f3c7407a Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 9 Aug 2017 15:38:49 -0700 Subject: [PATCH 03/10] spec -> API definition --- .github/issue_template.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 56cdc05f..9568fa80 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -25,12 +25,12 @@ or anything that violates the specifications. | Which operating system? | -### Demonstration spec - +### Demonstration API definition + ```yaml -your: "spec goes here" +your: "API definition goes here" ``` ### Configuration (browser query string, constructor, config.yaml) From 66d7638a91023c459c19c960ba8a0279f1a5e685 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 9 Aug 2017 16:01:34 -0700 Subject: [PATCH 04/10] Add note about large specs to issue template [ci skip] --- .github/issue_template.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/issue_template.md b/.github/issue_template.md index 9568fa80..407aac90 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -29,6 +29,8 @@ or anything that violates the specifications. + + ```yaml your: "API definition goes here" ``` From f9d6e770914a744826ffffac267d4858af94bd3d Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 9 Aug 2017 16:03:28 -0700 Subject: [PATCH 05/10] Update issue_template.md --- .github/issue_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 407aac90..77c30a7e 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -29,7 +29,7 @@ or anything that violates the specifications. - + ```yaml your: "API definition goes here" From 9dee2daa147dada6a6379034821c4aafdadcf043 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Wed, 9 Aug 2017 17:06:48 -0700 Subject: [PATCH 06/10] Fix global state issues with Schemes component --- src/core/components/layouts/base.jsx | 5 +++- src/core/components/schemes.jsx | 2 +- test/components/schemes.js | 35 ++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/core/components/layouts/base.jsx b/src/core/components/layouts/base.jsx index f502b88f..ea5fbce1 100644 --- a/src/core/components/layouts/base.jsx +++ b/src/core/components/layouts/base.jsx @@ -69,7 +69,10 @@ export default class BaseLayout extends React.Component {
{ schemes && schemes.size ? ( - + ) : null } { securityDefinitions ? ( diff --git a/src/core/components/schemes.jsx b/src/core/components/schemes.jsx index f9fe8f81..89ba0fbc 100644 --- a/src/core/components/schemes.jsx +++ b/src/core/components/schemes.jsx @@ -19,7 +19,7 @@ export default class Schemes extends React.Component { } componentWillReceiveProps(nextProps) { - if ( !this.props.operationScheme || !nextProps.schemes.has(this.props.operationScheme) ) { + if ( !this.props.operationScheme || !nextProps.schemes.includes(this.props.operationScheme) ) { // if we don't have a selected operationScheme or if our selected scheme is no longer an option, // then fire 'change' event and select the first scheme in the list of options this.setScheme(nextProps.schemes.first()) diff --git a/test/components/schemes.js b/test/components/schemes.js index a21c0628..8e0ebc1f 100644 --- a/test/components/schemes.js +++ b/test/components/schemes.js @@ -9,10 +9,12 @@ import Schemes from "components/schemes" describe("", function(){ it("calls props.specActions.setScheme() when no operationScheme is selected", function(){ + let setSchemeSpy = createSpy() + // Given let props = { specActions: { - setScheme: createSpy() + setScheme: setSchemeSpy }, schemes: fromJS([ "http", @@ -22,7 +24,7 @@ describe("", function(){ path: "/test", method: "get" } - + // When let wrapper = shallow() @@ -38,4 +40,33 @@ describe("", function(){ // Then operationScheme should default to first scheme in options list expect(props.specActions.setScheme).toHaveBeenCalledWith("https", "/test", "get") }) + + it.only("doesn't call props.specActions.setScheme() when schemes hasn't changed", function(){ + + let setSchemeSpy = createSpy() + + // Given + let props = { + specActions: { + setScheme: setSchemeSpy + }, + schemes: fromJS([ + "http", + "https" + ]), + operationScheme: "https" + } + + // When + let wrapper = shallow() + + // Should be called initially, to set the global state + expect(setSchemeSpy.calls.length).toEqual(1) + + // After an update + wrapper.instance().componentWillReceiveProps(props) + + // Should not be called again, since `operationScheme` is in schemes + expect(setSchemeSpy.calls.length).toEqual(1) + }) }) From 99c610f224e4a505d990d216b6b5ffbd6757da62 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Wed, 9 Aug 2017 17:10:39 -0700 Subject: [PATCH 07/10] Mark `operationScheme` as required prop --- src/core/components/schemes.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/components/schemes.jsx b/src/core/components/schemes.jsx index 89ba0fbc..a3a27ad1 100644 --- a/src/core/components/schemes.jsx +++ b/src/core/components/schemes.jsx @@ -6,9 +6,9 @@ export default class Schemes extends React.Component { static propTypes = { specActions: PropTypes.object.isRequired, schemes: PropTypes.object.isRequired, + operationScheme: PropTypes.string.isRequired, path: PropTypes.string, method: PropTypes.string, - operationScheme: PropTypes.string } componentWillMount() { From 9747559529e041591879cecc44244c505dd38d36 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Wed, 9 Aug 2017 17:35:33 -0700 Subject: [PATCH 08/10] operationScheme -> currentScheme --- src/core/components/layouts/base.jsx | 2 +- src/core/components/operation.jsx | 2 +- src/core/components/schemes.jsx | 6 +++--- test/components/schemes.js | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/components/layouts/base.jsx b/src/core/components/layouts/base.jsx index ea5fbce1..268ef46c 100644 --- a/src/core/components/layouts/base.jsx +++ b/src/core/components/layouts/base.jsx @@ -70,7 +70,7 @@ export default class BaseLayout extends React.Component { { schemes && schemes.size ? ( ) : null } diff --git a/src/core/components/operation.jsx b/src/core/components/operation.jsx index fc182a1e..4f6534db 100644 --- a/src/core/components/operation.jsx +++ b/src/core/components/operation.jsx @@ -229,7 +229,7 @@ export default class Operation extends PureComponent { path={ path } method={ method } specActions={ specActions } - operationScheme={ operationScheme } /> + currentScheme={ operationScheme } />
: null } diff --git a/src/core/components/schemes.jsx b/src/core/components/schemes.jsx index a3a27ad1..ed0947fe 100644 --- a/src/core/components/schemes.jsx +++ b/src/core/components/schemes.jsx @@ -6,7 +6,7 @@ export default class Schemes extends React.Component { static propTypes = { specActions: PropTypes.object.isRequired, schemes: PropTypes.object.isRequired, - operationScheme: PropTypes.string.isRequired, + currentScheme: PropTypes.string.isRequired, path: PropTypes.string, method: PropTypes.string, } @@ -19,8 +19,8 @@ export default class Schemes extends React.Component { } componentWillReceiveProps(nextProps) { - if ( !this.props.operationScheme || !nextProps.schemes.includes(this.props.operationScheme) ) { - // if we don't have a selected operationScheme or if our selected scheme is no longer an option, + if ( !this.props.currentScheme || !nextProps.schemes.includes(this.props.currentScheme) ) { + // if we don't have a selected currentScheme or if our selected scheme is no longer an option, // then fire 'change' event and select the first scheme in the list of options this.setScheme(nextProps.schemes.first()) } diff --git a/test/components/schemes.js b/test/components/schemes.js index 8e0ebc1f..9cea4a4e 100644 --- a/test/components/schemes.js +++ b/test/components/schemes.js @@ -7,7 +7,7 @@ import { fromJS } from "immutable" import Schemes from "components/schemes" describe("", function(){ - it("calls props.specActions.setScheme() when no operationScheme is selected", function(){ + it("calls props.specActions.setScheme() when no currentScheme is selected", function(){ let setSchemeSpy = createSpy() @@ -20,7 +20,7 @@ describe("", function(){ "http", "https" ]), - operationScheme: undefined, + currentScheme: undefined, path: "/test", method: "get" } @@ -28,16 +28,16 @@ describe("", function(){ // When let wrapper = shallow() - // Then operationScheme should default to first scheme in options list + // Then currentScheme should default to first scheme in options list expect(props.specActions.setScheme).toHaveBeenCalledWith("http", "/test" , "get") - // When the operationScheme is no longer in the list of options + // When the currentScheme is no longer in the list of options props.schemes = fromJS([ "https" ]) wrapper.setProps(props) - // Then operationScheme should default to first scheme in options list + // Then currentScheme should default to first scheme in options list expect(props.specActions.setScheme).toHaveBeenCalledWith("https", "/test", "get") }) @@ -54,7 +54,7 @@ describe("", function(){ "http", "https" ]), - operationScheme: "https" + currentScheme: "https" } // When @@ -66,7 +66,7 @@ describe("", function(){ // After an update wrapper.instance().componentWillReceiveProps(props) - // Should not be called again, since `operationScheme` is in schemes + // Should not be called again, since `currentScheme` is in schemes expect(setSchemeSpy.calls.length).toEqual(1) }) }) From b7a3f10f6472403180593d5f3e22ffc94a984608 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Wed, 9 Aug 2017 17:35:56 -0700 Subject: [PATCH 09/10] Remove it.only --- test/components/schemes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/components/schemes.js b/test/components/schemes.js index 9cea4a4e..2b918367 100644 --- a/test/components/schemes.js +++ b/test/components/schemes.js @@ -41,7 +41,7 @@ describe("", function(){ expect(props.specActions.setScheme).toHaveBeenCalledWith("https", "/test", "get") }) - it.only("doesn't call props.specActions.setScheme() when schemes hasn't changed", function(){ + it("doesn't call props.specActions.setScheme() when schemes hasn't changed", function(){ let setSchemeSpy = createSpy() From 049e227c3ca530bf96347819baba6c9b60e3d1fe Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Wed, 9 Aug 2017 17:44:36 -0700 Subject: [PATCH 10/10] Add small comment to test --- test/components/schemes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/components/schemes.js b/test/components/schemes.js index 2b918367..f8f5730c 100644 --- a/test/components/schemes.js +++ b/test/components/schemes.js @@ -37,7 +37,7 @@ describe("", function(){ ]) wrapper.setProps(props) - // Then currentScheme should default to first scheme in options list + // Then currentScheme should default to first scheme in options list, again expect(props.specActions.setScheme).toHaveBeenCalledWith("https", "/test", "get") })