Merge branch 'master' into bug/3505-schema-title-in-array-schemes
This commit is contained in:
@@ -138,6 +138,7 @@ urls.primaryName | When using `urls`, you can use this subparameter. If the valu
|
|||||||
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.
|
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.
|
||||||
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.
|
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.
|
||||||
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
|
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
|
||||||
|
domNode | The HTML DOM element inside which SwaggerUi will put the user interface for swagger. Overrides `dom_id`.
|
||||||
oauth2RedirectUrl | OAuth redirect URL
|
oauth2RedirectUrl | OAuth redirect URL
|
||||||
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.
|
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.
|
||||||
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.
|
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.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default class ObjectModel extends Component {
|
|||||||
|
|
||||||
render(){
|
render(){
|
||||||
let { schema, name, isRef, getComponent, depth, ...props } = this.props
|
let { schema, name, isRef, getComponent, depth, ...props } = this.props
|
||||||
let { expandDepth } = this.props
|
let { expandDepth, specSelectors } = this.props
|
||||||
let description = schema.get("description")
|
let description = schema.get("description")
|
||||||
let properties = schema.get("properties")
|
let properties = schema.get("properties")
|
||||||
let additionalProperties = schema.get("additionalProperties")
|
let additionalProperties = schema.get("additionalProperties")
|
||||||
@@ -38,6 +38,10 @@ export default class ObjectModel extends Component {
|
|||||||
}
|
}
|
||||||
</span>)
|
</span>)
|
||||||
|
|
||||||
|
const anyOf = specSelectors.isOAS3() ? schema.get("anyOf") : null
|
||||||
|
const oneOf = specSelectors.isOAS3() ? schema.get("oneOf") : null
|
||||||
|
const not = specSelectors.isOAS3() ? schema.get("not") : null
|
||||||
|
|
||||||
const titleEl = title && <span className="model-title">
|
const titleEl = title && <span className="model-title">
|
||||||
{ isRef && schema.get("$$ref") && <span className="model-hint">{ schema.get("$$ref") }</span> }
|
{ isRef && schema.get("$$ref") && <span className="model-hint">{ schema.get("$$ref") }</span> }
|
||||||
<span className="model-title__text">{ title }</span>
|
<span className="model-title__text">{ title }</span>
|
||||||
@@ -95,6 +99,48 @@ export default class ObjectModel extends Component {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
!anyOf ? null
|
||||||
|
: <tr>
|
||||||
|
<td>{ "anyOf ->" }</td>
|
||||||
|
<td>
|
||||||
|
{anyOf.map((schema, k) => {
|
||||||
|
return <div key={k}><Model { ...props } required={ false }
|
||||||
|
getComponent={ getComponent }
|
||||||
|
schema={ schema }
|
||||||
|
depth={ depth + 1 } /></div>
|
||||||
|
})}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
{
|
||||||
|
!oneOf ? null
|
||||||
|
: <tr>
|
||||||
|
<td>{ "oneOf ->" }</td>
|
||||||
|
<td>
|
||||||
|
{oneOf.map((schema, k) => {
|
||||||
|
return <div key={k}><Model { ...props } required={ false }
|
||||||
|
getComponent={ getComponent }
|
||||||
|
schema={ schema }
|
||||||
|
depth={ depth + 1 } /></div>
|
||||||
|
})}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
{
|
||||||
|
!not ? null
|
||||||
|
: <tr>
|
||||||
|
<td>{ "not ->" }</td>
|
||||||
|
<td>
|
||||||
|
{not.map((schema, k) => {
|
||||||
|
return <div key={k}><Model { ...props } required={ false }
|
||||||
|
getComponent={ getComponent }
|
||||||
|
schema={ schema }
|
||||||
|
depth={ depth + 1 } /></div>
|
||||||
|
})}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
const defaults = {
|
const defaults = {
|
||||||
// Some general settings, that we floated to the top
|
// Some general settings, that we floated to the top
|
||||||
dom_id: null,
|
dom_id: null,
|
||||||
|
domNode: null,
|
||||||
spec: {},
|
spec: {},
|
||||||
url: "",
|
url: "",
|
||||||
urls: null,
|
urls: null,
|
||||||
@@ -99,6 +100,12 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
|
|
||||||
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
|
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
|
||||||
let mergedConfig = deepExtend({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig)
|
let mergedConfig = deepExtend({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig)
|
||||||
|
|
||||||
|
// deep extend mangles domNode, we need to set it manually
|
||||||
|
if(opts.domNode) {
|
||||||
|
mergedConfig.domNode = opts.domNode
|
||||||
|
}
|
||||||
|
|
||||||
store.setConfigs(mergedConfig)
|
store.setConfigs(mergedConfig)
|
||||||
|
|
||||||
if (fetchedConfig !== null) {
|
if (fetchedConfig !== null) {
|
||||||
@@ -112,10 +119,13 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mergedConfig.dom_id) {
|
if(mergedConfig.domNode) {
|
||||||
system.render(mergedConfig.dom_id, "App")
|
system.render(mergedConfig.domNode, "App")
|
||||||
|
} else if(mergedConfig.dom_id) {
|
||||||
|
let domNode = document.querySelector(mergedConfig.dom_id)
|
||||||
|
system.render(domNode, "App")
|
||||||
} else {
|
} else {
|
||||||
console.error("Skipped rendering: no `dom_id` was specified")
|
console.error("Skipped rendering: no `dom_id` or `domNode` was specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
return system
|
return system
|
||||||
|
|||||||
@@ -58,8 +58,7 @@ export const makeMappedContainer = (getSystem, getStore, memGetComponent, getCom
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const render = (getSystem, getStore, getComponent, getComponents, dom) => {
|
export const render = (getSystem, getStore, getComponent, getComponents, domNode) => {
|
||||||
let domNode = document.querySelector(dom)
|
|
||||||
let App = (getComponent(getSystem, getStore, getComponents, "App", "root"))
|
let App = (getComponent(getSystem, getStore, getComponents, "App", "root"))
|
||||||
ReactDOM.render(( <App/> ), domNode)
|
ReactDOM.render(( <App/> ), domNode)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user