modelPropertyMacro, parameterMacro

This commit is contained in:
Anna Bodnia
2017-05-19 18:50:51 +03:00
parent c66436e7d5
commit edfe88d299
6 changed files with 24 additions and 15 deletions

View File

@@ -77,6 +77,12 @@ window.onload = function() {
const ui = SwaggerUIBundle({ const ui = SwaggerUIBundle({
url: "http://petstore.swagger.io/v2/swagger.json", url: "http://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui', dom_id: '#swagger-ui',
modelPropertyMacro: function (model) {
return model
},
parameterMacro: function (operation, parameter) {
return parameter
},
presets: [ presets: [
SwaggerUIBundle.presets.apis, SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset SwaggerUIStandalonePreset
@@ -94,8 +100,8 @@ window.onload = function() {
clientSecret: "your-client-secret-if-required", clientSecret: "your-client-secret-if-required",
realm: "your-realms", realm: "your-realms",
appName: "your-app-name", appName: "your-app-name",
scopeSeparator: "-", scopeSeparator: " ",
additionalQueryStringParams: {test: "hello"} additionalQueryStringParams: {}
}) })
} }
</script> </script>

2
dist/swagger-ui.css vendored

File diff suppressed because one or more lines are too long

14
dist/swagger-ui.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA0yCA;AAoyHA;AA8xHA;AA0kGA;AA+9BA;AA+iCA;AAmjCA;AA25BA","sourceRoot":""} {"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA0yCA;AAoyHA;AAiyHA;AAwkGA;AA48BA;AAqkCA;AA8iCA;AAs6BA","sourceRoot":""}

View File

@@ -7,8 +7,8 @@ import * as AllPlugins from "core/plugins/all"
import { parseSeach, filterConfigs } from "core/utils" import { parseSeach, filterConfigs } from "core/utils"
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion", const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
"apisSorter", "operationsSorter", "supportedSubmitMethods", "highlightSizeThreshold", "dom_id", "apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl",
"defaultModelRendering", "oauth2RedirectUrl", "showRequestHeaders", "custom" ] "showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro" ]
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo

View File

@@ -77,7 +77,10 @@ export const parseToJson = (str) => ({specActions, specSelectors, errActions}) =
return specActions.updateJsonSpec(json) return specActions.updateJsonSpec(json)
} }
export const resolveSpec = (json, url) => ({specActions, specSelectors, errActions, fn: { fetch, resolve, AST }}) => { export const resolveSpec = (json, url) => ({specActions, specSelectors, errActions, fn: { fetch, resolve, AST }, getConfigs}) => {
const { modelPropertyMacro, parameterMacro } = getConfigs()
debugger
if(typeof(json) === "undefined") { if(typeof(json) === "undefined") {
json = specSelectors.specJson() json = specSelectors.specJson()
} }
@@ -89,7 +92,7 @@ export const resolveSpec = (json, url) => ({specActions, specSelectors, errActio
let specStr = specSelectors.specStr() let specStr = specSelectors.specStr()
return resolve({fetch, spec: json, baseDoc: url}) return resolve({fetch, spec: json, baseDoc: url, modelPropertyMacro, parameterMacro })
.then( ({spec, errors}) => { .then( ({spec, errors}) => {
errActions.clear({ errActions.clear({
type: "thrown" type: "thrown"