Skip to content

Commit c72c476

Browse files
authored
Merge branch 'master' into bug/editor-1418-oas3-jump-to-model
2 parents b16907c + 6233886 commit c72c476

File tree

11 files changed

+77
-23
lines changed

11 files changed

+77
-23
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ urls.primaryName | When using `urls`, you can use this subparameter. If the valu
138138
spec | A JSON object describing the OpenAPI Specification. When used, the `url` parameter will not be parsed. This is useful for testing manually-generated specifications without hosting them.
139139
validatorUrl | By default, Swagger-UI attempts to validate specs against swagger.io's online validator. You can use this parameter to set a different validator URL, for example for locally deployed validators ([Validator Badge](https://github.com/swagger-api/validator-badge)). Setting it to `null` will disable validation.
140140
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
141+
domNode | The HTML DOM element inside which SwaggerUi will put the user interface for swagger. Overrides `dom_id`.
141142
oauth2RedirectUrl | OAuth redirect URL
142143
tagsSorter | Apply a sort to the tag list of each API. It can be 'alpha' (sort by paths alphanumerically) or a function (see [Array.prototype.sort()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) to learn how to write a sort function). Two tag name strings are passed to the sorter for each pass. Default is the order determined by Swagger-UI.
143144
operationsSorter | Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically), 'method' (sort by HTTP method) or a function (see Array.prototype.sort() to know how sort function works). Default is the order returned by the server unchanged.

dist/swagger-ui-bundle.js

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui-bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui-standalone-preset.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"ieee754": "^1.1.8",
4444
"immutable": "^3.x.x",
4545
"js-yaml": "^3.5.5",
46-
"less": "2.7.1",
4746
"lodash": "4.17.2",
4847
"matcher": "^0.1.2",
4948
"memoizee": "0.4.1",

src/core/components/object-model.jsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export default class ObjectModel extends Component {
4141
}
4242
</span>)
4343

44+
const anyOf = specSelectors.isOAS3() ? schema.get("anyOf") : null
45+
const oneOf = specSelectors.isOAS3() ? schema.get("oneOf") : null
46+
const not = specSelectors.isOAS3() ? schema.get("not") : null
47+
4448
const titleEl = title && <span className="model-title">
4549
{ isRef && schema.get("$$ref") && <span className="model-hint">{ schema.get("$$ref") }</span> }
4650
<span className="model-title__text">{ title }</span>
@@ -98,6 +102,48 @@ export default class ObjectModel extends Component {
98102
</td>
99103
</tr>
100104
}
105+
{
106+
!anyOf ? null
107+
: <tr>
108+
<td>{ "anyOf ->" }</td>
109+
<td>
110+
{anyOf.map((schema, k) => {
111+
return <div key={k}><Model { ...props } required={ false }
112+
getComponent={ getComponent }
113+
schema={ schema }
114+
depth={ depth + 1 } /></div>
115+
})}
116+
</td>
117+
</tr>
118+
}
119+
{
120+
!oneOf ? null
121+
: <tr>
122+
<td>{ "oneOf ->" }</td>
123+
<td>
124+
{oneOf.map((schema, k) => {
125+
return <div key={k}><Model { ...props } required={ false }
126+
getComponent={ getComponent }
127+
schema={ schema }
128+
depth={ depth + 1 } /></div>
129+
})}
130+
</td>
131+
</tr>
132+
}
133+
{
134+
!not ? null
135+
: <tr>
136+
<td>{ "not ->" }</td>
137+
<td>
138+
{not.map((schema, k) => {
139+
return <div key={k}><Model { ...props } required={ false }
140+
getComponent={ getComponent }
141+
schema={ schema }
142+
depth={ depth + 1 } /></div>
143+
})}
144+
</td>
145+
</tr>
146+
}
101147
</tbody></table>
102148
}
103149
</span>

src/core/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = function SwaggerUI(opts) {
2323
const defaults = {
2424
// Some general settings, that we floated to the top
2525
dom_id: null,
26+
domNode: null,
2627
spec: {},
2728
url: "",
2829
urls: null,
@@ -99,6 +100,12 @@ module.exports = function SwaggerUI(opts) {
99100

100101
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
101102
let mergedConfig = deepExtend({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig)
103+
104+
// deep extend mangles domNode, we need to set it manually
105+
if(opts.domNode) {
106+
mergedConfig.domNode = opts.domNode
107+
}
108+
102109
store.setConfigs(mergedConfig)
103110

104111
if (fetchedConfig !== null) {
@@ -112,10 +119,13 @@ module.exports = function SwaggerUI(opts) {
112119
}
113120
}
114121

115-
if(mergedConfig.dom_id) {
116-
system.render(mergedConfig.dom_id, "App")
122+
if(mergedConfig.domNode) {
123+
system.render(mergedConfig.domNode, "App")
124+
} else if(mergedConfig.dom_id) {
125+
let domNode = document.querySelector(mergedConfig.dom_id)
126+
system.render(domNode, "App")
117127
} else {
118-
console.error("Skipped rendering: no `dom_id` was specified")
128+
console.error("Skipped rendering: no `dom_id` or `domNode` was specified")
119129
}
120130

121131
return system

src/core/plugins/auth/actions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, aut
150150

151151
let _headers = Object.assign({
152152
"Accept":"application/json, text/plain, */*",
153-
"Access-Control-Allow-Origin": "*",
154153
"Content-Type": "application/x-www-form-urlencoded"
155154
}, headers)
156155

0 commit comments

Comments
 (0)