Compare commits

...
62 Commits
Author SHA1 Message Date
Kyle 2099ca09e6 Merge pull request #3526 from shockey/v/3.1.3
v3.1.3
2017-08-04 21:46:20 -07:00
Kyle Shockey 95b7adc246 Rebuild dist 2017-08-04 21:38:57 -07:00
Kyle Shockey 4b0b51ab6e v3.1.3 2017-08-04 21:36:13 -07:00
Kyle 08b1f88557 Merge pull request #3354 from owenconti/bug/2903-wrong-font-for-error
Fixes #2903 - Wrong font for errors
2017-08-04 16:41:00 -07:00
Kyle b7575ed8a5 Merge branch 'master' into bug/2903-wrong-font-for-error 2017-08-04 16:37:17 -07:00
Kyle 73662c0aec Merge pull request #3514 from owenconti/bug/3505-schema-title-in-array-schemes
Fixes #3505 - Choose modelName before name in Model component
2017-08-04 16:37:11 -07:00
Kyle dc4e60170d Merge branch 'master' into bug/3505-schema-title-in-array-schemes 2017-08-04 16:33:14 -07:00
Kyle 6af2aae26f Merge pull request #3509 from owenconti/bug/3500-missing-name-for-primitives
Fixes #3500 - Fix missing names for primitive models
2017-08-04 16:32:48 -07:00
Kyle 719db39ac4 Merge branch 'master' into bug/3500-missing-name-for-primitives 2017-08-04 16:27:35 -07:00
Kyle 0113703e16 Merge pull request #3488 from owenconti/bug/3480-model-description-over-the-edge
Fixes #3480 - Overflowing model description.
2017-08-04 16:27:26 -07:00
Kyle 19e09c2296 Merge branch 'master' into bug/3500-missing-name-for-primitives 2017-08-04 16:27:25 -07:00
Kyle 859ae1fd19 Merge branch 'master' into bug/3480-model-description-over-the-edge 2017-08-04 16:23:50 -07:00
Kyle bc62c1c751 Merge pull request #3524 from shockey/bug/3458-oas3-parameter-deprecation
Indicate parameter deprecation
2017-08-04 16:15:02 -07:00
Kyle Shockey 35733b5eb4 Indicate parameter deprecation 2017-08-04 15:39:48 -07:00
Kyle 2733205481 Merge pull request #3522 from swagger-api/ft/oas3
Removed animation as temporary fix
2017-08-04 14:53:52 -07:00
Kyle 0a20d724db Merge branch 'master' into ft/oas3 2017-08-04 14:45:29 -07:00
Minasokoni 758a229ac4 removed animation as temporary fix 2017-08-04 01:43:07 -07:00
Kyle 8633372270 Merge pull request #3519 from shockey/bug/editor-1418-oas3-jump-to-model
Create valid paths for model jumping in OAS3
2017-08-03 16:26:31 -07:00
Kyle c664e39908 Update object-model.jsx 2017-08-03 16:22:42 -07:00
Kyle c72c476f4b Merge branch 'master' into bug/editor-1418-oas3-jump-to-model 2017-08-03 16:17:39 -07:00
Kyle Shockey b16907ce6d Create valid paths for model jumping in OAS3 2017-08-03 16:15:47 -07:00
Anna 6233886983 Merge pull request #3481 from domanchi/master
Removing CORS header in request
2017-08-03 17:47:35 +03:00
Aaron Loo 700d547529 merge master 2017-08-03 07:32:32 -07:00
Kyle 103aaa54d5 Merge branch 'master' into bug/3505-schema-title-in-array-schemes 2017-08-02 20:55:24 -07:00
Kyle f375afc742 Merge pull request #3501 from oysteinsigholt/master
Fixes #3492 - Add domNode parameter
2017-08-02 17:10:25 -07:00
Kyle faafe372bd Merge branch 'master' into master 2017-08-02 17:06:49 -07:00
Kyle cd422fe8a7 Merge pull request #3513 from shockey/ft/3490-anyof-oneof-not-models
Support oneOf, anyOf, not
2017-08-02 16:49:39 -07:00
Kyle 2d00766c10 Merge branch 'master' into ft/3490-anyof-oneof-not-models 2017-08-02 16:41:16 -07:00
Owen Conti fb5443601e Fixes #3505 - Choose modelName before name in Model component 2017-08-02 17:39:56 -06:00
Kyle Shockey 4cd88d3360 Support oneOf + anyOf + not 2017-08-02 16:37:57 -07:00
Kyle b8cf502cfc Merge branch 'master' into master 2017-08-02 15:58:34 -07:00
Kyle ab53122271 Merge pull request #3512 from Raincal/patch-1
Remove a duplicate package
2017-08-02 15:56:31 -07:00
Raincal 92e5f4f100 Remove a duplicate package 2017-08-02 11:16:59 -05:00
Ron ad8bad6ddc Merge pull request #3508 from shockey/ft/3397-tags-external-docs
Display tag externalDocs
2017-08-01 22:03:56 -07:00
Kyle c2a1fa9d8f Merge branch 'master' into bug/3500-missing-name-for-primitives 2017-08-01 19:59:28 -07:00
Owen Conti d64dfc4252 Fixes #3500 - Fix missing names for primitive models 2017-08-01 20:46:41 -06:00
Kyle 7c8467652e Merge branch 'master' into ft/3397-tags-external-docs 2017-08-01 19:39:39 -07:00
Kyle Shockey c29e05d726 Display tag externalDocs 2017-08-01 19:34:56 -07:00
Kyle ad4cec0f1f Merge pull request #3380 from TheClimateCorporation/support-basic-auth-for-authorization-code-grant
Support basic auth for authorization code grant
2017-08-01 17:05:12 -07:00
Kyle 470cfe5cad Merge branch 'master' into support-basic-auth-for-authorization-code-grant 2017-08-01 16:57:13 -07:00
Kyle 7927d85e15 Merge pull request #3507 from swagger-api/shockey-patch-1
MOAR OpenAPI specification revisions
2017-08-01 16:56:58 -07:00
Kyle 88a6e075dd Remove useBasicAuthenticationWithAccessCodeGrant
... from `initOAuth` example
2017-08-01 16:54:30 -07:00
Kyle b329b03464 Merge branch 'master' into support-basic-auth-for-authorization-code-grant 2017-08-01 16:52:04 -07:00
shockey 53c11700ba MOAR OpenAPI specification revisions 2017-08-01 16:41:16 -07:00
oysteinsigholt 230f4a8467 add domNode parameter 2017-08-01 11:11:10 +02:00
shockey 6b1d78c6a6 Merge pull request #3497 from shockey/3.1.2-dist-updates
3.1.2: Rebuild dist
2017-07-31 17:32:11 -07:00
Kyle Shockey 0051140fc8 Rebuild dist 2017-07-31 17:25:48 -07:00
Owen Conti ea75eddcfb Fixes #3480
Change margin-left to padding-left on '&:first-of-type' table cells. Adjust width of table cell to account for padding.
2017-07-30 16:22:49 -06:00
Aaron Loo a04c6240fb Merge branch 'master' of https://github.com/swagger-api/swagger-ui 2017-07-28 10:20:15 -07:00
Aaron Loo 893d0b2cbf updating dist 2017-07-28 10:19:45 -07:00
Aaron Loo 860d356178 remove CORS header in request 2017-07-28 10:15:05 -07:00
shockey 71abda66ec Merge branch 'master' into bug/2903-wrong-font-for-error 2017-07-21 20:17:18 -07:00
shockey 4f1772f654 Merge branch 'master' into bug/2903-wrong-font-for-error 2017-07-21 19:19:44 -07:00
Owen Conti 24882b69a8 File formatting fixes 2017-07-17 21:15:05 -06:00
Owen Conti 0622bd7179 Revert changes based on @Minasokoni's suggestion 2017-07-17 21:09:25 -06:00
Owen Conti 54b867a9bc Merge branch 'master' into bug/2903-wrong-font-for-error
# Conflicts:
#	dev-helpers/index.html
2017-07-17 18:51:04 -06:00
Eric Turcotte a09e0b8b4a Removed semicolon 2017-07-13 11:16:47 -05:00
Eric Turcotte badfea61c3 Renamed authorizeAccessCodeWithQueryParams->authorizeAccessCodeWithFormParams
since that is technically correct
2017-07-13 10:53:36 -05:00
Eric Turcotte b06971bf81 If config useBasicAuthenticationWithAccessCodeGrant is truthy, send client id
and secret as HTTP basic auth during authorization_code grant
2017-07-12 23:35:34 -05:00
Eric Turcotte fc8ad8168d Renamed authorizeAccessCode() to authorizeAccessCodeWithQueryParams()
Added authorizeAccessCodeWithBasicAuthentication() that sends the client_id and
client_secret using HTTP basic authentication

    Authorization: Basic base64encoded[client_id:client_secret]

According to the OAuth2 spec, this is the preferred method.  It also enables
Authorization Servers that only support basic authentication during the
authorization_code grant.

https://tools.ietf.org/html/rfc6749#section-2.3.1
2017-07-12 23:32:29 -05:00
Owen Conti 5de1689946 Remove embedded styles from index.html files 2017-07-08 11:34:55 -06:00
Owen Conti 48f11a172a Fixes #2903 - Fix CSS imports so body and html styles are included from .scss files. Update body selector to have a font-family 2017-07-08 11:33:34 -06:00
26 changed files with 200 additions and 98 deletions
+6 -3
View File
@@ -18,11 +18,11 @@ This repo publishes to two different NPM packages:
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
## Compatibility
The OpenAPI Specification has undergone 4 revisions since initial creation in 2010. Compatibility between swagger-ui and the OpenAPI Specification is as follows:
The OpenAPI Specification has undergone 5 revisions since initial creation in 2010. Compatibility between swagger-ui and the OpenAPI Specification is as follows:
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes
------------------ | ------------ | -------------------------- | -----
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)
3.1.3 | 2017-08-04 | 2.0, 3.0 | [tag v3.1.3](https://github.com/swagger-api/swagger-ui/tree/v3.1.3)
3.0.21 | 2017-07-26 | 2.0 | [tag v3.0.21](https://github.com/swagger-api/swagger-ui/tree/v3.0.21)
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)
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)
@@ -97,7 +97,8 @@ To use swagger-ui's bundles, you should take a look at the [source of swagger-ui
#### OAuth2 configuration
You can configure OAuth2 authorization by calling `initOAuth` method with passed configs under the instance of `SwaggerUIBundle`
default `client_id` and `client_secret`, `realm`, an application name `appName`, `scopeSeparator`, `additionalQueryStringParams`.
default `client_id` and `client_secret`, `realm`, an application name `appName`, `scopeSeparator`, `additionalQueryStringParams`,
`useBasicAuthenticationWithAccessCodeGrant`.
Config Name | Description
--- | ---
@@ -107,6 +108,7 @@ realm | realm query parameter (for oauth1) added to `authorizationUrl` and `toke
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
additionalQueryStringParams | Additional query parameters added to `authorizationUrl` and `tokenUrl`. MUST be an object
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`
```
const ui = SwaggerUIBundle({...})
@@ -136,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.
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.
domNode | The HTML DOM element inside which SwaggerUi will put the user interface for swagger. Overrides `dom_id`.
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.
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.
-1
View File
@@ -21,7 +21,6 @@
{
box-sizing: inherit;
}
body {
margin:0;
background: #fafafa;
+4 -4
View File
@@ -11,15 +11,15 @@
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
box-sizing: inherit;
}
body {
+11 -11
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAoyKA;;;;;;AAy+EA;;;;;;;;;;;;;;;;;;;;;;;;;;AA00TA;;;;;;;;;;;;;;AAs8JA;;;;;;;;;AA+5oBA;;;;;AA2lQA;AAm4DA;;;;;;AAo4YA;;;;;;AA0iaA;AAumvBA","sourceRoot":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAoyKA;;;;;;AAy+EA;;;;;;;;;;;;;;;;;;;;;;;;;;AAw1TA;;;;;;;;;;;;;;AAs8JA;;;;;;;;;AAw6oBA;;;;;AAgrQA;AAm4DA;;;;;;AAo4YA;;;;;;AA8jaA;AAumvBA","sourceRoot":""}
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAwpcA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAmwcA","sourceRoot":""}
+1 -2
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.1.2",
"version": "3.1.3",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -43,7 +43,6 @@
"ieee754": "^1.1.8",
"immutable": "^3.x.x",
"js-yaml": "^3.5.5",
"less": "2.7.1",
"lodash": "4.17.2",
"matcher": "^0.1.2",
"memoizee": "0.4.1",
+2 -3
View File
@@ -15,7 +15,7 @@ export default class ArrayModel extends Component {
}
render(){
let { getComponent, required, schema, depth, expandDepth, name } = this.props
let { getComponent, schema, depth, expandDepth, name } = this.props
let items = schema.get("items")
let title = schema.get("title") || name
let properties = schema.filter( ( v, key) => ["type", "items", "$$ref"].indexOf(key) === -1 )
@@ -31,7 +31,7 @@ export default class ArrayModel extends Component {
return <span className="model">
<ModelCollapse title={titleEl} collapsed={ depth > expandDepth } collapsedContent="[...]">
[
<span><Model { ...this.props } schema={ items } required={ false }/></span>
<span><Model { ...this.props } schema={ items } required={ false } depth={ depth + 1 } /></span>
]
{
properties.size ? <span>
@@ -41,7 +41,6 @@ export default class ArrayModel extends Component {
: null
}
</ModelCollapse>
{ required && <span style={{ color: "red" }}>*</span>}
</span>
}
}
+4 -4
View File
@@ -55,14 +55,14 @@ export default class Model extends Component {
return <ObjectModel
className="object" { ...this.props }
schema={ modelSchema }
name={ name || modelName }
name={ modelName || name }
deprecated={deprecated}
isRef={ isRef!== undefined ? isRef : !!$$ref } />
case "array":
return <ArrayModel
className="array" { ...this.props }
schema={ modelSchema }
name={ name || modelName }
name={ modelName || name }
deprecated={deprecated}
required={ required } />
case "string":
@@ -74,8 +74,8 @@ export default class Model extends Component {
{ ...this.props }
getComponent={ getComponent }
schema={ modelSchema }
name={ name || modelName }
name={ modelName || name }
deprecated={deprecated}
required={ required }/> }
required={ required }/> }
}
}
+56 -6
View File
@@ -17,8 +17,9 @@ export default class ObjectModel extends Component {
}
render(){
let { schema, name, isRef, getComponent, depth, ...props } = this.props
let { expandDepth } = this.props
let { schema, name, isRef, getComponent, depth, expandDepth, specSelectors, ...props } = this.props
let { isOAS3 } = specSelectors
let description = schema.get("description")
let properties = schema.get("properties")
let additionalProperties = schema.get("additionalProperties")
@@ -30,14 +31,21 @@ export default class ObjectModel extends Component {
const Model = getComponent("Model")
const ModelCollapse = getComponent("ModelCollapse")
const JumpToPathSection = ({ name }) => <span className="model-jump-to-path"><JumpToPath path={`definitions.${name}`} /></span>
const JumpToPathSection = ({ name }) => {
const path = isOAS3 && isOAS3() ? `components.schemas.${name}` : `definitions.${name}`
return <span className="model-jump-to-path"><JumpToPath path={path} /></span>
}
const collapsedContent = (<span>
<span>{ braceOpen }</span>...<span>{ braceClose }</span>
{
isRef ? <JumpToPathSection name={ name }/> : ""
}
</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">
{ isRef && schema.get("$$ref") && <span className="model-hint">{ schema.get("$$ref") }</span> }
<span className="model-title__text">{ title }</span>
@@ -51,7 +59,7 @@ export default class ObjectModel extends Component {
}
<span className="inner-object">
{
<table className="model" style={{ marginLeft: "2em" }}><tbody>
<table className="model"><tbody>
{
!description ? null : <tr style={{ color: "#999", fontStyle: "italic" }}>
<td>description:</td>
@@ -95,6 +103,48 @@ export default class ObjectModel extends Component {
</td>
</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>
}
</span>
@@ -102,4 +152,4 @@ export default class ObjectModel extends Component {
</ModelCollapse>
</span>
}
}
}
+1 -1
View File
@@ -186,7 +186,7 @@ export default class Operation extends PureComponent {
}
</div>
<Collapse isOpened={shown} animated>
<Collapse isOpened={shown}>
<div className="opblock-body">
{ deprecated && <h4 className="opblock-title_normal"> Warning: Deprecated</h4>}
{ description &&
+18
View File
@@ -66,6 +66,8 @@ export default class Operations extends React.Component {
taggedOps.map( (tagObj, tag) => {
let operations = tagObj.get("operations")
let tagDescription = tagObj.getIn(["tagDetails", "description"], null)
let tagExternalDocsDescription = tagObj.getIn(["tagDetails", "externalDocs", "description"])
let tagExternalDocsUrl = tagObj.getIn(["tagDetails", "externalDocs", "url"])
let isShownKey = ["operations-tag", tag]
let showTag = layoutSelectors.isShown(isShownKey, docExpansion === "full" || docExpansion === "list")
@@ -89,6 +91,22 @@ export default class Operations extends React.Component {
</small>
}
<div>
{ !tagExternalDocsDescription ? null :
<small>
{ tagExternalDocsDescription }
{ tagExternalDocsUrl ? ": " : null }
{ tagExternalDocsUrl ?
<a
href={tagExternalDocsUrl}
onClick={(e) => e.stopPropagation()}
target={"_blank"}
>{tagExternalDocsUrl}</a> : null
}
</small>
}
</div>
<button className="expand-operation" title="Expand operation" onClick={() => layoutActions.show(isShownKey, !showTag)}>
<svg className="arrow" width="20" height="20">
<use xlinkHref={showTag ? "#large-arrow-down" : "#large-arrow"} />
+5
View File
@@ -58,6 +58,8 @@ export default class ParameterRow extends Component {
render() {
let {param, onChange, getComponent, isExecute, fn, onChangeConsumes, specSelectors, pathMethod} = this.props
let { isOAS3 } = specSelectors
// const onChangeWrapper = (value) => onChange(param, value)
const JsonSchemaForm = getComponent("JsonSchemaForm")
const ParamBody = getComponent("ParamBody")
@@ -95,6 +97,9 @@ export default class ParameterRow extends Component {
{ !required ? null : <span style={{color: "red"}}>&nbsp;*</span> }
</div>
<div className="parameter__type">{ param.get("type") } { itemType && `[${itemType}]` }</div>
<div className="parameter__deprecated">
{ isOAS3 && isOAS3() && param.get("deprecated") ? "deprecated": null }
</div>
<div className="parameter__in">({ param.get("in") })</div>
</td>
+28 -25
View File
@@ -7,11 +7,12 @@ export default class Primitive extends Component {
static propTypes = {
schema: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired,
required: PropTypes.bool
name: PropTypes.string,
depth: PropTypes.number
}
render(){
let { schema, getComponent, required } = this.props
let { schema, getComponent, name, depth } = this.props
if(!schema || !schema.get) {
// don't render if schema isn't correctly formed
@@ -24,32 +25,34 @@ export default class Primitive extends Component {
let enumArray = schema.get("enum")
let description = schema.get("description")
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
let style = required ? { fontWeight: "bold" } : {}
const Markdown = getComponent("Markdown")
const EnumModel = getComponent("EnumModel")
return <span className="prop">
<span className="prop-type" style={ style }>{ type }</span> { required && <span style={{ color: "red" }}>*</span>}
{ format && <span className="prop-format">(${format})</span>}
{
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={ propStyle }>
<br />{ key }: { String(v) }</span>)
: null
}
{
!description ? null :
<Markdown source={ description } />
}
{
xml && xml.size ? (<span><br /><span style={ propStyle }>xml:</span>
{
xml.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={ propStyle }><br/>&nbsp;&nbsp;&nbsp;{key}: { String(v) }</span>).toArray()
}
</span>): null
}
{
enumArray && <EnumModel value={ enumArray } getComponent={ getComponent } />
}
return <span className="model">
<span className="prop">
{ name && <span className={`${depth === 1 && "model-title"} prop-name`}>{ name }</span> }
<span className="prop-type">{ type }</span>
{ format && <span className="prop-format">(${format})</span>}
{
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={ propStyle }>
<br />{ key }: { String(v) }</span>)
: null
}
{
!description ? null :
<Markdown source={ description } />
}
{
xml && xml.size ? (<span><br /><span style={ propStyle }>xml:</span>
{
xml.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={ propStyle }><br/>&nbsp;&nbsp;&nbsp;{key}: { String(v) }</span>).toArray()
}
</span>): null
}
{
enumArray && <EnumModel value={ enumArray } getComponent={ getComponent } />
}
</span>
</span>
}
}
+13 -3
View File
@@ -23,6 +23,7 @@ module.exports = function SwaggerUI(opts) {
const defaults = {
// Some general settings, that we floated to the top
dom_id: null,
domNode: null,
spec: {},
url: "",
urls: null,
@@ -99,6 +100,12 @@ module.exports = function SwaggerUI(opts) {
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
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)
if (fetchedConfig !== null) {
@@ -112,10 +119,13 @@ module.exports = function SwaggerUI(opts) {
}
}
if(mergedConfig.dom_id) {
system.render(mergedConfig.dom_id, "App")
if(mergedConfig.domNode) {
system.render(mergedConfig.domNode, "App")
} else if(mergedConfig.dom_id) {
let domNode = document.querySelector(mergedConfig.dom_id)
system.render(domNode, "App")
} else {
console.error("Skipped rendering: no `dom_id` was specified")
console.error("Skipped rendering: no `dom_id` or `domNode` was specified")
}
return system
+11 -1
View File
@@ -68,11 +68,21 @@ export default function authorize ( { auth, authActions, errActions, configs, au
// pass action authorizeOauth2 and authentication data through window
// to authorize with oauth2
let callback
if (flow === "implicit") {
callback = authActions.preAuthorizeImplicit
} else if (authConfigs.useBasicAuthenticationWithAccessCodeGrant) {
callback = authActions.authorizeAccessCodeWithBasicAuthentication
} else {
callback = authActions.authorizeAccessCodeWithFormParams
}
win.swaggerUIRedirectOauth2 = {
auth: auth,
state: state,
redirectUrl: redirectUrl,
callback: flow === "implicit" ? authActions.preAuthorizeImplicit : authActions.authorizeAccessCode,
callback: callback,
errCb: errActions.newAuthErr
}
+16 -2
View File
@@ -111,7 +111,7 @@ export const authorizeApplication = ( auth ) => ( { authActions } ) => {
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers })
}
export const authorizeAccessCode = ( { auth, redirectUrl } ) => ( { authActions } ) => {
export const authorizeAccessCodeWithFormParams = ( { auth, redirectUrl } ) => ( { authActions } ) => {
let { schema, name, clientId, clientSecret } = auth
let form = {
grant_type: "authorization_code",
@@ -124,6 +124,21 @@ export const authorizeAccessCode = ( { auth, redirectUrl } ) => ( { authActions
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth})
}
export const authorizeAccessCodeWithBasicAuthentication = ( { auth, redirectUrl } ) => ( { authActions } ) => {
let { schema, name, clientId, clientSecret } = auth
let headers = {
Authorization: "Basic " + btoa(clientId + ":" + clientSecret)
}
let form = {
grant_type: "authorization_code",
code: auth.code,
client_id: clientId,
redirect_uri: redirectUrl
}
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers})
}
export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, authSelectors } ) => {
let { body, query={}, headers={}, name, url, auth } = data
let { additionalQueryStringParams } = authSelectors.getConfigs() || {}
@@ -135,7 +150,6 @@ export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, aut
let _headers = Object.assign({
"Accept":"application/json, text/plain, */*",
"Access-Control-Allow-Origin": "*",
"Content-Type": "application/x-www-form-urlencoded"
}, headers)
@@ -3,7 +3,6 @@ import PropTypes from "prop-types"
import { OAS3ComponentWrapFactory } from "../helpers"
import { Model } from "core/components/model"
class ModelComponent extends Component {
static propTypes = {
schema: PropTypes.object.isRequired,
+1 -2
View File
@@ -58,8 +58,7 @@ export const makeMappedContainer = (getSystem, getStore, memGetComponent, getCom
}
export const render = (getSystem, getStore, getComponent, getComponents, dom) => {
let domNode = document.querySelector(dom)
export const render = (getSystem, getStore, getComponent, getComponents, domNode) => {
let App = (getComponent(getSystem, getStore, getComponents, "App", "root"))
ReactDOM.render(( <App/> ), domNode)
}
-19
View File
@@ -1,21 +1,3 @@
html
{
box-sizing: border-box;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body
{
margin: 0;
background: #fafafa;
}
.wrapper
{
width: 100%;
@@ -699,7 +681,6 @@ body
.renderedMarkdown {
p {
@include text_body();
font-size: 14px;
margin-top: 0px;
margin-bottom: 0px;
}
+6 -2
View File
@@ -227,8 +227,6 @@ span
{
> span.model
{
padding: 0 0 0 10px;
.brace-close
{
padding: 0 0 0 10px;
@@ -236,6 +234,12 @@ span
}
}
.prop-name
{
display: inline-block;
width: 100px;
}
.prop-type
{
color: #55a;
+10 -2
View File
@@ -19,8 +19,8 @@ table
&:first-of-type
{
width: 100px;
padding: 0;
width: 124px;
padding: 0 0 0 2em;
}
}
}
@@ -138,6 +138,14 @@ table
@include text_code(#888);
}
.parameter__deprecated
{
font-size: 12px;
font-style: italic;
@include text_code(#f00);
}
.table-container
{
+1
View File
@@ -14,5 +14,6 @@
@import 'information';
@import 'authorize';
@import 'errors';
@include text_body();
@import 'split-pane-mode';
}