Compare commits

...
149 Commits
Author SHA1 Message Date
shockey ebe9f9b7f4 Merge pull request #3252 from shockey/v/3.0.15
v/3.0.15
2017-06-16 19:26:29 -07:00
shockey 344f28bf22 Fix README typo
nano is questionable.
2017-06-16 19:23:44 -07:00
Kyle Shockey 556ff037dc Rebuild dist 2017-06-16 19:20:08 -07:00
Kyle Shockey 754a93c14e Version bump 2017-06-16 19:10:15 -07:00
shockey eccc26da1b Merge pull request #3236 from mhw/fix-model-markdown
Render Markdown for object and property descriptions
2017-06-16 17:09:31 -07:00
shockey 99600df0f1 Merge branch 'master' into fix-model-markdown 2017-06-16 13:52:32 -07:00
shockey 1cab4984e0 Merge pull request #3250 from GSokol/#2946_FIX
#2946 Fix
2017-06-16 13:02:05 -07:00
sokol acff34e1d4 #2946 Fix CR fix 2017-06-16 21:14:00 +03:00
sokol 129129be97 #2946 Fix 2017-06-16 18:16:46 +03:00
shockey 00745bca38 Merge pull request #3211 from dwickern/multipart-file-upload
Fix #2922: file uploads fail to render curl command
2017-06-13 16:15:45 -07:00
shockey 1bd1190749 Merge branch 'master' into multipart-file-upload 2017-06-13 16:08:19 -07:00
shockey 667976ca67 Merge pull request #3238 from mhw/fix-response-json-indentation
Indent JSON examples.
2017-06-13 15:57:47 -07:00
Ron 0345f66ee2 Merge branch 'master' into fix-response-json-indentation 2017-06-13 15:45:16 -07:00
Mark H. Wilkinson 7d24a95d78 Indent JSON examples. 2017-06-13 23:07:44 +01:00
shockey ce16666b57 Merge branch 'master' into fix-model-markdown 2017-06-13 12:09:58 -07:00
shockey 3cfda13cfe Merge pull request #3076 from furkanayhan/show_actual_error_response
Show actual error response when trying
2017-06-13 11:34:02 -07:00
shockey a54d6fa2bc Merge branch 'master' into show_actual_error_response 2017-06-13 10:36:41 -07:00
Mark H. Wilkinson c24a07c523 Render primitive property descriptions as Markdown. 2017-06-13 17:15:59 +01:00
Mark H. Wilkinson db57ee0dfe Render object descriptions as Markdown. 2017-06-13 17:13:33 +01:00
shockey 99a525eac2 Merge pull request #3218 from dylancwood/chore-dist-dir
Add absolutePath to swagger-ui-dist exports
2017-06-12 23:18:37 -07:00
shockey 3e71861712 Merge branch 'master' into chore-dist-dir 2017-06-12 23:15:21 -07:00
shockey 5f8ffb870c Add function invocation to method example 2017-06-12 23:14:00 -07:00
Dylan 3311f3e95f export getAbsoluteFSPath method instead of property 2017-06-12 22:21:47 -07:00
shockey b5b00953e9 Merge pull request #3230 from shockey/rebuild
Rebuild dist
2017-06-12 15:25:42 -07:00
Kyle Shockey 873cb2892f Rebuild dist 2017-06-12 15:21:17 -07:00
Dylan df149c543b make dist absolutePath browser-safe, add test 2017-06-10 15:59:21 -07:00
Dylan d6d5b1d06e add documentation of absolutePath as well as npm version badge 2017-06-10 15:59:21 -07:00
Dylan 234e6d5d57 add absolutePath to swagger-ui-dist 2017-06-10 15:59:21 -07:00
shockey 212396f24d Merge pull request #3223 from swagger-api/readme-patch
Fix README.md
2017-06-09 22:14:17 -07:00
shockey f4a253461e Create README.md 2017-06-09 21:49:45 -07:00
shockey f23b7044c8 Merge pull request #3222 from shockey/v/3.0.14
v3.0.14, second edition...
2017-06-09 21:37:44 -07:00
Kyle Shockey d043f0e7af Bump version 2017-06-09 21:30:55 -07:00
shockey 72cbcc69e8 Merge pull request #3221 from shockey/v/3.0.14
v/3.0.14
2017-06-09 21:02:05 -07:00
Kyle Shockey e3fa724f87 Rebuild dist 2017-06-09 20:56:33 -07:00
Kyle Shockey 811a0a10e3 v3.0.14 2017-06-09 20:39:50 -07:00
Kyle Shockey 0ab6fde25f Remove problematic package-lock.json (for now) 2017-06-09 20:37:47 -07:00
Tony Tam 99c03cf3bb Merge pull request #3179 from franzwong/master
Copy swagger.json to nginx directory
2017-06-09 11:47:20 -07:00
Tony Tam 071307c61e Merge branch 'master' into master 2017-06-09 11:40:50 -07:00
Tony Tam 08c691894d extract basename from $SWAGGER_JSON file 2017-06-09 11:40:33 -07:00
Furkan Ayhan b3e476f476 Show actual error response when trying 2017-06-09 10:25:28 +03:00
Derek Wickern c5a23e584c Fix #2922: file uploads fail to render curl command
The request body is an immutable.js OrderedMap rather than a string,
so this fixes the type error:

  TypeError: request.get(...).split is not a function

Adds a special curl command argument for files, e.g.

  curl -F "param=value" -F "file=@filename.txt;type=text/plain"
2017-06-08 15:59:41 -07:00
Tony Tam f6e921f101 Merge pull request #3053 from Yasami/docker-run.sh-eol-lf
Force line endings of docker-run.sh to Unix-style
2017-06-08 13:22:36 -07:00
Tony Tam 6defee4402 Merge branch 'master' into docker-run.sh-eol-lf 2017-06-08 13:16:29 -07:00
Ron d980982942 Merge pull request #3210 from dylancwood/chore-swagger-ui-dist-docs
Documentation: clarify the two different npm packages available
2017-06-08 13:04:25 -07:00
Ron 30686d6975 Merge branch 'master' into chore-swagger-ui-dist-docs 2017-06-08 13:01:29 -07:00
Ron 07076d6064 Merge pull request #3125 from micmro/update-alpine
update Docker base-image to alpine 3.5
2017-06-08 12:57:05 -07:00
Tony Tam 5e6103f0cb Merge branch 'master' into update-alpine 2017-06-08 12:53:50 -07:00
Ron 5a1f824c21 Merge branch 'master' into docker-run.sh-eol-lf 2017-06-08 12:49:43 -07:00
Ron 284f187253 Merge branch 'master' into chore-swagger-ui-dist-docs 2017-06-08 12:24:01 -07:00
Dylan 531e5d1d73 clarify the two different npm packages available for this repo 2017-06-08 12:03:38 -07:00
Anna 60a9dc490f Merge pull request #3207 from bodnia/fix-3191
fixes #3191
2017-06-08 15:46:16 +03:00
Anna Bodnia ee2e82390b fixes #3191 2017-06-08 15:41:06 +03:00
Anna 1dedd44324 Merge pull request #3206 from bodnia/fixes-3172
#3172 added Access-Control-Allow-Origin for auth requests
2017-06-08 14:14:06 +03:00
Anna Bodnia bbf93c5e1f #3172 added Access-Control-Allow-Origin for auth requests 2017-06-08 14:06:30 +03:00
Anna e2b2055b4b Merge pull request #3204 from bodnia/fix-3172
fixes #3172
2017-06-08 12:32:44 +03:00
Anna Bodnia 36b263e230 fixes #3172 2017-06-08 12:19:47 +03:00
shockey e7975e7f3d Merge pull request #3200 from shockey/bug/3199-sanitization-escaping
Markdown quote double-escaping
2017-06-07 13:00:42 -07:00
Kyle Shockey a9d4f5efde Add filter to un-double-escape quotation marks 2017-06-07 12:52:59 -07:00
Kyle Shockey 3189e6101b Fix eslint quotes rule 2017-06-07 12:52:50 -07:00
Kyle Shockey 8919661438 Add failing test 2017-06-07 12:52:35 -07:00
Ron e8d84c02e6 Merge pull request #3195 from gwynjudd/model-expansion
Add support for docExpansion flag to models
2017-06-06 22:51:49 -07:00
shockey 4f7e75f443 Add propTypes validation for getConfig 2017-06-06 22:39:46 -07:00
Gwyn Judd 2d0c660d9f Add support for docExpansion flag to models
Show a more compressed view if docExpansion is set to "none"
2017-06-07 12:26:48 +12:00
shockey 4038b11d69 Merge pull request #3193 from shockey/operation-id-tweaks
CSS fixes for operationId display
2017-06-06 12:13:14 -07:00
Kyle Shockey 97ab51c354 CSS fixes for operationId display 2017-06-06 12:07:37 -07:00
shockey 0fdaeff5e8 Merge pull request #3152 from slate-studio/master
Add operationId to be shown for each operation
2017-06-06 11:36:48 -07:00
Artem 36aa568f0e Update README 2017-06-06 21:30:13 +03:00
shockey c05b66f4d4 Remove displayOperationId as prop to Operations
This appears to be a mistake. Operations should get `displayOperationId` from `getConfigs`, not from a prop.
2017-06-06 11:28:27 -07:00
shockey 68974a95b2 Use destructuring synyax to get displayOperationId 2017-06-06 11:18:42 -07:00
shockey c03210e7d4 Merge branch 'master' into master 2017-06-06 10:48:19 -07:00
Ron e5a9571a72 Merge pull request #3190 from swagger-api/fix-readme
Update README.md
2017-06-06 09:14:56 -07:00
Ron 58acaf681d Update README.md 2017-06-06 09:06:12 -07:00
Artem 78af4e7f9f Merge branch 'operationId'
# Conflicts:
#	src/core/components/operation.jsx
2017-06-06 17:23:04 +03:00
Artem e3f872ad63 Display operationId 2017-06-06 17:21:20 +03:00
Franz Wong 58797025c6 Merge branch 'master' into master 2017-06-06 19:45:35 +09:00
shockey 12dd90f748 Merge pull request #3159 from gwynjudd/doc-expansion
Added support for docExpansion config
2017-06-05 20:17:57 -07:00
Kyle Shockey 09148e478c Remove switching logic from spec specSelector 2017-06-05 20:04:52 -07:00
Kyle Shockey a857e947de Add default value to config constructor 2017-06-05 20:04:35 -07:00
shockey 438546f923 Merge branch 'master' into doc-expansion 2017-06-05 16:12:14 -07:00
Ron ea66055329 Merge pull request #3181 from scottohara/rename-pulse-animation
Use less generic pulse animation name (Fixes #3169)
2017-06-05 09:31:20 -07:00
Ron 2257836114 Merge branch 'master' into rename-pulse-animation 2017-06-05 09:28:33 -07:00
shockey 563a5643e7 Merge pull request #3182 from scottohara/remove-legacy-clear-class
Remove unused legacy clear class (Fixes #3167)
2017-06-05 09:00:29 -07:00
Scott O'Hara af2c890e51 Use less generic pulse animation name (Fixes #3169) 2017-06-05 08:38:39 +10:00
Scott O'Hara eed62339b2 Remove unused legacy clear class (Fixes #3167) 2017-06-05 08:36:49 +10:00
shockey eec04f4ce2 Merge pull request #3180 from shockey/v/3.0.13
v/3.0.13
2017-06-03 00:41:15 -07:00
Kyle Shockey 58422825c9 Rebuild dist 2017-06-03 00:18:15 -07:00
Kyle Shockey 5952bb6cbf Bump fast-json-patch in lockfile 2017-06-03 00:16:44 -07:00
Kyle Shockey b4cb0ce247 Rebuild dist 2017-06-03 00:11:32 -07:00
Kyle Shockey 19f7668b48 Bump declared version and upstream minimum versions 2017-06-02 22:42:18 -07:00
Franz Wong 20e7c0708a Copy swagger.json to nginx directory 2017-06-03 13:01:11 +09:00
shockey f862caa599 Merge pull request #3178 from shockey/build
Rebuild dist
2017-06-02 15:55:09 -07:00
Kyle Shockey c471f59c53 Rebuild dist 2017-06-02 15:49:04 -07:00
shockey 9a08904574 Merge pull request #3165 from shockey/bug/3163-markdown-xss
Sanitize Markdown inputs
2017-06-01 23:47:18 -07:00
Kyle Shockey bec97cfaf5 Fix style error 2017-06-01 22:24:31 -07:00
Kyle Shockey 6ccd037197 Merge branch 'bug/3163-markdown-xss' of github.com:shockey/swagger-ui into bug/3163-markdown-xss 2017-06-01 22:18:37 -07:00
Kyle Shockey af2b1e20f1 Sanitize Markdown inputs 2017-06-01 22:14:44 -07:00
Kyle Shockey 23b1a8aabd Finish rewiring Markdown provider 2017-06-01 21:41:28 -07:00
Kyle Shockey a2eed69ee7 Create providers directory; Markdown provider 2017-06-01 21:37:00 -07:00
Gwyn Judd eb929d3129 Added support for docExpansion config 2017-06-02 09:02:29 +12:00
shockey 6ae7eb4591 Merge branch 'master' into bug/3163-markdown-xss 2017-06-01 09:47:12 -07:00
Kyle Shockey df47e0e956 Disable HTML rendering in React-Markdown 2017-06-01 09:43:13 -07:00
shockey 5752ffcdab Merge pull request #3161 from shockey/ft/dev-server-watch
Dev server: remove 'watch' call, fix HMR
2017-05-31 23:53:38 -07:00
shockey 2bc6c45f83 Merge branch 'master' into ft/dev-server-watch 2017-05-31 18:54:38 -07:00
shockey 01124b07ad Merge pull request #3162 from swagger-api/readme-updates-0531
Update README.md
2017-05-31 18:15:33 -07:00
Kyle Shockey 1280abe737 Merge branch 'ft/dev-server-watch' of github.com:shockey/swagger-ui into ft/dev-server-watch 2017-05-31 18:14:30 -07:00
Kyle Shockey f4d1d28dd8 HMR for dev server 2017-05-31 18:13:43 -07:00
shockey 4dc966870d Update README.md 2017-05-31 17:25:51 -07:00
shockey 1d07a4b764 Merge branch 'master' into ft/dev-server-watch 2017-05-31 17:21:27 -07:00
shockey 65a4f9aaf2 Merge pull request #3160 from shockey/ft/package-lock
Add package-lock.json
2017-05-31 17:19:49 -07:00
shockey fa01f2b45d Merge branch 'master' into ft/package-lock 2017-05-31 17:16:55 -07:00
Kyle Shockey 1b7d94a54b Dev server: remove 'watch' call 2017-05-31 17:11:04 -07:00
Kyle Shockey f583469876 Add package-lock.json 2017-05-31 17:10:37 -07:00
Ron b242917e3e Merge pull request #2886 from gierschv/fix.info-font
fix(info): font for title, li and table
2017-05-31 12:35:02 -07:00
Ron d1c1b000bf Merge branch 'master' into fix.info-font 2017-05-31 12:31:00 -07:00
shockey fdcdb831eb Merge branch 'master' into master 2017-05-31 12:09:14 -07:00
Anna 8eb5461664 Merge pull request #3156 from bodnia/fix-3128-password
#3128 make request-body type default for aouth2 password flow
2017-05-31 18:58:09 +03:00
Anna Bodnia 676fd99960 #3128 make request-body type default for aouth2 password flow 2017-05-31 18:53:45 +03:00
Alexander Kravets adc09b6d5d Merge branch 'master' into master 2017-05-31 18:45:40 +03:00
Artem ed364d3562 Resolve conflicts 2017-05-31 18:43:47 +03:00
Anna 49705f3441 Merge pull request #3155 from bodnia/fix-3128
fix #3128
2017-05-31 18:18:21 +03:00
Artem 78fcf5f0ff Merge branch 'master' of https://github.com/slate-studio/swagger-ui 2017-05-31 17:50:16 +03:00
Artem 5eb006ee3d Refactor code 2017-05-31 17:50:11 +03:00
Anna Bodnia 5f2eaffbc3 fix #3128 2017-05-31 17:31:29 +03:00
Vincent Giersch 0ea14189c0 fix(info): font for title, li and table 2017-05-31 10:46:07 +02:00
Alexander Kravets 914f6991cd Merge branch 'master' into master 2017-05-31 08:47:48 +03:00
Anna 88df65533c Merge pull request #3148 from bodnia/master
typo in README
2017-05-30 14:49:07 +03:00
Anna Bodnia 8340f5d06c typo in README 2017-05-30 14:45:04 +03:00
Michael Mrowetz 6bced2ad48 Merge branch 'master' into update-alpine 2017-05-29 17:07:18 -07:00
Artem 2fd9d9ed25 Change operationId font size 2017-05-29 14:38:21 +03:00
Artem 20d9161e2b Add operationId 2017-05-29 13:31:38 +03:00
shockey 39501c8d82 Merge pull request #3140 from shockey/v/3.0.12
v3.0.12
2017-05-26 19:43:55 -07:00
Kyle Shockey d68dd5f7d6 Rebuild dist 2017-05-26 19:38:03 -07:00
Kyle Shockey 2567e5168d v3.0.12 2017-05-26 19:36:30 -07:00
shockey bf6681c914 Merge pull request #3133 from shockey/ft/dist-npm-packaging
packaging: fix swagger-ui-dist entry point
2017-05-26 00:59:16 -07:00
Michael Mrowetz b9dbfccb8e Merge branch 'master' into update-alpine 2017-05-26 00:03:27 -07:00
Roman Bolshakov b23c999d01 packaging: fix swagger-ui-dist entry point
Entry point was missing. This change allows importing SwaggerUIBundle
and SwaggerUIStandalonePreset directly from package. Correct entry point
is also needed for module bundlers like webpack to perform tree-shaking.
2017-05-25 17:45:01 -07:00
Anna 41d8089d0e Merge pull request #3130 from bodnia/fix-3067
Fix 3067
2017-05-25 18:30:12 +03:00
Anna Bodnia c5d2faa3a2 build 2017-05-25 18:10:40 +03:00
Anna Bodnia df4ea9b3d6 Merge remote-tracking branch 'upstream/master' into fix-3067 2017-05-25 18:06:07 +03:00
Anna Bodnia 62cb9ec581 Read me for modelPropertyMacro, changed for parameterMacro 2017-05-25 18:04:21 +03:00
Michael Mrowetz 494b99ebef update base-image to alpine 3.5 2017-05-25 10:55:38 +09:00
shockey 1db8e498b7 Merge pull request #3116 from Minasokoni/clickfix
Updated click area
2017-05-24 09:01:34 -07:00
Anna Bodnia 918e0e46c0 read me for parameterMacro 2017-05-23 15:36:42 +03:00
Robert Barnwell 760d1eba80 Merge branch 'master' into clickfix 2017-05-22 09:57:19 -07:00
Minasokoni a2a2f76199 updated click area 2017-05-22 09:12:13 -07:00
Anna Bodnia d5b9552a5a removed debugger 2017-05-22 17:13:31 +03:00
Anna Bodnia edfe88d299 modelPropertyMacro, parameterMacro 2017-05-19 18:50:51 +03:00
Masahide Sakamaki bd44c2161a Merge branch 'master' into docker-run.sh-eol-lf 2017-05-11 12:17:44 +09:00
Masahide Sakamaki ef1ff15c89 Set EOL of docker-run.sh to LF 2017-05-08 21:10:51 +09:00
51 changed files with 367 additions and 162 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
"rules": {
"semi": [2, "never"],
"strict": 0,
"quotes": 2,
"quotes": [2, "double", { "allowTemplateLiterals": true }],
"no-unused-vars": 2,
"no-multi-spaces": 1,
"camelcase": 1,
+1
View File
@@ -0,0 +1 @@
docker-run.sh text eol=lf
+1
View File
@@ -4,3 +4,4 @@ node_modules
.DS_Store
npm-debug.log*
.eslintcache
package-lock.json
+1 -1
View File
@@ -1,4 +1,4 @@
FROM alpine:3.4
FROM alpine:3.5
MAINTAINER fehguy
+29 -7
View File
@@ -8,6 +8,11 @@
As a brand new version, written from the ground up, there are some known issues and unimplemented features. Check out the [Known Issues](#known-issues) section for more details.
This repo publishes to two different NPM packages:
* [swagger-ui](https://www.npmjs.com/package/swagger-ui) is intended for use as a node module.
* [swagger-ui-dist](https://www.npmjs.com/package/swagger-ui-dist) comes pre-bundled with all dependencies and can be incorporated directly in a webapp.
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
## Compatibility
@@ -15,7 +20,7 @@ The OpenAPI Specification has undergone 4 revisions since initial creation in 20
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
------------------ | ------------ | -------------------------- | ----- | ------
3.0.11 | 2017-03-19 | 2.0 | [tag v3.0.11](https://github.com/swagger-api/swagger-ui/tree/v3.0.11) |
3.0.15 | 2017-06-16 | 2.0 | [tag v3.0.15](https://github.com/swagger-api/swagger-ui/tree/v3.0.15) |
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) |
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) |
@@ -35,13 +40,21 @@ docker run -p 80:8080 swaggerapi/swagger-ui
Will start nginx with swagger-ui on port 80.
Or you can provide your own swagger.json on your host
```
docker run -p 80:8080 -e "SWAGGER_JSON=/foo/swagger.json" -v /bar:/foo swaggerapi/swagger-ui
```
##### Prerequisites
- Node 6.x
- NPM 3.x
If you just want to see your specs, open `dist/index.html` in your browser directly from your filesystem.
If you'd like to make modifications to the codebase, run the dev server with: `npm run dev`.
If you'd like to make modifications to the codebase, run the dev server with: `npm run dev`. A development server will open on `3200`.
If you'd like to rebuild the `/dist` folder with your codebase changes, run `npm run build`.
##### Browser support
Swagger UI works in the latest versions of Chrome, Safari, Firefox, Edge and IE11.
@@ -57,6 +70,11 @@ To help with the migration, here are the currently known issues with 3.X. This l
- l10n (translations) is not implemented.
- Relative path support for external files is not implemented.
### Direct use of JS and CSS assets
To include the JS, CSS and image assets directly into a webpage, use the [swagger-ui-dist](https://www.npmjs.com/package/swagger-ui-dist) package.
The root directory of this package contains the contents of the _dist/_ directory of this repo.
As a node module, `swagger-ui-dist` also exports the `swagger-ui-bundle` and `swagger-ui-standalone-preset` objects.
### SwaggerUIBundle
To use swagger-ui's bundles, you should take a look at the [source of swagger-ui html page](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html) and customize it. This basically requires you to instantiate a SwaggerUi object as below:
@@ -81,11 +99,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
```
@@ -115,6 +133,10 @@ dom_id | The id of a dom element inside which SwaggerUi will put the user interf
oauth2RedirectUrl | OAuth redirect URL
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.
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'.
displayOperationId | Controls the display of operationId in operations list. The default is `false`.
### Plugins
@@ -134,9 +156,9 @@ 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/?configs=http://localhost:3001/config.yaml
- 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
- change default configs in `swagger-config.yaml` *Note: after changing, the project must be re-built*
+2 -2
View File
@@ -94,8 +94,8 @@ window.onload = function() {
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: "-",
additionalQueryStringParams: {test: "hello"}
scopeSeparator: " ",
additionalQueryStringParams: {}
})
}
</script>
+3 -3
View File
@@ -8,6 +8,7 @@
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;
qp = (window.location.hash || location.search).substring(1);
@@ -35,7 +36,7 @@
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
oauth2.callback(oauth2.auth);
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
} else {
oauth2.errCb({
authId: oauth2.auth.name,
@@ -45,9 +46,8 @@
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid});
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
}
window.close();
}
</script>
+43 -41
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;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAyTA;;;;;;AAoIA;AAi7FA;AAmtCA;AAi0IA;AA0oJA;AAgwFA;AAyrGA;AA4lFA;AAioFA;AA09CA;AAwhDA;AAkrCA;AAu4EA;;;;;AAykCA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AAwZA;;;;;;AA8wFA;AAw3FA;;;;;AAkgDA;AAgsFA;AAw2CA;AA2kCA;AA88CA;AAkgFA;AAk2FA;;;;;;;;;AA2pDA;AA2zIA;AAk4DA;AA8mDA","sourceRoot":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA2TA;;;;;;AAoIA;AAi7FA;AAmtCA;AAi0IA;AAioJA;AA2iGA;AAs+FA;AA4kFA;AA6jFA;AAm9CA;AA6jDA;AAgrCA;AA+/EA;;;;;AAu3BA;AA0qJA;;;;;;;;;;;;;;AAwoFA;AA+lIA;AA2hJA;AAo2HA;AA8lGA;AAwiEA;AAo4DA;AAk7DA;AAyHA;;;;;;AA6iGA;AA07FA;;;;;AAi8CA;AAgsFA;AAs2CA;AAilCA;AA+7CA;AA85DA;AA4zCA;AAs5FA;;;;;;;;;AAqlCA;AA2zIA;AAu7FA;AAmrFA;AA20EA","sourceRoot":""}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA8QA;AAmvGA;AAuxFA;;;;;;AAocA;AAkvFA;AAu+CA;AAo+CA;AAgrCA;AAuyEA","sourceRoot":""}
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA0SA;AAgyGA;AAuxFA;;;;;;AAocA;AAkvFA;AAu+CA;AAo+CA;AAgrCA;AAuyEA","sourceRoot":""}
+1 -1
View File
File diff suppressed because one or more lines are too long
+8 -8
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;;;;;;AA0yCA;AAoyHA;AA8xHA;AA0kGA;AA+9BA;AA+iCA;AAmjCA;AA25BA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAizCA;AAoyHA;AAmyHA;AAukGA;AA+9BA;AA8jCA;AAyiCA;AAs5BA","sourceRoot":""}
+6 -3
View File
@@ -2,7 +2,8 @@
set -e
INDEX_FILE=/usr/share/nginx/html/index.html
NGINX_ROOT=/usr/share/nginx/html
INDEX_FILE=$NGINX_ROOT/index.html
replace_in_index () {
if [ "$1" != "**None**" ]; then
@@ -30,8 +31,10 @@ if [ "$OAUTH_ADDITIONAL_PARAMS" != "**None**" ]; then
fi
if [[ -f $SWAGGER_JSON ]]; then
sed -i "s|http://petstore.swagger.io/v2/swagger.json|swagger.json|g" $INDEX_FILE
sed -i "s|http://example.com/api|swagger.json|g" $INDEX_FILE
cp $SWAGGER_JSON $NGINX_ROOT
REL_PATH="/$(basename $SWAGGER_JSON)"
sed -i "s|http://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
else
sed -i "s|http://petstore.swagger.io/v2/swagger.json|$API_URL|g" $INDEX_FILE
sed -i "s|http://example.com/api|$API_URL|g" $INDEX_FILE
+5 -4
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.0.11",
"version": "3.0.15",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -19,7 +19,7 @@
"build-core": "webpack --config webpack-dist.config.js --colors",
"build-standalone": "webpack --config webpack-dist-standalone.config.js --colors",
"predev": "npm install",
"dev": "npm-run-all --parallel hot-server watch open-localhost",
"dev": "npm-run-all --parallel hot-server open-localhost",
"watch": "webpack --config webpack-watch.config.js --watch --progress",
"open-localhost": "node -e 'require(\"open\")(\"http://localhost:3200\")'",
"hot-server": "webpack-dev-server --host 0.0.0.0 --config webpack-hot-dev-server.config.js --inline --hot --progress --content-base dev-helpers/",
@@ -32,7 +32,7 @@
"test": "npm run lint-errors && npm run just-test-in-node",
"test-in-node": "npm run lint-errors && npm run just-test-in-node",
"just-test": "karma start --config karma.conf.js",
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components"
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components test/bugs test/swagger-ui-dist-package"
},
"dependencies": {
"babel-polyfill": "^6.23.0",
@@ -67,9 +67,10 @@
"redux-immutable": "3.0.8",
"redux-logger": "*",
"reselect": "2.5.3",
"sanitize-html": "^1.14.1",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "~3.0.11",
"swagger-client": "~3.0.15",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
+1 -2
View File
@@ -53,8 +53,7 @@ export default class ApiKeyAuth extends React.Component {
<h4>Api key authorization<JumpToPath path={[ "securityDefinitions", name ]} /></h4>
{ value && <h6>Authorized</h6>}
<Row>
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={ schema.get("description") } />
<Markdown source={ schema.get("description") } />
</Row>
<Row>
<p>Name: <code>{ schema.get("name") }</code></p>
+1 -2
View File
@@ -59,8 +59,7 @@ export default class BasicAuth extends React.Component {
<h4>Basic authorization<JumpToPath path={[ "securityDefinitions", name ]} /></h4>
{ username && <h6>Authorized</h6> }
<Row>
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={ schema.get("description") } />
<Markdown source={ schema.get("description") } />
</Row>
<Row>
<label>Username:</label>
+4 -4
View File
@@ -27,7 +27,7 @@ export default class Oauth2 extends React.Component {
let username = auth && auth.get("username") || ""
let clientId = auth && auth.get("clientId") || authConfigs.clientId || ""
let clientSecret = auth && auth.get("clientSecret") || authConfigs.clientSecret || ""
let passwordType = auth && auth.get("passwordType") || "basic"
let passwordType = auth && auth.get("passwordType") || "request-body"
this.state = {
appName: authConfigs.appName,
@@ -97,13 +97,13 @@ export default class Oauth2 extends React.Component {
let isAuthorized = !!authorizedAuth
let errors = errSelectors.allErrors().filter( err => err.get("authId") === name)
let isValid = !errors.filter( err => err.get("source") === "validation").size
let description = schema.get("description")
return (
<div>
<h4>OAuth2.0 <JumpToPath path={[ "securityDefinitions", name ]} /></h4>
{ !this.state.appName ? null : <h5>Application: { this.state.appName } </h5> }
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={ schema.get("description") } />
{ description && <Markdown source={ schema.get("description") } /> }
{ isAuthorized && <h6>Authorized</h6> }
@@ -141,8 +141,8 @@ export default class Oauth2 extends React.Component {
isAuthorized ? <code> { this.state.passwordType } </code>
: <Col tablet={10} desktop={10}>
<select id="password_type" data-name="passwordType" onChange={ this.onInputChange }>
<option value="basic">Basic auth</option>
<option value="request-body">Request body</option>
<option value="basic">Basic auth</option>
<option value="query">Query parameters</option>
</select>
</Col>
+1 -1
View File
@@ -19,7 +19,7 @@ export default class Curl extends React.Component {
<div>
<h4>Curl</h4>
<div className="copy-paste">
<textarea onFocus={this.handleFocus} className="curl" style={{ whiteSpace: "normal" }} value={curl}></textarea>
<textarea onFocus={this.handleFocus} readOnly="true" className="curl" style={{ whiteSpace: "normal" }} value={curl}></textarea>
</div>
</div>
)
+1 -1
View File
@@ -99,7 +99,7 @@ export default class Info extends React.Component {
</hgroup>
<div className="description">
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}} source={ description } />
<Markdown source={ description } />
</div>
{
+1 -4
View File
@@ -1,13 +1,10 @@
import React, { PropTypes } from "react"
import OriCollapse from "react-collapse"
import _Markdown from "react-remarkable"
function xclass(...args) {
return args.filter(a => !!a).join(" ").trim()
}
export const Markdown = _Markdown
export class Container extends React.Component {
render() {
let { fullscreen, full, ...rest } = this.props
@@ -73,7 +70,7 @@ export class Col extends React.Component {
}
}
let classes = xclass(rest.className, "clear", ...classesAr)
let classes = xclass(rest.className, ...classesAr)
return (
<section {...rest} style={{display: hide ? "none": null}} className={classes}/>
+18 -15
View File
@@ -22,13 +22,14 @@ export default class LiveResponse extends React.Component {
render() {
const { request, response, getComponent } = this.props
const body = response.get("text")
const status = response.get("status")
const url = response.get("url")
const headers = response.get("headers").toJS()
const notDocumented = response.get("notDocumented")
const isError = response.get("error")
const body = isError ? response.get("response").get("text") : response.get("text")
const headersKeys = Object.keys(headers)
const contentType = headers["content-type"]
@@ -37,6 +38,7 @@ export default class LiveResponse extends React.Component {
const returnObject = headersKeys.map(key => {
return <span className="headerline" key={key}> {key}: {headers[key]} </span>
})
const hasHeaders = returnObject.length !== 0
return (
<div>
@@ -54,28 +56,29 @@ export default class LiveResponse extends React.Component {
<td className="col response-col_status">
{ status }
{
!notDocumented ? null :
<div className="response-undocumented">
<i> Undocumented </i>
</div>
notDocumented ? <div className="response-undocumented">
<i> Undocumented </i>
</div>
: null
}
</td>
<td className="col response-col_description">
{
!isError ? null : <span>
{`${response.get("name")}: ${response.get("message")}`}
</span>
isError ? <span>
{`${response.get("name")}: ${response.get("message")}`}
</span>
: null
}
{
!body || isError ? null
: <ResponseBody content={ body }
contentType={ contentType }
url={ url }
headers={ headers }
getComponent={ getComponent }/>
body ? <ResponseBody content={ body }
contentType={ contentType }
url={ url }
headers={ headers }
getComponent={ getComponent }/>
: null
}
{
!headers ? null : <Headers headers={ returnObject }/>
hasHeaders ? <Headers headers={ returnObject }/> : null
}
</td>
</tr>
+17 -7
View File
@@ -40,6 +40,7 @@ class ObjectModel extends Component {
let additionalProperties = schema.get("additionalProperties")
let title = schema.get("title") || name
let required = schema.get("required")
const Markdown = getComponent("Markdown")
const JumpToPathSection = ({ name }) => <span className="model-jump-to-path"><JumpToPath path={`definitions.${name}`} /></span>
let collapsedContent = (<span>
<span>{ braceOpen }</span>...<span>{ braceClose }</span>
@@ -66,7 +67,9 @@ class ObjectModel extends Component {
{
!description ? null : <tr style={{ color: "#999", fontStyle: "italic" }}>
<td>description:</td>
<td>{ description }</td>
<td>
<Markdown source={ description } />
</td>
</tr>
}
{
@@ -114,11 +117,12 @@ class ObjectModel extends Component {
class Primitive extends Component {
static propTypes = {
schema: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired,
required: PropTypes.bool
}
render(){
let { schema, required } = this.props
let { schema, getComponent, required } = this.props
if(!schema || !schema.get) {
// don't render if schema isn't correctly formed
@@ -129,17 +133,23 @@ class Primitive extends Component {
let format = schema.get("format")
let xml = schema.get("xml")
let enumArray = schema.get("enum")
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "$$ref"].indexOf(key) === -1 )
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")
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 !== "description" && key + ": " }{ String(v) }</span>)
<br />{ key }: { String(v) }</span>)
: null
}
{
!description ? null :
<Markdown source={ description } />
}
{
xml && xml.size ? (<span><br /><span style={ propStyle }>xml:</span>
{
@@ -217,7 +227,7 @@ class Model extends Component {
}
render () {
let { schema, required, name, isRef } = this.props
let { schema, getComponent, required, name, isRef } = this.props
let $$ref = schema && schema.get("$$ref")
let modelName = $$ref && this.getModelName( $$ref )
let modelSchema, type
@@ -236,7 +246,7 @@ class Model extends Component {
switch(type) {
case "object":
return <ObjectModel className="object" { ...this.props } schema={ modelSchema }
name={ modelName || name }
name={ name || modelName }
isRef={ isRef!== undefined ? isRef : !!$$ref }/>
case "array":
return <ArrayModel className="array" { ...this.props } schema={ modelSchema } required={ required } />
@@ -245,7 +255,7 @@ class Model extends Component {
case "integer":
case "boolean":
default:
return <Primitive schema={ modelSchema } required={ required }/>
return <Primitive getComponent={ getComponent } schema={ modelSchema } required={ required }/>
}
}
}
+5 -3
View File
@@ -6,13 +6,15 @@ export default class Models extends Component {
getComponent: PropTypes.func,
specSelectors: PropTypes.object,
layoutSelectors: PropTypes.object,
layoutActions: PropTypes.object
layoutActions: PropTypes.object,
getConfigs: PropTypes.func.isRequired
}
render(){
let { specSelectors, getComponent, layoutSelectors, layoutActions } = this.props
let { specSelectors, getComponent, layoutSelectors, layoutActions, getConfigs } = this.props
let definitions = specSelectors.definitions()
let showModels = layoutSelectors.isShown("models", true)
let { docExpansion } = getConfigs()
let showModels = layoutSelectors.isShown("models", docExpansion === "full" || docExpansion === "list" )
const Model = getComponent("model")
const Collapse = getComponent("Collapse")
+14 -4
View File
@@ -17,6 +17,8 @@ export default class Operation extends React.Component {
allowTryItOut: PropTypes.bool,
displayOperationId: PropTypes.bool,
response: PropTypes.object,
request: PropTypes.object,
@@ -27,13 +29,15 @@ 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 = {
showSummary: true,
response: null,
allowTryItOut: true,
displayOperationId: false,
}
constructor(props, context) {
@@ -76,8 +80,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 =() => {
@@ -105,6 +111,7 @@ export default class Operation extends React.Component {
response,
request,
allowTryItOut,
displayOperationId,
fn,
getComponent,
@@ -123,6 +130,7 @@ export default class Operation extends React.Component {
let produces = operation.get("produces")
let schemes = operation.get("schemes")
let parameters = getList(operation, ["parameters"])
let operationId = operation.get("__originalOperationId")
const Responses = getComponent("responses")
const Parameters = getComponent( "parameters" )
@@ -159,6 +167,8 @@ export default class Operation extends React.Component {
</div>
}
{ displayOperationId && operationId ? <span className="opblock-summary-operation-id">{operationId}</span> : null }
{
(!security || !security.count()) ? null :
<AuthorizeOperationBtn authActions={ authActions }
@@ -173,7 +183,7 @@ export default class Operation extends React.Component {
{ description &&
<div className="opblock-description-wrapper">
<div className="opblock-description">
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}} source={ description } />
<Markdown source={ description } />
</div>
</div>
}
+10 -9
View File
@@ -10,10 +10,7 @@ export default class Operations extends React.Component {
layoutActions: PropTypes.object.isRequired,
authActions: PropTypes.object.isRequired,
authSelectors: PropTypes.object.isRequired,
};
static defaultProps = {
getConfigs: PropTypes.func.isRequired
};
render() {
@@ -25,6 +22,7 @@ export default class Operations extends React.Component {
layoutActions,
authActions,
authSelectors,
getConfigs,
fn
} = this.props
@@ -34,6 +32,7 @@ export default class Operations extends React.Component {
const Collapse = getComponent("Collapse")
let showSummary = layoutSelectors.showSummary()
let { docExpansion, displayOperationId } = getConfigs()
return (
<div>
@@ -43,16 +42,15 @@ 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 (
<div className={showTag ? "opblock-tag-section is-open" : "opblock-tag-section"} key={"operation-" + tag}>
<h4 className={!tagDescription ? "opblock-tag no-desc" : "opblock-tag" }>
<span onClick={() => layoutActions.show(isShownKey, !showTag)}>{tag}</span>
<h4 onClick={() => layoutActions.show(isShownKey, !showTag)} className={!tagDescription ? "opblock-tag no-desc" : "opblock-tag" }>
<span>{tag}</span>
{ !tagDescription ? null :
<small onClick={() => layoutActions.show(isShownKey, !showTag)} >
<small>
{ tagDescription }
</small>
}
@@ -88,6 +86,8 @@ export default class Operations extends React.Component {
request={ request }
allowTryItOut={allowTryItOut}
displayOperationId={displayOperationId}
specActions={ specActions }
specSelectors={ specSelectors }
@@ -99,6 +99,7 @@ export default class Operations extends React.Component {
getComponent={ getComponent }
fn={fn}
getConfigs={ getConfigs }
/>
}).toArray()
}
+1 -2
View File
@@ -99,8 +99,7 @@ export default class ParameterRow extends Component {
</td>
<td className="col parameters-col_description">
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={ param.get("description") }/>
<Markdown source={ param.get("description") }/>
{(isFormData && !isFormDataSupported) && <div>Error: your browser does not support FormData</div>}
{ bodyParam || !isExecute ? null
+6
View File
@@ -0,0 +1,6 @@
# Providers
Providers are generic bridges to third-party components. They provide two benefits:
1. ability for plugins to override third-party components, because providers are loaded through `getComponent`
2. allows us to avoid painting ourselves into a corner with a third-party component
@@ -0,0 +1,24 @@
import React, { PropTypes } from "react"
import Remarkable from "react-remarkable"
import sanitize from "sanitize-html"
const sanitizeOptions = {
textFilter: function(text) {
return text
.replace(/&quot;/g, "\"")
}
}
function Markdown({ source }) {
const sanitized = sanitize(source, sanitizeOptions)
return <Remarkable
options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={sanitized}
></Remarkable>
}
Markdown.propTypes = {
source: PropTypes.string.isRequired
}
export default Markdown
+2 -2
View File
@@ -8,7 +8,7 @@ const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
let exampleValue
try {
exampleValue = example && example.toJS ? example.toJS() : example
exampleValue = JSON.stringify(exampleValue)
exampleValue = JSON.stringify(exampleValue, null, 2)
}
catch(e) {
exampleValue = String(example)
@@ -76,7 +76,7 @@ export default class Response extends React.Component {
<td className="col response-col_description">
<div className="response-col_description__inner">
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}} source={ response.get( "description" ) } />
<Markdown source={ response.get( "description" ) } />
</div>
{ example ? (
+8 -4
View File
@@ -1,3 +1,5 @@
import win from "./window"
export default function curl( request ){
let curlified = []
let type = ""
@@ -18,11 +20,13 @@ export default function curl( request ){
if ( request.get("body") ){
if(type === "multipart/form-data" && request.get("method") === "POST") {
let formDataBody = request.get("body").split("&")
for(var data in formDataBody) {
for( let [ k,v ] of request.get("body").values()) {
curlified.push( "-F" )
curlified.push(formDataBody[data])
if (v instanceof win.File) {
curlified.push( `"${k}=@${v.name};type=${v.type}"` )
} else {
curlified.push( `"${k}=${v}"` )
}
}
} else {
curlified.push( "-d" )
+4 -2
View File
@@ -7,8 +7,8 @@ import * as AllPlugins from "core/plugins/all"
import { parseSeach, filterConfigs } from "core/utils"
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
"apisSorter", "operationsSorter", "supportedSubmitMethods", "highlightSizeThreshold", "dom_id",
"defaultModelRendering", "oauth2RedirectUrl", "showRequestHeaders", "custom" ]
"apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl",
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro", "displayOperationId" ]
// eslint-disable-next-line no-undef
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
@@ -24,9 +24,11 @@ module.exports = function SwaggerUI(opts) {
spec: {},
url: "",
layout: "BaseLayout",
docExpansion: "list",
validatorUrl: "https://online.swagger.io/validator",
configs: {},
custom: {},
displayOperationId: false,
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.
+6 -5
View File
@@ -81,7 +81,7 @@ export const authorizePassword = ( auth ) => ( { authActions } ) => {
if ( passwordType === "basic") {
headers.Authorization = "Basic " + btoa(username + ":" + password)
} else {
Object.assign(form, {username}, {password})
Object.assign(form, {username}, {password})
if ( passwordType === "query") {
if ( clientId ) {
@@ -91,7 +91,7 @@ export const authorizePassword = ( auth ) => ( { authActions } ) => {
query.client_secret = clientSecret
}
} else {
Object.assign(form, {client_id: clientId}, {client_secret: clientSecret})
headers.Authorization = "Basic " + btoa(clientId + ":" + clientSecret)
}
}
@@ -100,14 +100,15 @@ export const authorizePassword = ( auth ) => ( { authActions } ) => {
export const authorizeApplication = ( auth ) => ( { authActions } ) => {
let { schema, scopes, name, clientId, clientSecret } = auth
let headers = {
Authorization: "Basic " + btoa(clientId + ":" + clientSecret)
}
let form = {
grant_type: "client_credentials",
client_id: clientId,
client_secret: clientSecret,
scope: scopes.join(scopeSeparator)
}
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth })
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers })
}
export const authorizeAccessCode = ( { auth, redirectUrl } ) => ( { authActions } ) => {
+4 -2
View File
@@ -77,7 +77,9 @@ export const parseToJson = (str) => ({specActions, specSelectors, errActions}) =
return specActions.updateJsonSpec(json)
}
export const resolveSpec = (json, url) => ({specActions, specSelectors, errActions, fn: { fetch, resolve, AST }}) => {
export const resolveSpec = (json, url) => ({specActions, specSelectors, errActions, fn: { fetch, resolve, AST }, getConfigs}) => {
const { modelPropertyMacro, parameterMacro } = getConfigs()
if(typeof(json) === "undefined") {
json = specSelectors.specJson()
}
@@ -89,7 +91,7 @@ export const resolveSpec = (json, url) => ({specActions, specSelectors, errActio
let specStr = specSelectors.specStr()
return resolve({fetch, spec: json, baseDoc: url})
return resolve({fetch, spec: json, baseDoc: url, modelPropertyMacro, parameterMacro })
.then( ({spec, errors}) => {
errActions.clear({
type: "thrown"
-2
View File
@@ -43,8 +43,6 @@ export const specResolved = createSelector(
// Default Spec ( as an object )
export const spec = state => {
let res = specResolved(state)
if(res.count() < 1)
res = specJson(state)
return res
}
+3
View File
@@ -46,6 +46,8 @@ import Model from "core/components/model"
import Models from "core/components/models"
import TryItOutButton from "core/components/try-it-out-button"
import Markdown from "core/components/providers/markdown"
import BaseLayout from "core/components/layouts/base"
import * as LayoutUtils from "core/components/layout-utils"
@@ -89,6 +91,7 @@ export default function() {
model: Model,
models: Models,
TryItOutButton,
Markdown,
BaseLayout
}
}
+4
View File
@@ -7,6 +7,7 @@ import _memoize from "lodash/memoize"
import some from "lodash/some"
import eq from "lodash/eq"
import { memoizedSampleFromSchema, memoizedCreateXMLExample } from "core/plugins/samples/fn"
import win from "./window"
const DEFAULT_REPONSE_KEY = "default"
@@ -34,6 +35,9 @@ export function fromJSOrdered (js) {
if(isImmutable(js))
return js // Can't do much here
if (js instanceof win.File)
return js
return !isObject(js) ? js :
Array.isArray(js) ?
Im.Seq(js).map(fromJSOrdered).toList() :
+2 -1
View File
@@ -3,7 +3,8 @@ function makeWindow() {
location: {},
history: {},
open: () => {},
close: () => {}
close: () => {},
File: function() {}
}
if(typeof window === "undefined") {
+2 -2
View File
@@ -58,7 +58,7 @@
&.execute
{
animation: pulse 2s infinite;
animation: swagger-ui-pulse 2s infinite;
color: #fff;
border-color: #4990e2;
@@ -66,7 +66,7 @@
}
@keyframes pulse
@keyframes swagger-ui-pulse
{
0%
{
+6 -1
View File
@@ -13,13 +13,18 @@
font-size: 12px;
}
}
p
p, li, table
{
font-size: 14px;
@include text_body();
}
h1, h2, h3, h4, h5
{
@include text_body();
}
code
{
padding: 3px 5px;
+6
View File
@@ -209,6 +209,7 @@ body
}
.opblock-summary-path,
.opblock-summary-operation-id,
.opblock-summary-path__deprecated
{
font-size: 16px;
@@ -247,6 +248,11 @@ body
text-decoration: line-through;
}
.opblock-summary-operation-id
{
font-size: 14px;
}
.opblock-summary-description
{
font-size: 13px;
+20 -1
View File
@@ -1,3 +1,22 @@
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module.
# Swagger UI Dist
[![NPM version](https://badge.fury.io/js/swagger-ui-dist.svg)](http://badge.fury.io/js/swagger-ui-dist)
# API
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module.
Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
`SwaggerUIBundle` and `SwaggerUIStandalonePreset` can be imported:
```javascript
import { SwaggerUIBundle, SwaggerUIStandalonePreset } from "swagger-ui-dist"
```
To get an absolute path to this directory for static file serving, use the exported `getAbsoluteFSPath` method:
```javascript
const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath()
// then instantiate server that serves files from the swaggerUiAssetPath
```
For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
+14
View File
@@ -0,0 +1,14 @@
/*
* getAbsoluteFSPath
* @return {string} When run in NodeJS env, returns the absolute path to the current directory
* When run outside of NodeJS, will return an error message
*/
const getAbsoluteFSPath = () => {
// detect whether we are running in a browser or nodejs
if (typeof module !== "undefined" && module.exports) {
return require("path").resolve(__dirname)
}
throw new Error('getAbsoluteFSPath can only be called within a Nodejs environment');
}
module.exports = getAbsoluteFSPath
+1 -1
View File
@@ -18,4 +18,4 @@ else
npm pack .
fi
find . -not -name .npmignore -not -name .npmrc -not -name deploy.sh -not -name package.json -not -name README.md -not -name *.tgz -delete
find . -not -name .npmignore -not -name .npmrc -not -name deploy.sh -not -name index.js -not -name package.json -not -name README.md -not -name *.tgz -delete
+4
View File
@@ -0,0 +1,4 @@
module.exports.SwaggerUIBundle = require("./swagger-ui-bundle.js")
module.exports.SwaggerUIStandalonePreset = require("./swagger-ui-standalone-preset.js")
module.exports.absolutePath = require("./.absolute-path.js")
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "swagger-ui-dist",
"version": "$$VERSION",
"main": "dist/swagger-ui.js",
"main": "index.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
"(in alphabetical order)",
+23
View File
@@ -0,0 +1,23 @@
/* eslint-env mocha */
import React from "react"
import expect from "expect"
import { render } from "enzyme"
import Markdown from "components/providers/markdown"
describe("UI-3199: Sanitized Markdown causing code examples to be double escaped", function(){
it("should single-escape quotes", function(){
let str = "" +
"This is a test: \n\n" +
" {\"abc\": \"def\"}\n"
let props = {
source: str
}
let el = render(<Markdown {...props}/>)
expect(el.find("code").first().text()).toEqual("{\"abc\": \"def\"}\n")
expect(el.find("code").first().html()).toEqual("{&quot;abc&quot;: &quot;def&quot;}\n")
})
})
+26 -2
View File
@@ -1,6 +1,7 @@
import expect from "expect"
import Im from "immutable"
import curl from "core/curlify"
import win from "core/window"
describe("curlify", function() {
@@ -131,12 +132,35 @@ describe("curlify", function() {
url: "http://example.com",
method: "POST",
headers: { "content-type": "multipart/form-data" },
body: "id=123&name=Sahar"
body: [
["id", "123"],
["name", "Sahar"]
]
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F id=123 -F name=Sahar")
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"name=Sahar\"")
})
it("should print a curl with formData and file", function() {
var file = new win.File()
file.name = "file.txt"
file.type = "text/plain"
var req = {
url: "http://example.com",
method: "POST",
headers: { "content-type": "multipart/form-data" },
body: [
["id", "123"],
["file", file]
]
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"file=@file.txt;type=text/plain\"")
})
it("prints a curl post statement from an object", function() {
@@ -0,0 +1,13 @@
/* eslint-env mocha */
import expect from "expect"
import path from "path"
import getAbsoluteFSPath from "../../swagger-ui-dist-package/absolute-path"
describe("swagger-ui-dist", function(){
describe("getAbsoluteFSPath", function(){
it("returns absolute path", function(){
const expectedPath = path.resolve(__dirname, "../../swagger-ui-dist-package")
expect(getAbsoluteFSPath()).toEqual(expectedPath)
})
})
})
+4 -2
View File
@@ -10,11 +10,13 @@ module.exports = require("./make-webpack-config")({
devtool: "eval",
entry: {
'swagger-ui-bundle': [
'webpack/hot/dev-server',
'babel-polyfill',
'./src/core/index.js'
'./src/core/index.js',
],
'swagger-ui-standalone-preset': [
'./src/standalone/index.js'
'webpack/hot/dev-server',
'./src/standalone/index.js',
]
},
output: {