Merge pull request #2912 from shockey/bug/2904-try-it-out
Fix inferring issues with Try-It-Out
This commit is contained in:
91
dist/swagger-ui-bundle.js
vendored
91
dist/swagger-ui-bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui-bundle.js.map
vendored
2
dist/swagger-ui-bundle.js.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0dA;;;;;;AAoIA;AAk7FA;AAmtCA;;;;;AA0uIA;AA66IA;AA27FA;AAuwGA;AAilFA;AAikFA;AAs9CA;AA8jDA;AA2qCA;AA4tEA;AAgkIA;;;;;;;;;;;;;;AAw4GA;AAyoIA;AAiuJA;AA8kHA;AAonGA;AAukEA;AA02DA;AAyxDA;AAw6BA;;;;;;AA8vEA;AAm0FA;;;;;AA23CA;AA2qFA;AAw2CA;AA2kCA;AAq/CA;AAwwEA;AA48FA;;;;;;;;;AA81BA;AA2zIA;AAi4DA;AA6tDA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0dA;AAkoJA;AAyiCA;;;;;AAskCA;AA66IA;AA27FA;AAuwGA;AA6mEA;AAk+CA;AA+/CA;AAgsCA;AAs3EA;AAo+HA;;;;;;;;;;;;;;AAusGA;AAyoIA;AAiuJA;AA8kHA;AAonGA;AAukEA;AA02DA;AAyxDA;AAw6BA;;;;;;AAs0EA;AA24FA;;;;;AAy3CA;AA2qFA;AAw2CA;AA2kCA;AAq/CA;AAwwEA;AA48FA;;;;;;;;;AA81BA;AA2zIA;AAi4DA;AA6tDA;;;;;;AAg3BA;AA8iHA;AAipGA","sourceRoot":""}
|
||||||
16
dist/swagger-ui.js
vendored
16
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui.js.map
vendored
2
dist/swagger-ui.js.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAuwCA;AAoyHA;AA2wHA;AA07FA;AAmoCA;AAghCA;AA0gCA;AAw4BA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAuwCA;AAoyHA;AAgxHA;AAo8FA;AAooCA;AAghCA;AA0gCA;AAw4BA","sourceRoot":""}
|
||||||
@@ -68,6 +68,7 @@
|
|||||||
"serialize-error": "2.0.0",
|
"serialize-error": "2.0.0",
|
||||||
"shallowequal": "0.2.2",
|
"shallowequal": "0.2.2",
|
||||||
"swagger-client": "^3.0.5",
|
"swagger-client": "^3.0.5",
|
||||||
|
"url-parse": "^1.1.8",
|
||||||
"whatwg-fetch": "0.11.1",
|
"whatwg-fetch": "0.11.1",
|
||||||
"worker-loader": "^0.7.1",
|
"worker-loader": "^0.7.1",
|
||||||
"xml": "1.0.1",
|
"xml": "1.0.1",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import YAML from "js-yaml"
|
import YAML from "js-yaml"
|
||||||
|
import parseUrl from "url-parse"
|
||||||
import serializeError from "serialize-error"
|
import serializeError from "serialize-error"
|
||||||
|
|
||||||
// Actions conform to FSA (flux-standard-actions)
|
// Actions conform to FSA (flux-standard-actions)
|
||||||
@@ -186,7 +187,11 @@ export const logRequest = (req) => {
|
|||||||
// (For debugging) and ease of testing
|
// (For debugging) and ease of testing
|
||||||
export const executeRequest = (req) => ({fn, specActions, specSelectors}) => {
|
export const executeRequest = (req) => ({fn, specActions, specSelectors}) => {
|
||||||
let { pathName, method } = req
|
let { pathName, method } = req
|
||||||
let parsedRequest = Object.assign({ contextUrl: specSelectors.url() }, req)
|
|
||||||
|
// if url is relative, parseUrl makes it absolute by inferring from `window.location`
|
||||||
|
req.contextUrl = parseUrl(specSelectors.url()).toString()
|
||||||
|
|
||||||
|
let parsedRequest = Object.assign({}, req)
|
||||||
if ( pathName && method ) {
|
if ( pathName && method ) {
|
||||||
parsedRequest.operationId = method.toLowerCase() + "-" + pathName
|
parsedRequest.operationId = method.toLowerCase() + "-" + pathName
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,7 +291,11 @@ export function operationConsumes(state, pathMethod) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const operationScheme = ( state, path, method ) => {
|
export const operationScheme = ( state, path, method ) => {
|
||||||
return state.getIn(["scheme", path, method]) || state.getIn(["scheme", "_defaultScheme"]) || "http"
|
let url = state.get("url")
|
||||||
|
let matchResult = url.match(/^([a-z][a-z0-9+\-.]*):/)
|
||||||
|
let urlScheme = Array.isArray(matchResult) ? matchResult[1] : null
|
||||||
|
|
||||||
|
return state.getIn(["scheme", path, method]) || state.getIn(["scheme", "_defaultScheme"]) || urlScheme || "http"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const canExecuteScheme = ( state, path, method ) => {
|
export const canExecuteScheme = ( state, path, method ) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
import expect from "expect"
|
import expect from "expect"
|
||||||
import { fromJS } from "immutable"
|
import { fromJS } from "immutable"
|
||||||
import { parameterValues, contentTypeValues } from "corePlugins/spec/selectors"
|
import { parameterValues, contentTypeValues, operationScheme } from "corePlugins/spec/selectors"
|
||||||
|
|
||||||
describe("spec plugin - selectors", function(){
|
describe("spec plugin - selectors", function(){
|
||||||
|
|
||||||
@@ -92,4 +92,43 @@ describe("spec plugin - selectors", function(){
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("operationScheme", function(){
|
||||||
|
|
||||||
|
it("should return the correct scheme for a remote spec that doesn't specify a scheme", function(){
|
||||||
|
// Given
|
||||||
|
let state = fromJS({
|
||||||
|
url: "https://generator.swagger.io/api/swagger.json",
|
||||||
|
resolved: {
|
||||||
|
paths: {
|
||||||
|
"/one": {
|
||||||
|
get: {
|
||||||
|
"consumes_value": "one",
|
||||||
|
"produces_value": "two"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// When
|
||||||
|
let scheme = operationScheme(state, ["/one"], "get")
|
||||||
|
// Then
|
||||||
|
expect(scheme).toEqual("https")
|
||||||
|
})
|
||||||
|
|
||||||
|
// it("should be ok, if no operation found", function(){
|
||||||
|
// // Given
|
||||||
|
// let state = fromJS({ })
|
||||||
|
//
|
||||||
|
// // When
|
||||||
|
// let contentTypes = contentTypeValues(state, [ "/one", "get" ])
|
||||||
|
// // Then
|
||||||
|
// expect(contentTypes.toJS()).toEqual({
|
||||||
|
// requestContentType: undefined,
|
||||||
|
// responseContentType: undefined
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user