diff --git a/README.md b/README.md index 21c5a566..3ab1380e 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,11 @@ default `client_id` and `client_secret`, `realm`, an application name `appName`, Config Name | Description --- | --- -client_id | Default clientId. MUST be a string -client_secret | Default clientSecret. MUST be a string +client_id | Default clientId. MUST be a string +client_secret | Default clientSecret. MUST be a string realm | realm query parameter (for oauth1) added to `authorizationUrl` and `tokenUrl` . MUST be a string appName | application name, displayed in authorization popup. MUST be a string -scopeSeparator | scope separator for passing scopes, encoded before calling, default value is a space (encoded value `%20`). MUST be a string +scopeSeparator | scope separator for passing scopes, encoded before calling, default value is a space (encoded value `%20`). MUST be a string additionalQueryStringParams | Additional query parameters added to `authorizationUrl` and `tokenUrl`. MUST be an object ``` @@ -117,6 +117,7 @@ operationsSorter | Apply a sort to the operation list of each API. It can be 'al configUrl | Configs URL parameterMacro | MUST be a function. Function to set default value to parameters. Accepts two arguments parameterMacro(operation, parameter). Operation and parameter are objects passed for context, both remain immutable modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable +docExpansion | 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). The default is 'list'. ### Plugins @@ -136,7 +137,7 @@ let preset = [ ``` #### Configs plugin -Configs plugin allows to fetch external configs instead of passing them to `SwaggerUIBundle`. Fetched configs support two formats: JSON or yaml. The plugin is enabled by default. +Configs plugin allows to fetch external configs instead of passing them to `SwaggerUIBundle`. Fetched configs support two formats: JSON or yaml. The plugin is enabled by default. There are three options of passing config: - add a query parameter `config` with URL to a server where the configs are hosted. For ex. http://petstore.swagger.io/?config=http://localhost:3001/config.yaml - add a config `configUrl` with URL to SwaggerUIBundle diff --git a/src/core/components/operation.jsx b/src/core/components/operation.jsx index f6a97b08..0bc2ecc7 100644 --- a/src/core/components/operation.jsx +++ b/src/core/components/operation.jsx @@ -27,7 +27,8 @@ export default class Operation extends React.Component { specSelectors: PropTypes.object.isRequired, layoutActions: PropTypes.object.isRequired, layoutSelectors: PropTypes.object.isRequired, - fn: PropTypes.object.isRequired + fn: PropTypes.object.isRequired, + getConfigs: PropTypes.func.isRequired } static defaultProps = { @@ -76,8 +77,10 @@ export default class Operation extends React.Component { } isShown =() => { - let { layoutSelectors, isShownKey } = this.props - return layoutSelectors.isShown(isShownKey, false ) // Here is where we set the default + let { layoutSelectors, isShownKey, getConfigs } = this.props + let { docExpansion } = getConfigs() + + return layoutSelectors.isShown(isShownKey, docExpansion === "full" ) // Here is where we set the default } onTryoutClick =() => { diff --git a/src/core/components/operations.jsx b/src/core/components/operations.jsx index 6fdfa810..70d2cdd0 100644 --- a/src/core/components/operations.jsx +++ b/src/core/components/operations.jsx @@ -10,6 +10,7 @@ export default class Operations extends React.Component { layoutActions: PropTypes.object.isRequired, authActions: PropTypes.object.isRequired, authSelectors: PropTypes.object.isRequired, + getConfigs: PropTypes.func.isRequired }; static defaultProps = { @@ -25,6 +26,7 @@ export default class Operations extends React.Component { layoutActions, authActions, authSelectors, + getConfigs, fn } = this.props @@ -34,6 +36,7 @@ export default class Operations extends React.Component { const Collapse = getComponent("Collapse") let showSummary = layoutSelectors.showSummary() + let { docExpansion } = getConfigs() return (
@@ -43,7 +46,7 @@ export default class Operations extends React.Component { let tagDescription = tagObj.getIn(["tagDetails", "description"], null) let isShownKey = ["operations-tag", tag] - let showTag = layoutSelectors.isShown(isShownKey, true) + let showTag = layoutSelectors.isShown(isShownKey, docExpansion === "full" || docExpansion === "list") return (
@@ -98,6 +101,7 @@ export default class Operations extends React.Component { getComponent={ getComponent } fn={fn} + getConfigs={ getConfigs } /> }).toArray() }