diff --git a/dev-helpers/index.html b/dev-helpers/index.html index 59ed9497aabed3768da8c767ee140a12dc69f817..3a863dee572648ce68990c52b322348f44322840 100644 --- a/dev-helpers/index.html +++ b/dev-helpers/index.html @@ -77,6 +77,10 @@ const ui = SwaggerUIBundle({ url: "http://petstore.swagger.io/v2/swagger.json", dom_id: '#swagger-ui', + deepLinking: true, + defaultModelsExpandDepth: 1, + defaultModelExpandDepth: 1, + docExpansion: "list", presets: [ SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset diff --git a/dist/index.html b/dist/index.html index 0de47c6755508814b5dc5943f1d76e5fdcfed951..4f852369bad8b240a4c12b4c711908cef51cdd32 100644 --- a/dist/index.html +++ b/dist/index.html @@ -77,6 +77,9 @@ window.onload = function() { url: "http://petstore.swagger.io/v2/swagger.json", dom_id: '#swagger-ui', deepLinking: true, + defaultModelsExpandDepth: 1, + defaultModelExpandDepth: 1, + docExpansion: "list", presets: [ SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset diff --git a/docs/usage/configuration.md b/docs/usage/configuration.md index 2f38c6eea07d5d78421435923dd57f64ab9a7bcb..a334baa9e8aeaea1661bc59c94b179998a21cf70 100644 --- a/docs/usage/configuration.md +++ b/docs/usage/configuration.md @@ -49,8 +49,9 @@ Parameter Name | Description --- | --- `deepLinking` | `Boolean=false`. If set to `true`, enables deep linking for tags and operations. See the [Deep Linking documentation](/docs/usage/deep-linking.md) for more information. `displayOperationId` | `Boolean=false`. Controls the display of operationId in operations list. The default is `false`. -`defaultModelExpandDepth` | `Number=1`. The default expansion depth for models. -`defaultModelRendering` | `String=["example"*, "model"]`. Controls how models are shown when the API is first rendered. (The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links.) +`defaultModelsExpandDepth` | `Number=1`. The default expansion depth for models (set to -1 completely hide the models). +`defaultModelExpandDepth` | `Number=1`. The default expansion depth for the model on the model-example section. +`defaultModelRendering` | `String=["example"*, "model"]`. Controls how the model is shown when the API is first rendered. (The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links.) `displayRequestDuration` | `Boolean=false`. Controls the display of the request duration (in milliseconds) for Try-It-Out requests. `docExpansion` | `String=["list"*, "full", "none"]`. Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). `filter` | `Boolean=false OR String`. 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 Boolean to enable or disable, or a 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. diff --git a/src/core/components/models.jsx b/src/core/components/models.jsx index 55965b12d774a47d15c6d91ca711f1562eb671b7..cafd59ec1c7a0bfb577b9588602501d8bf714bd3 100644 --- a/src/core/components/models.jsx +++ b/src/core/components/models.jsx @@ -13,14 +13,14 @@ export default class Models extends Component { render(){ let { specSelectors, getComponent, layoutSelectors, layoutActions, getConfigs } = this.props let definitions = specSelectors.definitions() - let { docExpansion, defaultModelExpandDepth } = getConfigs() - let showModels = layoutSelectors.isShown("models", docExpansion === "full" || docExpansion === "list" ) + let { docExpansion, defaultModelsExpandDepth } = getConfigs() + if (!definitions.size || defaultModelsExpandDepth < 0) return null + + let showModels = layoutSelectors.isShown("models", defaultModelsExpandDepth > 0 && docExpansion !== "none") const specPathBase = specSelectors.isOAS3() ? ["components", "schemas"] : ["definitions"] const ModelWrapper = getComponent("ModelWrapper") - const Collapse = getComponent("Collapse") - - if (!definitions.size) return null + const Collapse = getComponent("Collapse") return

layoutActions.show("models", !showModels)}> @@ -34,7 +34,7 @@ export default class Models extends Component { definitions.entrySeq().map( ( [ name, model ])=>{ return
", function(){ layoutActions: {}, getConfigs: () => ({ docExpansion: "list", - defaultModelExpandDepth: 0 + defaultModelsExpandDepth: 0 }) } - it("passes defaultModelExpandDepth to ModelWrapper", function(){ + it("passes defaultModelsExpandDepth to ModelWrapper", function(){ // When let wrapper = shallow()