Skip to content

Commit 859ae1f

Browse files
authored
Merge branch 'master' into bug/3480-model-description-over-the-edge
2 parents ea75edd + bc62c1c commit 859ae1f

17 files changed

+159
-42
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ This repo publishes to two different NPM packages:
1818
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
1919

2020
## Compatibility
21-
The OpenAPI Specification has undergone 4 revisions since initial creation in 2010. Compatibility between swagger-ui and the OpenAPI Specification is as follows:
21+
The OpenAPI Specification has undergone 5 revisions since initial creation in 2010. Compatibility between swagger-ui and the OpenAPI Specification is as follows:
2222

23-
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
24-
------------------ | ------------ | -------------------------- | ----- | ------
25-
3.1.1 | 2017-07-29 | 2.0 | [tag v3.1.1](https://github.com/swagger-api/swagger-ui/tree/v3.1.1) |
26-
2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10) |
27-
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5) |
28-
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
29-
1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13) |
30-
1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1) |
23+
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes
24+
------------------ | ------------ | -------------------------- | -----
25+
3.1.2 | 2017-07-31 | 2.0, 3.0 | [tag v3.1.2](https://github.com/swagger-api/swagger-ui/tree/v3.1.2)
26+
3.0.21 | 2017-07-26 | 2.0 | [tag v3.0.21](https://github.com/swagger-api/swagger-ui/tree/v3.0.21)
27+
2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10)
28+
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5)
29+
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24)
30+
1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13)
31+
1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1)
3132

3233

3334
### How to run
@@ -96,7 +97,8 @@ To use swagger-ui's bundles, you should take a look at the [source of swagger-ui
9697

9798
#### OAuth2 configuration
9899
You can configure OAuth2 authorization by calling `initOAuth` method with passed configs under the instance of `SwaggerUIBundle`
99-
default `client_id` and `client_secret`, `realm`, an application name `appName`, `scopeSeparator`, `additionalQueryStringParams`.
100+
default `client_id` and `client_secret`, `realm`, an application name `appName`, `scopeSeparator`, `additionalQueryStringParams`,
101+
`useBasicAuthenticationWithAccessCodeGrant`.
100102

101103
Config Name | Description
102104
--- | ---
@@ -106,6 +108,7 @@ realm | realm query parameter (for oauth1) added to `authorizationUrl` and `toke
106108
appName | application name, displayed in authorization popup. MUST be a string
107109
scopeSeparator | scope separator for passing scopes, encoded before calling, default value is a space (encoded value `%20`). MUST be a string
108110
additionalQueryStringParams | Additional query parameters added to `authorizationUrl` and `tokenUrl`. MUST be an object
111+
useBasicAuthenticationWithAccessCodeGrant | Only activated for the `accessCode` flow. During the `authorization_code` request to the `tokenUrl`, pass the [Client Password](https://tools.ietf.org/html/rfc6749#section-2.3.1) using the HTTP Basic Authentication scheme (`Authorization` header with `Basic base64encoded[client_id:client_secret]`). The default is `false`
109112

110113
```
111114
const ui = SwaggerUIBundle({...})
@@ -135,6 +138,7 @@ urls.primaryName | When using `urls`, you can use this subparameter. If the valu
135138
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.
136139
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.
137140
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`.
138142
oauth2RedirectUrl | OAuth redirect URL
139143
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.
140144
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swagger-ui",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"main": "dist/swagger-ui.js",
55
"repository": "[email protected]:swagger-api/swagger-ui.git",
66
"contributors": [
@@ -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: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export default class ObjectModel extends Component {
1818

1919
render(){
2020
let { schema, name, isRef, getComponent, depth, ...props } = this.props
21-
let { expandDepth } = this.props
21+
let { expandDepth, specSelectors } = this.props
22+
let { isOAS3 } = specSelectors
2223
let description = schema.get("description")
2324
let properties = schema.get("properties")
2425
let additionalProperties = schema.get("additionalProperties")
@@ -30,14 +31,21 @@ export default class ObjectModel extends Component {
3031
const Model = getComponent("Model")
3132
const ModelCollapse = getComponent("ModelCollapse")
3233

33-
const JumpToPathSection = ({ name }) => <span className="model-jump-to-path"><JumpToPath path={`definitions.${name}`} /></span>
34+
const JumpToPathSection = ({ name }) => {
35+
const path = isOAS3 && isOAS3() ? `components.schemas.${name}` : `definitions.${name}`
36+
return <span className="model-jump-to-path"><JumpToPath path={path} /></span>
37+
}
3438
const collapsedContent = (<span>
3539
<span>{ braceOpen }</span>...<span>{ braceClose }</span>
3640
{
3741
isRef ? <JumpToPathSection name={ name }/> : ""
3842
}
3943
</span>)
40-
44+
45+
const anyOf = specSelectors.isOAS3() ? schema.get("anyOf") : null
46+
const oneOf = specSelectors.isOAS3() ? schema.get("oneOf") : null
47+
const not = specSelectors.isOAS3() ? schema.get("not") : null
48+
4149
const titleEl = title && <span className="model-title">
4250
{ isRef && schema.get("$$ref") && <span className="model-hint">{ schema.get("$$ref") }</span> }
4351
<span className="model-title__text">{ title }</span>
@@ -95,11 +103,53 @@ export default class ObjectModel extends Component {
95103
</td>
96104
</tr>
97105
}
106+
{
107+
!anyOf ? null
108+
: <tr>
109+
<td>{ "anyOf ->" }</td>
110+
<td>
111+
{anyOf.map((schema, k) => {
112+
return <div key={k}><Model { ...props } required={ false }
113+
getComponent={ getComponent }
114+
schema={ schema }
115+
depth={ depth + 1 } /></div>
116+
})}
117+
</td>
118+
</tr>
119+
}
120+
{
121+
!oneOf ? null
122+
: <tr>
123+
<td>{ "oneOf ->" }</td>
124+
<td>
125+
{oneOf.map((schema, k) => {
126+
return <div key={k}><Model { ...props } required={ false }
127+
getComponent={ getComponent }
128+
schema={ schema }
129+
depth={ depth + 1 } /></div>
130+
})}
131+
</td>
132+
</tr>
133+
}
134+
{
135+
!not ? null
136+
: <tr>
137+
<td>{ "not ->" }</td>
138+
<td>
139+
{not.map((schema, k) => {
140+
return <div key={k}><Model { ...props } required={ false }
141+
getComponent={ getComponent }
142+
schema={ schema }
143+
depth={ depth + 1 } /></div>
144+
})}
145+
</td>
146+
</tr>
147+
}
98148
</tbody></table>
99149
}
100150
</span>
101151
<span className="brace-close">{ braceClose }</span>
102152
</ModelCollapse>
103153
</span>
104154
}
105-
}
155+
}

src/core/components/operation.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export default class Operation extends PureComponent {
186186
}
187187
</div>
188188

189-
<Collapse isOpened={shown} animated>
189+
<Collapse isOpened={shown}>
190190
<div className="opblock-body">
191191
{ deprecated && <h4 className="opblock-title_normal"> Warning: Deprecated</h4>}
192192
{ description &&

src/core/components/operations.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export default class Operations extends React.Component {
6666
taggedOps.map( (tagObj, tag) => {
6767
let operations = tagObj.get("operations")
6868
let tagDescription = tagObj.getIn(["tagDetails", "description"], null)
69+
let tagExternalDocsDescription = tagObj.getIn(["tagDetails", "externalDocs", "description"])
70+
let tagExternalDocsUrl = tagObj.getIn(["tagDetails", "externalDocs", "url"])
6971

7072
let isShownKey = ["operations-tag", tag]
7173
let showTag = layoutSelectors.isShown(isShownKey, docExpansion === "full" || docExpansion === "list")
@@ -89,6 +91,22 @@ export default class Operations extends React.Component {
8991
</small>
9092
}
9193

94+
<div>
95+
{ !tagExternalDocsDescription ? null :
96+
<small>
97+
{ tagExternalDocsDescription }
98+
{ tagExternalDocsUrl ? ": " : null }
99+
{ tagExternalDocsUrl ?
100+
<a
101+
href={tagExternalDocsUrl}
102+
onClick={(e) => e.stopPropagation()}
103+
target={"_blank"}
104+
>{tagExternalDocsUrl}</a> : null
105+
}
106+
</small>
107+
}
108+
</div>
109+
92110
<button className="expand-operation" title="Expand operation" onClick={() => layoutActions.show(isShownKey, !showTag)}>
93111
<svg className="arrow" width="20" height="20">
94112
<use xlinkHref={showTag ? "#large-arrow-down" : "#large-arrow"} />

0 commit comments

Comments
 (0)