diff --git a/README.md b/README.md
index b1b99ae2..a570557b 100644
--- a/README.md
+++ b/README.md
@@ -170,8 +170,8 @@ displayRequestDuration | Controls the display of the request duration (in millis
maxDisplayedTags | If set, limits the number of tagged operations displayed to at most this many. The default is to show all operations.
filter | If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. Can be true/false to enable or disable, or an explicit filter string in which case filtering will be enabled using that string as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag.
deepLinking | If set to `true`, enables dynamic deep linking for tags and operations. [Docs](https://github.com/swagger-api/swagger-ui/blob/master/docs/deep-linking.md)
-requestInterceptor | MUST be a function. Function to intercept try-it-out requests. Accepts one argument requestInterceptor(request) and must return the potentially modified request.
-responseInterceptor | MUST be a function. Function to intercept try-it-out responses. Accepts one argument responseInterceptor(response) and must return the potentially modified response.
+requestInterceptor | MUST be a function. Function to intercept remote definition, Try-It-Out, and OAuth2 requests. Accepts one argument requestInterceptor(request) and must return the potentially modified request.
+responseInterceptor | MUST be a function. Function to intercept remote definition, Try-It-Out, and OAuth2 responses. Accepts one argument responseInterceptor(response) and must return the potentially modified response.
showMutatedRequest | If set to `true` (the default), uses the mutated request returned from a rquestInterceptor to produce the curl command in the UI, otherwise the request before the requestInterceptor was applied is used.
showExtensions | Controls the display of vendor extension (`x-`) fields and values for Operations, Parameters, and Schema. The default is `false`.
diff --git a/src/core/components/layout-utils.jsx b/src/core/components/layout-utils.jsx
index d1adfeb1..1601681f 100644
--- a/src/core/components/layout-utils.jsx
+++ b/src/core/components/layout-utils.jsx
@@ -183,7 +183,7 @@ export class Select extends React.Component {
{ allowEmptyValue ? : null }
{
allowedValues.map(function (item, key) {
- return
+ return
})
}
diff --git a/src/core/json-schema-components.js b/src/core/json-schema-components.js
index e8bf1e44..07fcada2 100644
--- a/src/core/json-schema-components.js
+++ b/src/core/json-schema-components.js
@@ -36,7 +36,7 @@ export class JsonSchemaForm extends Component {
let { type, format="" } = schema
- let Comp = getComponent(`JsonSchema_${type}_${format}`) || getComponent(`JsonSchema_${type}`) || getComponent("JsonSchema_string")
+ let Comp = (format ? getComponent(`JsonSchema_${type}_${format}`) : getComponent(`JsonSchema_${type}`)) || getComponent("JsonSchema_string")
return
}
@@ -68,19 +68,19 @@ export class JsonSchema_string extends Component {
const isDisabled = schema["in"] === "formData" && !("FormData" in window)
const Input = getComponent("Input")
if (schema["type"] === "file") {
- return ()
}
else {
- return ()
}
}
@@ -189,8 +189,8 @@ export class JsonSchema_boolean extends Component {
return ()
}
}
diff --git a/src/core/plugins/auth/actions.js b/src/core/plugins/auth/actions.js
index 7a41a398..d264c65d 100644
--- a/src/core/plugins/auth/actions.js
+++ b/src/core/plugins/auth/actions.js
@@ -139,7 +139,7 @@ export const authorizeAccessCodeWithBasicAuthentication = ( { auth, redirectUrl
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers})
}
-export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, authSelectors } ) => {
+export const authorizeRequest = ( data ) => ( { fn, getConfigs, authActions, errActions, authSelectors } ) => {
let { body, query={}, headers={}, name, url, auth } = data
let { additionalQueryStringParams } = authSelectors.getConfigs() || {}
let fetchUrl = url
@@ -158,7 +158,9 @@ export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, aut
method: "post",
headers: _headers,
query: query,
- body: body
+ body: body,
+ requestInterceptor: getConfigs().requestInterceptor,
+ responseInterceptor: getConfigs().responseInterceptor
})
.then(function (response) {
let token = JSON.parse(response.data)
diff --git a/test/components/json-schema-form.js b/test/components/json-schema-form.js
new file mode 100644
index 00000000..ba551919
--- /dev/null
+++ b/test/components/json-schema-form.js
@@ -0,0 +1,154 @@
+/* eslint-env mocha */
+import React from "react"
+import expect, { createSpy } from "expect"
+import { Select, Input } from "components/layout-utils"
+import { render } from "enzyme"
+import * as JsonSchemaComponents from "core/json-schema-components"
+import { JsonSchemaForm } from "core/json-schema-components"
+
+const components = {...JsonSchemaComponents, Select, Input}
+
+const getComponentStub = (name) => {
+ if(components[name]) return components[name]
+
+ return null
+}
+
+describe("", function(){
+ describe("strings", function() {
+ it("should render the correct options for a string enum parameter", function(){
+
+ let props = {
+ getComponent: getComponentStub,
+ value: "",
+ onChange: () => {},
+ keyName: "",
+ fn: {},
+ schema: {
+ type: "string",
+ enum: ["one", "two"]
+ }
+ }
+
+ let wrapper = render()
+
+ expect(wrapper.find("select").length).toEqual(1)
+ expect(wrapper.find("select option").length).toEqual(3)
+ expect(wrapper.find("select option").eq(0).text()).toEqual("--")
+ expect(wrapper.find("select option").eq(1).text()).toEqual("one")
+ expect(wrapper.find("select option").eq(2).text()).toEqual("two")
+ })
+
+ it("should render the correct options for a required string enum parameter", function(){
+
+ let props = {
+ getComponent: getComponentStub,
+ value: "",
+ onChange: () => {},
+ keyName: "",
+ fn: {},
+ required: true,
+ schema: {
+ type: "string",
+ enum: ["one", "two"]
+ }
+ }
+
+ let wrapper = render()
+
+ expect(wrapper.find("select").length).toEqual(1)
+ expect(wrapper.find("select option").length).toEqual(2)
+ expect(wrapper.find("select option").eq(0).text()).toEqual("one")
+ expect(wrapper.find("select option").eq(1).text()).toEqual("two")
+ })
+ })
+ describe("booleans", function() {
+ it("should render the correct options for a boolean parameter", function(){
+
+ let props = {
+ getComponent: getComponentStub,
+ value: "",
+ onChange: () => {},
+ keyName: "",
+ fn: {},
+ schema: {
+ type: "boolean"
+ }
+ }
+
+ let wrapper = render()
+
+ expect(wrapper.find("select").length).toEqual(1)
+ expect(wrapper.find("select option").length).toEqual(3)
+ expect(wrapper.find("select option").eq(0).text()).toEqual("--")
+ expect(wrapper.find("select option").eq(1).text()).toEqual("true")
+ expect(wrapper.find("select option").eq(2).text()).toEqual("false")
+ })
+
+ it("should render the correct options for a required enum boolean parameter", function(){
+
+ let props = {
+ getComponent: getComponentStub,
+ value: "",
+ onChange: () => {},
+ keyName: "",
+ fn: {},
+ required: true,
+ schema: {
+ type: "boolean",
+ enum: ["true"]
+ }
+ }
+
+ let wrapper = render()
+
+ expect(wrapper.find("select").length).toEqual(1)
+ expect(wrapper.find("select option").length).toEqual(1)
+ expect(wrapper.find("select option").first().text()).toEqual("true")
+ })
+ })
+ describe("unknown types", function() {
+ it("should render unknown types as strings", function(){
+
+ let props = {
+ getComponent: getComponentStub,
+ value: "yo",
+ onChange: () => {},
+ keyName: "",
+ fn: {},
+ schema: {
+ type: "NotARealType"
+ }
+ }
+
+
+ let wrapper = render()
+
+ expect(wrapper.find("input").length).toEqual(1)
+ // expect(wrapper.find("select input").length).toEqual(1)
+ // expect(wrapper.find("select option").first().text()).toEqual("true")
+ })
+
+ it("should render unknown types as strings when a format is passed", function(){
+
+ let props = {
+ getComponent: getComponentStub,
+ value: "yo",
+ onChange: () => {},
+ keyName: "",
+ fn: {},
+ schema: {
+ type: "NotARealType",
+ format: "NotARealFormat"
+ }
+ }
+
+
+ let wrapper = render()
+
+ expect(wrapper.find("input").length).toEqual(1)
+ // expect(wrapper.find("select input").length).toEqual(1)
+ // expect(wrapper.find("select option").first().text()).toEqual("true")
+ })
+ })
+})