Compare commits

..
182 Commits
Author SHA1 Message Date
Kyle Shockey db8bd52f16 v3.0.6 2017-04-14 21:08:42 -07:00
Kyle Shockey 7172ed6fe9 Rebuild dist 2017-04-14 21:05:22 -07:00
Kyle Shockey 48e0cb10b5 Revert "Fix bug where reducer dies on empty operation"
This reverts commit 08b3c38b8a.
2017-04-14 21:00:56 -07:00
Kyle Shockey bedd509a4a Rebuild dist 2017-04-14 20:19:13 -07:00
shockey c6279e5f25 Merge pull request #2917 from shockey/ft/base-layout
Base layout
2017-04-14 19:07:21 -07:00
Kyle Shockey 81f74d9d51 Move loadingStatus code into StandaloneLayout (where it belongs!) 2017-04-14 19:01:57 -07:00
Kyle Shockey 208694e9a8 Fix linter & tests 2017-04-14 18:46:27 -07:00
Kyle Shockey ba7a1369b8 Dist rebuild 2017-04-14 18:41:34 -07:00
Kyle Shockey d1d663b35f Consume BaseLayout in UI standalone 2017-04-14 18:39:31 -07:00
Kyle Shockey cf80839d11 Add BaseLayout to core 2017-04-14 18:38:59 -07:00
Kyle Shockey de92f8deb4 Merge branch 'master' of github.com:swagger-api/swagger-ui 2017-04-14 18:22:29 -07:00
Kyle Shockey 99b8543562 Merge branch 'show_readonly_values_in_responses' of https://github.com/furkanayhan/swagger-ui into furkanayhan-show_readonly_values_in_responses 2017-04-14 18:21:44 -07:00
Tony Tam ef60fb07a4 added push 2017-04-14 17:35:09 -07:00
Kyle Shockey c45e5a3158 Rebuild dist 2017-04-14 17:16:25 -07:00
Kyle Shockey 08b3c38b8a Fix bug where reducer dies on empty operation 2017-04-14 17:15:27 -07:00
shockey c7ae644c96 Merge pull request #2912 from shockey/bug/2904-try-it-out
Fix inferring issues with Try-It-Out
2017-04-14 16:42:04 -07:00
Tony Tam 283722a20e added push 2017-04-14 14:36:29 -07:00
Tony Tam 89adefe392 Merge pull request #2916 from swagger-api/feature/docker-tag-fix
Feature/docker tag fix
2017-04-14 17:28:20 -04:00
Tony Tam 205197d04f fixed variable 2017-04-14 14:19:52 -07:00
Tony Tam 74008954c3 update tag logic to latest and unstable 2017-04-14 14:13:11 -07:00
Tony Tam 2b159372a9 removed dead line 2017-04-14 14:12:55 -07:00
Kyle Shockey 5be31ac909 Pass around contextUrl correctly 2017-04-13 19:24:02 -07:00
Kyle Shockey fce0916dca Merge branch 'bug/2760-infer-host' into bug/2904-try-it-out 2017-04-13 19:12:39 -07:00
Kyle Shockey 4c1a5488bb Parse spec url when deciding scheme for operation 2017-04-13 17:26:47 -07:00
Furkan Ayhan 2e91ab0a2e Add react-test-renderer as devDependencies 2017-04-13 16:36:35 +03:00
Furkan Ayhan 6965a496fb Show readOnly values in responses 2017-04-13 16:01:29 +03:00
Tony Tam e33efa1b36 Merge pull request #2901 from swagger-api/feature/docker-config
added variables for docker
2017-04-11 17:07:26 -04:00
Tony Tam 3ce9baee30 added variables for docker 2017-04-11 13:59:34 -07:00
Tony Tam 1f424afe0f Merge pull request #2900 from swagger-api/issue-2899
updated docker push logic
2017-04-11 16:48:59 -04:00
Tony Tam 4da6126d10 Merge branch 'master' into issue-2899 2017-04-11 16:43:13 -04:00
Tony Tam 9465d1251b updated docker push logic 2017-04-11 13:42:26 -07:00
shockey f7c5515dff Merge pull request #2894 from shockey/bug/2763-malformed-security-render-error
Protect AuthorizeOperationBtn from malformed security values
2017-04-10 14:03:49 -07:00
shockey 44ea2773cf Merge branch 'master' into bug/2763-malformed-security-render-error 2017-04-10 13:58:48 -07:00
Kyle Shockey 3c98939732 Fix name masking for render error messages 2017-04-10 13:58:18 -07:00
Kyle Shockey f2ae188722 Fix #2763 2017-04-10 13:50:51 -07:00
shockey 5e571fac51 Merge pull request #2821 from jeffweeksio/master
Update utils.js to allow negative numbers
2017-04-10 11:29:25 -07:00
shockey 8e60343417 Merge branch 'master' into master 2017-04-10 11:21:23 -07:00
Kyle Shockey 1b6da44cb5 v3.0.5 2017-04-07 21:44:40 -07:00
Kyle Shockey b120c115aa Use latest swagger-client; rebuild dist 2017-04-07 21:41:27 -07:00
Kyle Shockey e2b1757f8f Infer contextUrl through documentation scheme + host if spec url is relative 2017-04-07 20:51:07 -07:00
Anna 3c0fe96dde Merge pull request #2877 from bodnia/config-with-url
config passed with configUrl in constructor
2017-04-07 16:04:05 +03:00
Anna Bodnia eb4fa2a6b4 Merge remote-tracking branch 'upstream/master' into config-with-url 2017-04-07 15:57:24 +03:00
Anna 4fd5d9f643 Merge pull request #2878 from bodnia/fix-auth-schemes-display
fix schemes auth button display #2816
2017-04-07 15:51:24 +03:00
Anna Bodnia cfb9ddd675 removed not used variable 2017-04-07 15:43:25 +03:00
Anna Bodnia 63edfc739b fix schemes auth button display #2816 2017-04-07 15:39:59 +03:00
Anna Bodnia 8130168c97 config passed with configUrl in constructor 2017-04-07 15:17:27 +03:00
shockey c9e90fd975 Merge pull request #2860 from swagger-api/public-gone
gone with the public
2017-04-06 17:01:17 -07:00
shockey dc67698a48 Merge branch 'master' into public-gone 2017-04-06 16:51:38 -07:00
Kyle Shockey 5f9efc09cb Merge branch 'master' of https://github.com/marcgibbons/swagger-ui into marcgibbons-master 2017-04-06 16:44:47 -07:00
Anna 724c8c51d5 Merge pull request #2864 from misi/master
Implement Application/Client Credentials  Flow
2017-04-06 15:50:39 +03:00
Mészáros Mihály 81abe37a31 add fn.fetch instead of native fetch 2017-04-06 14:46:04 +02:00
Mészáros Mihály 4066d1920e move out the code according @bodnia guide 2017-04-06 13:12:28 +02:00
Mészáros Mihály 9b35b7bf5c Merge branch 'master' of github.com:misi/swagger-ui 2017-04-06 08:19:35 +02:00
Mészáros Mihály 593e8de4c8 fix rm unintentieonaly staged file 2017-04-06 08:17:39 +02:00
misi c7f2cd6543 Merge branch 'master' into master 2017-04-06 08:08:34 +02:00
Mészáros Mihály a4500d1763 fix error handling 2017-04-06 08:03:36 +02:00
Mészáros Mihály ec1ba7a124 fix most lint errors 2017-04-06 06:08:52 +02:00
shockey 5f3a7a2e82 Merge pull request #2865 from shockey/bug/no-line-numbers-without-jumptoline
Improve spec error messaging
2017-04-05 16:08:32 -07:00
Kyle Shockey 9cfc18c8ee Merge branch 'master' into bug/no-line-numbers-without-jumptoline 2017-04-05 15:50:55 -07:00
Kyle Shockey 8bae745f78 Improve spec error messaging 2017-04-05 15:42:22 -07:00
Mészáros Mihály c8aaf0d3f3 Merge branch 'master' of github.com:misi/swagger-ui 2017-04-05 20:22:01 +02:00
Mészáros Mihály ae33b7f46a Implement application/client_credentials flow 2017-04-05 20:20:23 +02:00
Mészáros Mihály 823dcf0fd7 Authenticate Application/client_credentials flow 2017-04-05 20:16:34 +02:00
Mészáros Mihály ac8ac340af add posdt for application and get token 2017-04-05 15:53:26 +02:00
Anna 7a0cc20b5c Merge pull request #2863 from bodnia/fix-2816
fix #2816
2017-04-05 16:02:11 +03:00
Anna Bodnia f27f1b7808 fix #2816 2017-04-05 15:57:23 +03:00
shockey 8b64f475d7 Merge pull request #2861 from shockey/bug/jump-line-missing
Fix render issues that occur when jumpToLine isn't provided
2017-04-04 17:54:54 -07:00
shockey 05b2605545 Merge branch 'master' into bug/jump-line-missing 2017-04-04 17:51:16 -07:00
Kyle Shockey 0ee0236666 Fix render issues that occurs when jumpToLine isn't provided 2017-04-04 17:45:37 -07:00
shockey 8c023c907d Update paths in index.html 2017-04-04 15:38:34 -07:00
Ron 7f525a8730 gone with the public 2017-04-04 14:37:45 -07:00
Ron ad4fe9cbd5 Merge pull request #2836 from pwielgolaski/patch-1
Fix location of index.html in README.md
2017-04-04 14:01:47 -07:00
Ron e08df745dd Merge branch 'master' into patch-1 2017-04-04 13:57:59 -07:00
Ron 96f855ece7 Merge pull request #2859 from swagger-api/Update-composer
Update composer.json
2017-04-04 12:28:42 -07:00
Ron 95f7d6546a Update composer.json 2017-04-04 12:25:07 -07:00
Ron 28267b7bb0 Merge pull request #2858 from swagger-api/PHP-Composer
Create composer.json
2017-04-04 12:04:48 -07:00
Jeff Weeks 2535758adf Merge branch 'master' into master 2017-04-04 14:26:48 -04:00
Ron a4ef2be656 Merge branch 'master' into PHP-Composer 2017-04-04 11:26:36 -07:00
shockey d829b4a840 Merge pull request #2857 from swagger-api/UI-Customization
Update README.md
2017-04-04 11:19:41 -07:00
Kyle Shockey f2fc7e2af0 Merge branch 'master' into UI-Customization 2017-04-04 11:13:46 -07:00
Ron ac9c8b5460 Create composer.json 2017-04-04 11:07:55 -07:00
shockey e4c47717eb Update utils.js 2017-04-04 11:06:33 -07:00
Ron e24bc7635f Update README.md 2017-04-04 10:41:22 -07:00
Ron 0c00e03330 Update README.md 2017-04-04 10:34:22 -07:00
Anna b9c1402882 Merge pull request #2853 from bodnia/build-dist
latest build
2017-04-04 16:50:49 +03:00
Anna Bodnia dd8fb58fcd latest build 2017-04-04 16:50:19 +03:00
Anna 381070f655 Merge pull request #2851 from bodnia/fix-2456
fix #2456
2017-04-04 16:10:14 +03:00
Anna Bodnia 59ecaf40ee fix #2456 2017-04-04 16:09:28 +03:00
Anna 436586a661 Merge pull request #2850 from bodnia/fix-2807
fix #2807
2017-04-04 15:08:05 +03:00
Anna Bodnia 5be1ae582c fix #2807 2017-04-04 15:07:34 +03:00
Anna 3ed8efe736 Merge pull request #2848 from bodnia/fix-2839
fix #2839
2017-04-04 14:35:23 +03:00
Anna Bodnia fde75d408e fix #2839 2017-04-04 14:34:59 +03:00
Anna 52331ab494 Merge pull request #2846 from bodnia/fix-2800
fix #2800
2017-04-04 12:40:04 +03:00
Anna Bodnia c86199a506 fix #2800 2017-04-04 12:39:26 +03:00
Piotr Wielgolaski 6cce7713e1 Fix location of index.html in README.md
There is no index.html in `public` folder, so we should use `dist`  I suppose.
2017-04-01 16:30:46 +02:00
Kyle Shockey bfe5963978 v3.0.4 2017-03-31 19:26:23 -07:00
Kyle Shockey e0e6ccc6d3 Bump swagger-client to latest 2017-03-31 19:25:17 -07:00
Kyle Shockey 965cfd349c Rebuild dist 2017-03-31 19:19:56 -07:00
shockey c46566a904 Merge pull request #2835 from shockey/ft/cleanup
Removed unused packages from dependencies
2017-03-31 18:08:40 -07:00
Kyle Shockey ed9e94f506 Fix linter problems 2017-03-31 18:05:01 -07:00
Kyle Shockey ade4dd4e68 Merge branch 'master' of github.com:swagger-api/swagger-ui into ft/cleanup 2017-03-31 17:58:02 -07:00
Kyle Shockey a8f9f5c791 Removed unused packages from dependencies 2017-03-31 17:52:00 -07:00
Anna 02d55a096b Merge pull request #2833 from bodnia/fix-2795
fixes #2795
2017-03-31 18:36:22 +03:00
Anna Bodnia d2e20a72f0 fixes #2795 2017-03-31 18:35:52 +03:00
Anna af0088ccca Merge pull request #2831 from bodnia/fix-2796
fix badge async load
2017-03-31 11:19:46 +03:00
Anna Bodnia 879fc4ce04 fix badge async load 2017-03-31 11:19:10 +03:00
Anna 38737da9e9 Merge pull request #2829 from bodnia/fix-2827
#2827 remove online validator badge for specs hosted locally
2017-03-30 18:55:40 +03:00
Anna Bodnia 161dc57cd5 #2827 remove online validator badge for specs hosted locally 2017-03-30 18:55:16 +03:00
Anna 1df4df67c1 Merge pull request #2826 from bodnia/fix-2774
#2774 display scopes for oauth2 password flow
2017-03-30 17:49:59 +03:00
Anna Bodnia 432cd7f965 #2774 display scopes for oauth2 password flow 2017-03-30 17:49:32 +03:00
shockey b34e363ae1 Merge pull request #2823 from shockey/master
Fix dev server
2017-03-30 00:22:09 -07:00
Kyle Shockey 229bd1df9a Fix dev server 2017-03-30 00:16:17 -07:00
Marc Gibbons a1e5f2198e Allow any HTTP headers, send cookies on same origin 2017-03-29 17:18:41 -04:00
Jeff Weeks 2a6ecb2d38 Update utils.js 2017-03-29 16:30:25 -04:00
Anna ec46a22df5 Merge pull request #2820 from bodnia/fix-badge
fix badge display
2017-03-29 22:20:40 +03:00
Anna Bodnia 0b668ccf2a fix badge display 2017-03-29 22:20:12 +03:00
Anna c38bf2a0b1 Merge pull request #2817 from bodnia/fix-2796
#2796 disable validator (with badge) by removing it from config
2017-03-29 12:38:19 +03:00
Anna Bodnia ded299d891 #2796 disable validator (with badge) by removing it from config 2017-03-29 12:36:38 +03:00
Tony Tam 374b3613d0 Merge pull request #2812 from swagger-api/update-docker
added docker push from travis
2017-03-27 22:28:43 -07:00
Tony Tam eff72c21df added image name 2017-03-27 22:24:05 -07:00
Tony Tam 995ca2bf3d enabled docker service 2017-03-27 22:15:27 -07:00
Tony Tam a09412d712 added docker push from travis 2017-03-27 22:11:24 -07:00
shockey 7d215a9ef7 Merge pull request #2811 from shockey/ft/default-export-standalone
standalone default export
2017-03-27 20:01:18 -07:00
shockey 29ecbea269 Merge pull request #2810 from shockey/master
Version updates
2017-03-27 19:52:37 -07:00
Kyle Shockey 431b67362c Eliminate the need for the ES6 module backflips in Standalone example 2017-03-27 19:51:45 -07:00
Kyle Shockey bd0fbc60dd Merge branch 'master' of github.com:swagger-api/swagger-ui 2017-03-27 19:42:46 -07:00
Anna b8e1f1ceeb Merge pull request #2802 from bodnia/fix-auth-btn
Fix display of auth button not to depend on schemes
2017-03-27 22:58:08 +03:00
Anna Bodnia a13dc1ede1 Fix display of auth button not to depend on schemes 2017-03-27 22:57:27 +03:00
Kyle Shockey 822dda8fc8 Dist rebuild 2017-03-25 21:06:18 -07:00
shockey 85d7ec52e7 Update README.md 2017-03-25 01:04:57 -07:00
Kyle Shockey 7827e0ab82 Version 3.0.3 2017-03-25 00:59:49 -07:00
Kyle Shockey 284572855b Dist rebuild 2017-03-25 00:59:40 -07:00
shockey e23dada9fe Merge pull request #2755 from buunguyen/master
Use loadSpec option of latest swagger client
2017-03-25 00:57:46 -07:00
shockey 8fea5f545e Merge pull request #2787 from shockey/master
contextUrl for swagger-client
2017-03-25 00:40:10 -07:00
Kyle Shockey be887043ed Merge branch 'master' of github.com:swagger-api/swagger-ui 2017-03-25 00:39:54 -07:00
Kyle Shockey 6a668cbf7d Rebuild dist 2017-03-25 00:36:11 -07:00
Kyle Shockey 40ccf6aa98 Send spec url to swagger-client 2017-03-25 00:35:52 -07:00
shockey 8b95575449 Merge pull request #2786 from shockey/ft/dist-reorg
Dist reorganization
2017-03-24 22:04:18 -07:00
Kyle Shockey fd8869d845 Rebuild dist 2017-03-24 21:55:26 -07:00
Kyle Shockey 4a81a12f93 Webpack build and Dockerfile updates, to account for new structure 2017-03-24 21:55:17 -07:00
Kyle Shockey 997a31c0b5 Unify index.html files 2017-03-24 21:45:44 -07:00
Kyle Shockey 3eeb73ac48 Swap index.html files 2017-03-24 21:40:06 -07:00
Buu Nguyen 633fa101b9 Merge branch 'master' of https://github.com/swagger-api/swagger-ui
# Conflicts:
#	dist/swagger-ui-bundle.js
#	dist/swagger-ui-bundle.js.map
#	dist/swagger-ui-standalone-preset.js
#	dist/swagger-ui.js
#	dist/swagger-ui.js.map
2017-03-24 10:59:11 -07:00
shockey 2fd371bb36 Merge pull request #2777 from shockey/ft/ie11-polyfills
Add babel-polyfill for older IE support
2017-03-23 17:57:16 -07:00
Kyle Shockey f1be25b258 Add babel-polyfill for older IE support (ping #2762) 2017-03-23 17:54:17 -07:00
shockey f6535911e6 Merge pull request #2776 from shockey/ft/linting-and-testing
Linting and testing
2017-03-23 16:45:12 -07:00
Kyle Shockey ec9c554e25 Re-rebuild dist 2017-03-23 16:44:42 -07:00
Kyle Shockey 8dd23053b2 Merge branch 'master' of github.com:swagger-api/swagger-ui into ft/linting-and-testing 2017-03-23 16:43:37 -07:00
Kyle Shockey fa3afc099f Rebuild dist 2017-03-23 16:42:07 -07:00
Kyle Shockey e1fcbfbf09 Linter error fixes 2017-03-23 16:36:45 -07:00
Kyle Shockey 518551a5dd Bump eslint react version 2017-03-23 15:22:55 -07:00
Ron 19558e7098 Update README.md 2017-03-23 13:15:52 -07:00
Anna 204ea46213 Merge pull request #2766 from bodnia/fixes-xml
fixes for XML render
2017-03-23 19:13:35 +02:00
Ron 27a84014f4 Update README.md 2017-03-23 08:38:08 -07:00
Kyle Shockey c801cd82f3 Make linter more strict 2017-03-22 21:41:39 -07:00
Kyle Shockey f1f239b07b Delete unused AST tests 2017-03-22 21:22:07 -07:00
Kyle Shockey df9e93fc2b Skip failing test for now 2017-03-22 21:21:28 -07:00
Kyle Shockey 95c6393181 Bump react-addons-test-utils version 2017-03-22 21:15:50 -07:00
Kyle Shockey 78c67f9eb1 Refactor window wrapper for node testing 2017-03-22 21:09:36 -07:00
Kyle Shockey f195d01184 Autofix ESLint problems 2017-03-22 20:40:05 -07:00
Kyle Shockey 664e44d3d9 Use correct eslint paths 2017-03-22 20:39:30 -07:00
Kyle Shockey a1cfbfb7bb Wire up testing and linting 2017-03-22 20:35:18 -07:00
Ron 1c9f79c98e Update README.md 2017-03-22 15:12:39 -07:00
Ron eaf183d548 Update README.md 2017-03-22 15:11:10 -07:00
Ron 26b255584c Update README.md 2017-03-22 15:10:37 -07:00
Anna Bodnia 4ebe2273da fixes for XML render 2017-03-22 16:14:20 +02:00
Kyle Shockey bfa7214cdf Rebuild dist 2017-03-21 16:51:39 -07:00
Kyle Shockey 3be5d2cb93 Remove plugin that's breaking Try It Out when host/basePath isn't defined 2017-03-21 16:43:06 -07:00
shockey bdf564ee3a Merge pull request #2750 from Minasokoni/schemes-condition
Added conditional to hide schemes div if no schemes are with in the spec
2017-03-21 11:54:04 -07:00
Buu Nguyen a6a3affff9 Use loadSpec option of latest swagger client 2017-03-20 18:10:31 -07:00
Ron f6f0382102 Merge pull request #2754 from Minasokoni/target-blankv2
Added target=_blank to links in info section
2017-03-20 16:49:45 -07:00
Robert Barnwell d4c632253e Merge branch 'master' into target-blankv2 2017-03-20 16:15:07 -07:00
Minasokoni 2248e02a4d added target=_blank to links in info section 2017-03-20 16:12:59 -07:00
Minasokoni cdb4380dde added conditional for security 2017-03-20 14:35:07 -07:00
Minasokoni 384eeffcaf added conditional to hide schemes div if no schemes are avail 2017-03-20 14:20:58 -07:00
Tony Tam fc50fa7683 Merge pull request #2747 from Minasokoni/styling-fixes
Styling fixes
2017-03-20 12:23:19 -07:00
Robert Barnwell 69a0efa0df Merge branch 'master' into styling-fixes 2017-03-20 11:32:17 -07:00
Minasokoni b6a3310ffc pre wrap fix 2017-03-20 11:30:07 -07:00
Minasokoni 75824afe18 force svg size 2017-03-20 11:28:51 -07:00
Tony Tam 2aa4aa0dd6 Merge pull request #2742 from damianopetrungaro/master
Added missing slash in Dockerfile on ADD section
2017-03-20 06:59:02 -07:00
Damiano Petrungaro a5a65589ce Added missing slash 2017-03-20 09:45:27 +01:00
Ron 1ed71a6081 Update README.md 2017-03-20 00:32:18 -07:00
90 changed files with 902 additions and 696 deletions
+37
View File
@@ -0,0 +1,37 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"extends": ["eslint:recommended", "plugin:react/recommended"],
"plugins": [
"react"
],
"rules": {
"semi": [2, "never"],
"strict": 0,
"quotes": 2,
"no-unused-vars": 2,
"no-multi-spaces": 1,
"camelcase": 1,
"no-use-before-define": [2,"nofunc"],
"no-underscore-dangle": 0,
"no-unused-expressions": 1,
"comma-dangle": 0,
"no-console": ["error", { allow: ["warn", "error"] }],
"react/jsx-no-bind": 1,
"react/display-name": 0
}
}
+1
View File
@@ -3,3 +3,4 @@ node_modules
.deps_check
.DS_Store
npm-debug.log
.eslintcache
+25
View File
@@ -1,11 +1,15 @@
language: node_js
node_js:
- '6.9'
services:
- docker
branches:
only:
- master
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
before_deploy: "npm run build-core"
env:
- DOCKER_IMAGE_NAME=swaggerapi/swagger-ui
deploy:
provider: npm
email: apiteam@swagger.io
@@ -16,3 +20,24 @@ deploy:
tags: true
repo: swagger-api/swagger-ui
node: '6.9'
after_success:
- if [ $DOCKER_HUB_USERNAME ]; then
docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD;
if [ ! -z "$TRAVIS_TAG" ]; then
DOCKER_IMAGE_TAG=$TRAVIS_TAG;
else
DOCKER_IMAGE_TAG=unstable;
fi;
docker build -t $DOCKER_IMAGE_NAME .;
if [ ! -z "$TRAVIS_TAG" ]; then
docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
docker push $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:latest;
docker push $DOCKER_IMAGE_NAME:latest;
else
docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
fi;
fi;
+15 -6
View File
@@ -2,18 +2,27 @@ FROM alpine:3.4
MAINTAINER fehguy
ENV VERSION "v2.2.10"
ENV FOLDER "swagger-ui-2.2.10"
ENV API_URL "http://petstore.swagger.io/v2/swagger.json"
ENV API_KEY "**None**"
ENV OAUTH_CLIENT_ID "**None**"
ENV OAUTH_CLIENT_SECRET "**None**"
ENV OAUTH_REALM "**None**"
ENV OAUTH_APP_NAME "**None**"
ENV OAUTH_ADDITIONAL_PARAMS "**None**"
ENV SWAGGER_JSON "/app/swagger.json"
ENV PORT 80
RUN apk add --update nginx
RUN mkdir -p /run/nginx
COPY nginx.conf /etc/nginx/
# copy swagger files to the `/js` folder
ADD ./dist/ /usr/share/nginx/html/js
ADD ./public/* /usr/share/nginx/html
# change the folder structure
RUN sed -i 's/\.\.\/dist/js/g' /usr/share/nginx/html/index.html
ADD ./dist/* /usr/share/nginx/html/
ADD ./docker-run.sh /usr/share/nginx/
EXPOSE 8080
CMD exec nginx -g 'daemon off;'
CMD ["sh", "/usr/share/nginx/docker-run.sh"]
+46 -4
View File
@@ -4,7 +4,9 @@
## New!
This is the new version of swagger-ui, 3.x.
**This is the new version of swagger-ui, 3.x. Want to learn more? Check out our [FAQ](http://swagger.io/new-ui-faq/).**
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.
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
@@ -13,7 +15,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.2 | 2017-03-19 | 2.0 | [tag v3.0.2](https://github.com/swagger-api/swagger-ui/tree/v3.0.2) |
3.0.6 | 2017-03-19 | 2.0 | [tag v3.0.6](https://github.com/swagger-api/swagger-ui/tree/v3.0.6) |
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) |
@@ -37,14 +39,54 @@ Will start nginx with swagger-ui on port 80.
- Node 6.x
- NPM 3.x
If you just want to see your specs, open `public/index.html` in your browser directly from your filesystem.
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`.
##### Browser support
Swagger UI works in the latest versions of Chrome, Safari, Firefox, Edge and IE11.
### Known Issues
To help with the migration, here are the currently known issues with 3.X. This list will update regularly, and will not include features that were not implemented in previous versions.
- Only part of the [parameters](#parameters) previously supported are available.
- The JSON Form Editor is not implemented.
- Shebang URL support for operations is missing.
- Support for `collectionFormat` is partial.
- l10n (translations) is not implemented.
- Relative path support for external files is not implemented.
### SwaggerUIBundle
To use swagger-ui 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 and call load() on it as below:
```javascript
const ui = SwaggerUIBundle({
url: "http://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
```
#### Parameters
Parameter Name | Description
--- | ---
url | The url pointing to API definition (normally `swagger.json` or `swagger.yaml`).
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.
oauth2RedirectUrl | OAuth redirect URL
## CORS Support
CORS is a technique to prevent websites from doing bad things with your personal data. Most browsers + JavaScript toolkits not only support CORS but enforce it, which has implications for your API server which supports Swagger.
+40
View File
@@ -0,0 +1,40 @@
{
"name": "swagger-api/swagger-ui",
"description": " Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.",
"keywords": [
"Swagger",
"OpenAPI",
"specification",
"documentation",
"API",
"UI"
],
"homepage": "http://swagger.io",
"license": "Apache-2.0",
"authors": [
{
"name": "Anna Bodnia",
"email": "anna.bodnia@gmail.com"
},
{
"name": "Buu Nguyen",
"email": "buunguyen@gmail.com"
},
{
"name": "Josh Ponelat",
"email": "jponelat@gmail.com"
},
{
"name": "Kyle Shockey",
"email": "kyleshockey1@gmail.com"
},
{
"name": "Robert Barnwell",
"email": "robert@robertismy.name"
},
{
"name": "Sahar Jafari",
"email": "shr.jafari@gmail.com"
}
]
}
+9 -7
View File
@@ -1,12 +1,13 @@
<!-- HTML for dev server -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="../dist/swagger-ui.css" >
<link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16" />
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
@@ -66,18 +67,19 @@
<div id="swagger-ui"></div>
<script src="../dist/swagger-ui-bundle.js"> </script>
<script src="../dist/swagger-ui-standalone-preset.js"> </script>
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
// Build a system
const ui = SwaggerUIBundle({
url: "http://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
// yay ES6 modules ↘
Array.isArray(SwaggerUIStandalonePreset) ? SwaggerUIStandalonePreset : SwaggerUIStandalonePreset.default
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl

Before

Width:  |  Height:  |  Size: 445 B

After

Width:  |  Height:  |  Size: 445 B

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

+8 -7
View File
@@ -1,10 +1,13 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<!-- this is for the dev server -->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
@@ -64,9 +67,8 @@
<div id="swagger-ui"></div>
<!-- don't be alarmed, these don't match what's in dist, because webpack-dev-server serves them in memory. -->
<script src="/dist/SwaggerUIBundle.js"> </script>
<script src="/dist/SwaggerUIStandalonePreset.js"> </script>
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Build a system
@@ -75,8 +77,7 @@ window.onload = function() {
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
// yay ES6 modules ↘
Array.isArray(SwaggerUIStandalonePreset) ? SwaggerUIStandalonePreset : SwaggerUIStandalonePreset.default
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
@@ -89,4 +90,4 @@ window.onload = function() {
</script>
</body>
</html>
</html>
+46 -45
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;;;;;;;;;;;;;;;;;;;;;;;;;;AAoOA;;;;;;AAoIA;AAm7FA;AAwtCA;AAg0IA;;;;;AAkxBA;AA+7IA;AAi2GA;AA43FA;AA6oFA;AAipFA;AA+9CA;AA0gDA;AA0rCA;AA80EA;AAs4HA;;;;;;;;;;;;;;AA8kHA;AAyoIA;AAkuJA;AAilHA;AA4kGA;AAwkEA;AAs3DA;AAovDA;AA0tBA;AA+pGA;;;;;;AAseA;AAimGA;AA44EA;;;;;AAoGA;AA2qFA;AAm2CA;AAmvDA;AAwtCA;AAuiEA;AA29FA;;;;;;;;;AA00BA;AA2zIA;AAm4DA","sourceRoot":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0dA;AAkoJA;AAyiCA;;;;;AAskCA;AA66IA;AA20FA;AAg3GA;AAonEA;AA+9CA;AA6/CA;AA+rCA;AA+3EA;AA68HA;;;;;;;;;;;;;;AA8tGA;AAyoIA;AAiuJA;AA8kHA;AAonGA;AAukEA;AA02DA;AAyxDA;AAw6BA;;;;;;AAs0EA;AA24FA;;;;;AAy3CA;AA2qFA;AAw2CA;AA2kCA;AAq/CA;AAwwEA;AA48FA;;;;;;;;;AA81BA;AA2zIA;AAi4DA;AAqlDA;;;;;;AA4kCA;AA8iHA;AAipGA","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;;;;;AAwSA;AAyiGA","sourceRoot":""}
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA6PA;AAyiGA","sourceRoot":""}
+1 -1
View File
File diff suppressed because one or more lines are too long
+14 -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;AAqnGA;AAi2HA;AA6+FA;AAgqCA;AAi+BA;AAyvCA;AA84BA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAuwCA;AAoyHA;AAmxHA;AAo8FA;AAooCA;AAghCA;AA0gCA;AA06BA","sourceRoot":""}
+45
View File
@@ -0,0 +1,45 @@
#! /bin/sh
set -e
INDEX_FILE=/usr/share/nginx/html/index.html
replace_in_index () {
if [ "$1" != "**None**" ]; then
sed -i "s|/\*||g" $INDEX_FILE
sed -i "s|\*/||g" $INDEX_FILE
sed -i "s|$1|$2|g" $INDEX_FILE
fi
}
replace_or_delete_in_index () {
if [ -z "$2" ]; then
sed -i "/$1/d" $INDEX_FILE
else
replace_in_index $1 $2
fi
}
replace_in_index myApiKeyXXXX123456789 $API_KEY
replace_or_delete_in_index your-client-id $OAUTH_CLIENT_ID
replace_or_delete_in_index your-client-secret-if-required $OAUTH_CLIENT_SECRET
replace_or_delete_in_index your-realms $OAUTH_REALM
replace_or_delete_in_index your-app-name $OAUTH_APP_NAME
if [ "$OAUTH_ADDITIONAL_PARAMS" != "**None**" ]; then
replace_in_index "additionalQueryStringParams: {}" "additionalQueryStringParams: {$OAUTH_ADDITIONAL_PARAMS}"
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
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
fi
if [[ -n "$VALIDATOR_URL" ]]; then
sed -i "s|.*validatorUrl:.*$||g" $INDEX_FILE
sed -i "s|\(url: url,.*\)|\1\n validatorUrl: \"${VALIDATOR_URL}\",|g" $INDEX_FILE
fi
exec nginx -g 'daemon off;'
+23 -10
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.0.2",
"version": "3.0.6",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -22,22 +22,26 @@
"dev": "npm-run-all --parallel hot-server watch 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 dist/",
"hot-server": "webpack-dev-server --host 0.0.0.0 --config webpack-hot-dev-server.config.js --inline --hot --progress --content-base dev-helpers/",
"deps-license": "license-checker --production --csv --out $npm_package_config_deps_check_dir/licenses.csv && license-checker --development --csv --out $npm_package_config_deps_check_dir/licenses-dev.csv",
"deps-size": "webpack -p --config webpack.check.js --json | webpack-bundle-size-analyzer >| $npm_package_config_deps_check_dir/sizes.txt",
"deps-check": "npm run deps-license && npm run deps-size",
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core"
"lint": "eslint --cache --ext '.js,.jsx' src test",
"lint-errors": "eslint --cache --quiet --ext '.js,.jsx' src test",
"lint-fix": "eslint --cache --ext '.js,.jsx' src test --fix",
"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"
},
"dependencies": {
"babel-polyfill": "^6.23.0",
"brace": "0.7.0",
"btoa": "^1.1.2",
"debounce": "1.0.0",
"deep-extend": "0.4.1",
"expect": "1.20.2",
"getbase": "^2.8.2",
"immutable": "^3.x.x",
"js-yaml": "^3.5.5",
"jsonschema": "^1.1.0",
"less": "2.7.1",
"lodash": "4.17.2",
"matcher": "^0.1.2",
@@ -46,7 +50,7 @@
"react": "^15.4.0",
"react-addons-perf": "0.14.8",
"react-addons-shallow-compare": "0.14.8",
"react-addons-test-utils": "0.14.8",
"react-addons-test-utils": "^15.4.0",
"react-collapse": "2.3.1",
"react-dom": "^15.4.0",
"react-height": "^2.0.0",
@@ -63,12 +67,12 @@
"reselect": "2.5.3",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "^3.0.2",
"swagger-client": "^3.0.5",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
"xml": "1.0.1",
"yaml-js": "^0.1.3",
"yaml-worker": "^2.1.0"
"yaml-js": "^0.1.3"
},
"devDependencies": {
"autoprefixer": "6.6.1",
@@ -84,11 +88,19 @@
"css-loader": "0.22.0",
"deep-extend": "^0.4.1",
"deepmerge": "^1.3.2",
"enzyme": "^2.7.1",
"eslint": "^2.13.1",
"eslint-plugin-react": "^6.10.3",
"extract-text-webpack-plugin": "0.8.2",
"file-loader": "0.8.4",
"html-webpack-plugin": "^2.28.0",
"imports-loader": "0.6.5",
"json-loader": "0.5.3",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-mocha": "^0.2.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "1.8.0",
"less": "2.5.3",
"less-loader": "2.2.1",
"license-checker": "^8.0.4",
@@ -100,6 +112,7 @@
"postcss-loader": "0.7.0",
"raw-loader": "0.5.1",
"react-hot-loader": "^1.3.1",
"react-test-renderer": "^15.5.4",
"rimraf": "^2.6.0",
"sass-loader": "^6.0.2",
"standard": "^8.6.0",
+1 -1
View File
@@ -6,7 +6,7 @@ export default class AuthorizeBtn extends React.Component {
}
onClick =() => {
let { authActions, authSelectors, errActions} = this.props
let { authActions, authSelectors } = this.props
let definitions = authSelectors.definitionsToAuthorize()
authActions.showDefinitions(definitions)
@@ -16,6 +16,10 @@ export default class AuthorizeOperationBtn extends React.Component {
let isAuthorized = authSelectors.isAuthorized(security)
if(isAuthorized === null) {
return null
}
return (
<button className={isAuthorized ? "authorization__btn locked" : "authorization__btn unlocked"} onClick={ this.onClick }>
<svg width="20" height="20">
+1 -3
View File
@@ -42,14 +42,12 @@ export default class Auths extends React.Component {
}
render() {
let { definitions, getComponent, authSelectors, errSelectors, specSelectors } = this.props
let { definitions, getComponent, authSelectors, errSelectors } = this.props
const ApiKeyAuth = getComponent("apiKeyAuth")
const BasicAuth = getComponent("basicAuth")
const Oauth2 = getComponent("oauth2", true)
const Button = getComponent("Button")
const JumpToPath = getComponent("JumpToPath", true)
let specStr = specSelectors.specStr()
let authorized = authSelectors.authorized()
let authorizedAuth = definitions.filter( (definition, key) => {
+6 -6
View File
@@ -10,13 +10,13 @@ export default class Oauth2 extends React.Component {
static propTypes = {
name: PropTypes.string,
authorized: PropTypes.object,
configs: PropTypes.object,
getComponent: PropTypes.func.isRequired,
schema: PropTypes.object.isRequired,
authSelectors: PropTypes.object.isRequired,
authActions: PropTypes.object.isRequired,
errSelectors: PropTypes.object.isRequired,
errActions: PropTypes.object.isRequired
errActions: PropTypes.object.isRequired,
getConfigs: PropTypes.any
}
constructor(props, context) {
@@ -145,7 +145,7 @@ export default class Oauth2 extends React.Component {
}
{
( flow === IMPLICIT || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) &&
( flow === APPLICATION || flow === IMPLICIT || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) &&
( !isAuthorized || isAuthorized && this.state.clientId) && <Row>
<label htmlFor="client_id">client_id:</label>
<Col tablet={10} desktop={10}>
@@ -159,7 +159,7 @@ export default class Oauth2 extends React.Component {
}
{
( flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) && <Row>
( flow === APPLICATION || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) && <Row>
<label htmlFor="client_secret">client_secret:</label>
<Col tablet={10} desktop={10}>
{
@@ -172,7 +172,7 @@ export default class Oauth2 extends React.Component {
}
{
!isAuthorized && flow !== PASSWORD && scopes && scopes.size ? <div className="scopes">
!isAuthorized && scopes && scopes.size ? <div className="scopes">
<h2>Scopes:</h2>
{ scopes.map((description, name) => {
return (
@@ -205,7 +205,7 @@ export default class Oauth2 extends React.Component {
} )
}
<div className="auth-btn-wrapper">
{ isValid && flow !== APPLICATION &&
{ isValid &&
( isAuthorized ? <Button className="btn modal-btn auth authorize" onClick={ this.logout }>Logout</Button>
: <Button className="btn modal-btn auth authorize" onClick={ this.authorize }>Authorize</Button>
)
+1 -1
View File
@@ -1,6 +1,6 @@
import React, { PropTypes } from "react"
import ImPropTypes from "react-immutable-proptypes"
import { fromJS } from 'immutable'
import { fromJS } from "immutable"
const noop = ()=>{}
+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" }} defaultValue={curl}></textarea>
<textarea onFocus={this.handleFocus} className="curl" style={{ whiteSpace: "normal" }} value={curl}></textarea>
</div>
</div>
)
+19 -4
View File
@@ -1,7 +1,6 @@
import React, { PropTypes } from "react"
import Im, { List } from "immutable"
import { List } from "immutable"
import Collapse from "react-collapse"
import sortBy from "lodash/sortBy"
export default class Errors extends React.Component {
@@ -69,7 +68,7 @@ const ThrownErrorItem = ( { error, jumpToLine } ) => {
{ error.get("message") }
</span>
<div>
{ errorLine ? <a onClick={jumpToLine.bind(null, errorLine)}>Jump to line { errorLine }</a> : null }
{ errorLine && jumpToLine ? <a onClick={jumpToLine.bind(null, errorLine)}>Jump to line { errorLine }</a> : null }
</div>
</div>
}
@@ -78,11 +77,23 @@ const ThrownErrorItem = ( { error, jumpToLine } ) => {
}
const SpecErrorItem = ( { error, jumpToLine } ) => {
let locationMessage = null
if(error.get("path")) {
if(List.isList(error.get("path"))) {
locationMessage = <small>at { error.get("path").join(".") }</small>
} else {
locationMessage = <small>at { error.get("path") }</small>
}
} else if(error.get("line") && !jumpToLine) {
locationMessage = <small>on line { error.get("line") }</small>
}
return (
<div className="error-wrapper">
{ !error ? null :
<div>
<h4>{ toTitleCase(error.get("source")) + " " + error.get("level") }{ error.get("path") ? <small> at {List.isList(error.get("path")) ? error.get("path").join(".") : error.get("path")}</small>: null }</h4>
<h4>{ toTitleCase(error.get("source")) + " " + error.get("level") }&nbsp;{ locationMessage }</h4>
<span style={{ whiteSpace: "pre-line"}}>{ error.get("message") }</span>
<div>
{ jumpToLine ? (
@@ -107,6 +118,10 @@ ThrownErrorItem.propTypes = {
jumpToLine: PropTypes.func
}
ThrownErrorItem.defaultProps = {
jumpToLine: null
}
SpecErrorItem.propTypes = {
error: PropTypes.object.isRequired,
jumpToLine: PropTypes.func
-4
View File
@@ -1,5 +1,4 @@
import React, { Component, PropTypes } from "react"
import { fromJS } from "immutable"
export default class Execute extends Component {
@@ -29,9 +28,6 @@ export default class Execute extends Component {
onChangeProducesWrapper = ( val ) => this.props.specActions.changeProducesValue([this.props.path, this.props.method], val)
render(){
let { getComponent, operation, specActions, path, method } = this.props
const ContentType = getComponent( "contentType" )
return (
<button className="btn execute opblock-control__btn" onClick={ this.onClick }>
Execute
+3 -3
View File
@@ -58,7 +58,7 @@ class License extends React.Component {
return (
<div>
{
url ? <a href={ url }>{ name }</a>
url ? <a target="_blank" href={ url }>{ name }</a>
: <span>{ name }</span>
}
</div>
@@ -95,7 +95,7 @@ export default class Info extends React.Component {
{ version && <small><pre className="version"> { version } </pre></small> }
</h2>
{ host || basePath ? <Path host={ host } basePath={ basePath } /> : null }
{ url && <a href={ url }><span className="url"> { url } </span></a> }
{ url && <a target="_blank" href={ url }><span className="url"> { url } </span></a> }
</hgroup>
<div className="description">
@@ -104,7 +104,7 @@ export default class Info extends React.Component {
{
termsOfService && <div>
<a href={ termsOfService }>Terms of service</a>
<a target="_blank" href={ termsOfService }>Terms of service</a>
</div>
}
+5 -5
View File
@@ -2,8 +2,6 @@ import React, { PropTypes } from "react"
import OriCollapse from "react-collapse"
import _Markdown from "react-remarkable"
const noop = () => {}
function xclass(...args) {
return args.filter(a => !!a).join(" ").trim()
}
@@ -44,12 +42,14 @@ export class Col extends React.Component {
const {
hide,
keepContents,
mobile, /* we don't want these in the final component, since React now complains. So we extract them */
/* we don't want these in the `rest` object that passes to the final component,
since React now complains. So we extract them */
/* eslint-disable no-unused-vars */
mobile,
tablet,
desktop,
large,
/* eslint-enable no-unused-vars */
...rest
} = this.props
+80
View File
@@ -0,0 +1,80 @@
import React, { PropTypes } from "react"
export default class BaseLayout extends React.Component {
static propTypes = {
errSelectors: PropTypes.object.isRequired,
errActions: PropTypes.object.isRequired,
specActions: PropTypes.object.isRequired,
specSelectors: PropTypes.object.isRequired,
layoutSelectors: PropTypes.object.isRequired,
layoutActions: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired
}
render() {
let { specSelectors, specActions, getComponent } = this.props
let info = specSelectors.info()
let url = specSelectors.url()
let basePath = specSelectors.basePath()
let host = specSelectors.host()
let securityDefinitions = specSelectors.securityDefinitions()
let externalDocs = specSelectors.externalDocs()
let schemes = specSelectors.schemes()
let Info = getComponent("info")
let Operations = getComponent("operations", true)
let Models = getComponent("models", true)
let AuthorizeBtn = getComponent("authorizeBtn", true)
let Row = getComponent("Row")
let Col = getComponent("Col")
let Errors = getComponent("errors", true)
const Schemes = getComponent("schemes")
const isSpecEmpty = !specSelectors.specStr()
if(isSpecEmpty) {
return <h4>No spec provided.</h4>
}
return (
<div className='swagger-ui'>
<div>
<Errors/>
<Row className="information-container">
<Col mobile={12}>
{ info.count() ? (
<Info info={ info } url={ url } host={ host } basePath={ basePath } externalDocs={externalDocs} getComponent={getComponent}/>
) : null }
</Col>
</Row>
{ schemes && schemes.size || securityDefinitions ? (
<div className="scheme-container">
<Col className="schemes wrapper" mobile={12}>
{ schemes && schemes.size ? (
<Schemes schemes={ schemes } specActions={ specActions } />
) : null }
{ securityDefinitions ? (
<AuthorizeBtn />
) : null }
</Col>
</div>
) : null }
<Row>
<Col mobile={12} desktop={12} >
<Operations/>
</Col>
</Row>
<Row>
<Col mobile={12} desktop={12} >
<Models/>
</Col>
</Row>
</div>
</div>
)
}
}
+14 -7
View File
@@ -1,10 +1,11 @@
import React, { Component, PropTypes } from "react"
import ImPropTypes from "react-immutable-proptypes"
import isObject from "lodash/isObject"
import { List } from "immutable"
const braceOpen = "{"
const braceClose = "}"
const propStyle = { color: "#999", fontStyle: "italic" }
const EnumModel = ({ value }) => {
let collapsedContent = <span>Array [ { value.count() } ]</span>
return <span className="prop-enum">
@@ -128,10 +129,8 @@ class Primitive extends Component {
let format = schema.get("format")
let xml = schema.get("xml")
let enumArray = schema.get("enum")
let description = schema.get("description")
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "$$ref"].indexOf(key) === -1 )
let style = required ? { fontWeight: "bold" } : {}
let propStyle = { color: "#999", fontStyle: "italic" }
return <span className="prop">
<span className="prop-type" style={ style }>{ type }</span> { required && <span style={{ color: "red" }}>*</span>}
@@ -169,12 +168,23 @@ class ArrayModel extends Component {
render(){
let { required, schema, depth, expandDepth } = this.props
let items = schema.get("items")
let properties = schema.filter( ( v, key) => ["type", "items", "$$ref"].indexOf(key) === -1 )
return <span>
return <span className="model">
<span className="model-title">
<span className="model-title__text">{ schema.get("title") }</span>
</span>
<Collapse collapsed={ depth > expandDepth } collapsedContent="[...]">
[
<span><Model { ...this.props } schema={ items } required={ false }/></span>
]
{
properties.size ? <span>
{ properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={propStyle}>
<br />{ `${key}:`}{ String(v) }</span>)
}<br /></span>
: null
}
</Collapse>
{ required && <span style={{ color: "red" }}>*</span>}
</span>
@@ -251,9 +261,6 @@ export default class ModelComponent extends Component {
}
render(){
let { name, schema } = this.props
let title = schema.get("title") || name
return <div className="model-box">
<Model { ...this.props } depth={ 1 } expandDepth={ this.props.expandDepth || 0 }/>
</div>
+5 -3
View File
@@ -4,13 +4,15 @@ import React, { Component, PropTypes } from "react"
export default class Models extends Component {
static propTypes = {
getComponent: PropTypes.func,
specSelectors: PropTypes.object
specSelectors: PropTypes.object,
layoutSelectors: PropTypes.object,
layoutActions: PropTypes.object
}
render(){
let { specSelectors, getComponent, layoutSelectors, layoutActions } = this.props
let definitions = specSelectors.definitions()
let showModels = layoutSelectors.isShown('models', true)
let showModels = layoutSelectors.isShown("models", true)
const Model = getComponent("model")
const Collapse = getComponent("Collapse")
@@ -18,7 +20,7 @@ export default class Models extends Component {
if (!definitions.size) return null
return <section className={ showModels ? "models is-open" : "models"}>
<h4 onClick={() => layoutActions.show('models', !showModels)}>
<h4 onClick={() => layoutActions.show("models", !showModels)}>
<span>Models</span>
<svg width="20" height="20">
<use xlinkHref="#large-arrow" />
+70 -6
View File
@@ -1,13 +1,19 @@
import React from "react"
import React, { PropTypes } from "react"
export default class OnlineValidatorBadge extends React.Component {
static propTypes = {
getComponent: PropTypes.func.isRequired,
getConfigs: PropTypes.func.isRequired,
specSelectors: PropTypes.object.isRequired
}
constructor(props, context) {
super(props, context)
let { specSelectors, getConfigs } = props
let { validatorUrl } = getConfigs()
this.state = {
url: specSelectors.url(),
validatorUrl: validatorUrl || "https://online.swagger.io/validator"
validatorUrl: validatorUrl === undefined ? "https://online.swagger.io/validator" : validatorUrl
}
}
@@ -17,7 +23,7 @@ export default class OnlineValidatorBadge extends React.Component {
this.setState({
url: specSelectors.url(),
validatorUrl: validatorUrl || "https://online.swagger.io/validator"
validatorUrl: validatorUrl === undefined ? "https://online.swagger.io/validator" : validatorUrl
})
}
@@ -27,14 +33,72 @@ export default class OnlineValidatorBadge extends React.Component {
if ( typeof spec === "object" && Object.keys(spec).length) return null
if (!this.state.url) {
if (!this.state.url || !this.state.validatorUrl || this.state.url.indexOf("localhost") >= 0
|| this.state.url.indexOf("127.0.0.1") >= 0) {
return null
}
return (<span style={{ float: "right"}}>
return (<span style={{ float: "right"}}>
<a target="_blank" href={`${ this.state.validatorUrl }/debug?url=${ this.state.url }`}>
<img alt="Online validator badge" src={`${ this.state.validatorUrl }?url=${ this.state.url }`} />
<ValidatorImage src={`${ this.state.validatorUrl }?url=${ this.state.url }`} alt="Online validator badge"/>
</a>
</span>)
}
}
class ValidatorImage extends React.Component {
static propTypes = {
src: PropTypes.string,
alt: PropTypes.string
}
constructor(props) {
super(props)
this.state = {
loaded: false,
error: false
}
}
componentDidMount() {
const img = new Image()
img.onload = () => {
this.setState({
loaded: true
})
}
img.onerror = () => {
this.setState({
error: true
})
}
img.src = this.props.src
}
componentWillReceiveProps(nextProps) {
if (nextProps.src !== this.props.src) {
const img = new Image()
img.onload = () => {
this.setState({
loaded: true
})
}
img.onerror = () => {
this.setState({
error: true
})
}
img.src = nextProps.src
}
}
render() {
if (this.state.error) {
return <img alt={"Error"} />
} else if (!this.state.loaded) {
return <img alt= {"Loading..."} />
}
return <img src={this.props.src} alt={this.props.alt} />
}
}
+7 -9
View File
@@ -1,5 +1,4 @@
import React, { PropTypes } from "react"
import { Map, fromJS } from "immutable"
import shallowCompare from "react-addons-shallow-compare"
import { getList } from "core/utils"
import * as CustomPropTypes from "core/proptypes"
@@ -112,9 +111,7 @@ export default class Operation extends React.Component {
specActions,
specSelectors,
authActions,
authSelectors,
layoutSelectors,
layoutActions,
authSelectors
} = this.props
let summary = operation.get("summary")
@@ -205,11 +202,12 @@ export default class Operation extends React.Component {
pathMethod={ [path, method] }
/>
{!tryItOutEnabled || !allowTryItOut ? null : schemes && schemes.size ? <Schemes schemes={ schemes }
path={ path }
method={ method }
specActions={ specActions }/>
: null
{!tryItOutEnabled || !allowTryItOut ? null : schemes && schemes.size ? <div className="opblock-schemes">
<Schemes schemes={ schemes }
path={ path }
method={ method }
specActions={ specActions }/>
</div> : null
}
<div className={(!tryItOutEnabled || !response || !allowTryItOut) ? "execute-wrapper" : "btn-group"}>
-2
View File
@@ -1,5 +1,4 @@
import React, { PropTypes } from "react"
import {presets} from "react-motion"
export default class Operations extends React.Component {
@@ -33,7 +32,6 @@ export default class Operations extends React.Component {
const Operation = getComponent("operation")
const Collapse = getComponent("Collapse")
const Schemes = getComponent("schemes")
let showSummary = layoutSelectors.showSummary()
+1 -2
View File
@@ -30,7 +30,6 @@ export default class Overview extends React.Component {
{
taggedOps.map( (tagObj, tag) => {
let operations = tagObj.get("operations")
let tagDetails = tagObj.get("tagDetails")
let showTagId = ["overview-tags", tag]
let showTag = layoutSelectors.isShown(showTagId, true)
@@ -45,7 +44,7 @@ export default class Overview extends React.Component {
<Collapse isOpened={showTag} animated>
{
operations.map( op => {
let { path, method, operation, id } = op.toObject() // toObject is shallow
let { path, method, id } = op.toObject() // toObject is shallow
let showOpIdPrefix = "operations"
let showOpId = id
let shown = layoutSelectors.isShown([showOpIdPrefix, showOpId])
+2 -2
View File
@@ -1,6 +1,6 @@
import React, { Component, PropTypes } from "react"
import shallowCompare from "react-addons-shallow-compare"
import { Set, fromJS, List } from "immutable"
import { fromJS, List } from "immutable"
import { getSampleSchema } from "core/utils"
const NOOP = Function.prototype
@@ -50,7 +50,7 @@ export default class ParamBody extends Component {
}
updateValues = (props) => {
let { specSelectors, pathMethod, param, isExecute, consumesValue="", onChangeConsumes } = props
let { specSelectors, pathMethod, param, isExecute, consumesValue="" } = props
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name")) : {}
let isXml = /xml/i.test(consumesValue)
let paramValue = isXml ? parameter.get("value_xml") : parameter.get("value")
+2 -2
View File
@@ -1,6 +1,6 @@
import React, { Component, PropTypes } from "react"
import ImPropTypes from "react-immutable-proptypes"
import Im, { fromJS } from "immutable"
import Im from "immutable"
// More readable, just iterate over maps, only
const eachMap = (iterable, fn) => iterable.valueSeq().filter(Im.Map.isMap).map(fn)
@@ -87,7 +87,7 @@ export default class Parameters extends Component {
</thead>
<tbody>
{
eachMap(parameters, (parameter, k) => (
eachMap(parameters, (parameter) => (
<ParameterRow fn={ fn }
getComponent={ getComponent }
param={ parameter }
+10 -2
View File
@@ -1,13 +1,21 @@
import React, { PropTypes } from "react"
import { fromJS } from 'immutable'
import { fromJS } from "immutable"
import { getSampleSchema } from "core/utils"
const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
if ( examples && examples.size ) {
return examples.entrySeq().map( ([ key, example ]) => {
let exampleValue
try {
exampleValue = example && example.toJS ? example.toJS() : example
exampleValue = JSON.stringify(exampleValue)
}
catch(e) {
exampleValue = String(example)
}
return (<div key={ key }>
<h5>{ key }</h5>
<HighlightCode className="example" value={ example } />
<HighlightCode className="example" value={ exampleValue } />
</div>)
}).toArray()
}
+1 -3
View File
@@ -17,8 +17,6 @@ export default class Schemes extends React.Component {
}
onChange =( e ) => {
let { path, method, specActions } = this.props
this.setScheme( e.target.value )
}
@@ -33,7 +31,7 @@ export default class Schemes extends React.Component {
return (
<label htmlFor="schemes">
<span>Schemes</span>
<span className="schemes-title">Schemes</span>
<select onChange={ this.onChange }>
{ schemes.valueSeq().map(
( scheme ) => <option value={ scheme } key={ scheme }>{ scheme }</option>
@@ -4,11 +4,13 @@ export default class TryItOutButton extends React.Component {
static propTypes = {
onTryoutClick: PropTypes.func,
onCancelClick: PropTypes.func,
enabled: PropTypes.bool, // Try it out is enabled, ie: the user has access to the form
};
static defaultProps = {
onTryoutClick: Function.prototype,
onCancelClick: Function.prototype,
enabled: false,
};
+1 -1
View File
@@ -4,7 +4,7 @@ export default function curl( request ){
let headers = request.get("headers")
curlified.push( "curl" )
curlified.push( "-X", request.get("method") )
curlified.push( request.get("url") )
curlified.push( `"${request.get("url")}"`)
if ( headers && headers.size ) {
for( let p of request.get("headers").entries() ){
+17 -13
View File
@@ -13,9 +13,9 @@ module.exports = function SwaggerUI(opts) {
dom_id: null,
spec: {},
url: "",
layout: "Layout",
layout: "BaseLayout",
validatorUrl: "https://online.swagger.io/validator",
configs: {
validatorUrl: "https://online.swagger.io/validator"
},
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
@@ -68,22 +68,24 @@ module.exports = function SwaggerUI(opts) {
var system = store.getSystem()
let queryConfig = parseSeach()
const downloadSpec = (configs) => {
const downloadSpec = (fetchedConfig) => {
if(typeof constructorConfig !== "object") {
return system
}
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
let mergedConfig = deepExtend({}, constructorConfig, localConfig, queryConfig)
let mergedConfig = deepExtend({}, constructorConfig, localConfig, fetchedConfig || {}, queryConfig)
store.setConfigs(filterConfigs(mergedConfig))
if(!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
system.specActions.updateUrl("")
system.specActions.updateLoadingStatus("success");
system.specActions.updateSpec(JSON.stringify(mergedConfig.spec))
} else if(system.specActions.download && mergedConfig.url) {
system.specActions.updateUrl(mergedConfig.url)
system.specActions.download(mergedConfig.url)
if (fetchedConfig !== null) {
if (!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
system.specActions.updateUrl("")
system.specActions.updateLoadingStatus("success")
system.specActions.updateSpec(JSON.stringify(mergedConfig.spec))
} else if (system.specActions.download && mergedConfig.url) {
system.specActions.updateUrl(mergedConfig.url)
system.specActions.download(mergedConfig.url)
}
}
if(mergedConfig.dom_id) {
@@ -95,8 +97,10 @@ module.exports = function SwaggerUI(opts) {
return system
}
if (!system.specActions.getConfigByUrl || (system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(downloadSpec))) {
return downloadSpec(constructorConfig)
let configUrl = queryConfig.config || constructorConfig.configUrl
if (!configUrl || !system.specActions.getConfigByUrl || system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(configUrl, downloadSpec)) {
return downloadSpec()
}
}
+3 -5
View File
@@ -1,8 +1,6 @@
import React, { PropTypes, Component } from "react"
import { arrayify } from "core/utils"
import shallowCompare from "react-addons-shallow-compare"
import { List, fromJS } from "immutable"
import assign from "object-assign"
//import "less/json-schema-form"
const noop = ()=> {}
@@ -53,7 +51,7 @@ export class JsonSchema_string extends Component {
}
onEnumChange = (val) => this.props.onChange(val)
render() {
let { getComponent, value, schema, fn, required, description } = this.props
let { getComponent, value, schema, required, description } = this.props
let enumValue = schema["enum"]
let errors = schema.errors || []
@@ -119,13 +117,13 @@ export class JsonSchema_array extends Component {
}
onEnumChange = (value) => {
this.setState(state => ({
this.setState(() => ({
value: value
}), this.onChange)
}
render() {
let { getComponent, onChange, required, schema, fn } = this.props
let { getComponent, required, schema, fn } = this.props
let itemSchema = fn.inferSchema(schema.items)
+5
View File
@@ -14,6 +14,11 @@ export default function authorize ( auth, authActions, errActions, configs ) {
return
}
if (flow === "application") {
authActions.authorizeOauth2Application(auth)
return
}
// todo move to parser
if ( !redirectUrl ) {
errActions.newAuthErr( {
+1 -1
View File
@@ -26,7 +26,7 @@ export function transformPathToArray(property, jsSpec) {
return a.concat(b)
}, [])
.concat([""]) // add an empty item into the array, so we don't get stuck with something in our buffer below
.reduce((buffer, curr, i, arr) => {
.reduce((buffer, curr) => {
let obj = pathArr.length ? get(jsSpec, pathArr) : jsSpec
if(get(obj, makeAccessArray(buffer, curr))) {
@@ -1,36 +0,0 @@
import React, { PropTypes } from "react"
export default function (system) {
return {
components: {
NoHostWarning,
},
statePlugins: {
spec: {
selectors: {
allowTryItOutFor,
}
}
}
}
}
// This is a quick style. How do we improve this?
const style = {
backgroundColor: "#e7f0f7",
padding: "1rem",
borderRadius: "3px",
}
function NoHostWarning() {
return (
<div style={style}>Note: The interactive forms are disabled, as no `host` property was found in the specification. Please see: <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object" target="_blank">OAI 2.0/#swagger-object</a></div>
)
}
// Only allow if, there is a host field
function allowTryItOutFor(state) {
return ({specSelectors}) => {
return specSelectors.hasHost(state)
}
}
+1 -3
View File
@@ -277,8 +277,6 @@ export let getLineNumberForPathAsync = promisifySyncFn(getLineNumberForPath)
function promisifySyncFn(fn) {
return function(...args) {
return new Promise(function(resolve, reject) {
resolve(fn(...args))
})
return new Promise((resolve) => resolve(fn(...args)))
}
}
+37 -2
View File
@@ -1,5 +1,5 @@
import win from "core/window"
import btoa from "btoa"
import { btoa } from "core/utils"
export const SHOW_AUTH_POPUP = "show_popup"
export const AUTHORIZE = "authorize"
@@ -8,6 +8,8 @@ export const PRE_AUTHORIZE_OAUTH2 = "pre_authorize_oauth2"
export const AUTHORIZE_OAUTH2 = "authorize_oauth2"
export const VALIDATE = "validate"
const scopeSeparator = " "
export function showDefinitions(payload) {
return {
type: SHOW_AUTH_POPUP,
@@ -77,7 +79,8 @@ export const authorizePassword = ( auth ) => ( { fn, authActions, errActions } )
query: {
grant_type: "password",
username,
password
password,
scopes: encodeURIComponent(auth.scopes.join(scopeSeparator))
}
}
@@ -116,3 +119,35 @@ export const authorizePassword = ( auth ) => ( { fn, authActions, errActions } )
})
.catch(err => { errActions.newAuthErr( err ) })
}
export const authorizeOauth2Application = ( auth ) => ( { fn, authActions, errActions } ) => {
let { schema, scopes, name, clientId, clientSecret } = auth
fn.fetch(schema.get("tokenUrl"), {
method: "post", headers: {
"Accept":"application/json, text/plain, */*",
"Content-Type": "application/x-www-form-urlencoded"
},
body: "grant_type=client_credentials" +
"&client_id=" + encodeURIComponent(clientId) +
"&client_secret=" + encodeURIComponent(clientSecret) +
"&scope=" + encodeURIComponent(scopes.join(scopeSeparator))
})
.then(function (response) {
if ( !response.ok ) {
errActions.newAuthErr( {
authId: name,
level: "error",
source: "auth",
message: response.statusText
} )
return
} else {
response.json()
.then(function (json){
authActions.authorizeOauth2({ auth, token: json})
})
}
})
.catch(err => { errActions.newAuthErr( err ) })
}
+1 -3
View File
@@ -1,10 +1,9 @@
import { fromJS, Map } from "immutable"
import btoa from "btoa"
import { btoa } from "core/utils"
import {
SHOW_AUTH_POPUP,
AUTHORIZE,
PRE_AUTHORIZE_OAUTH2,
AUTHORIZE_OAUTH2,
LOGOUT
} from "./actions"
@@ -21,7 +20,6 @@ export default {
// refactor withMutations
securities.entrySeq().forEach( ([ key, security ]) => {
let type = security.getIn(["schema", "type"])
let name = security.get("name")
if ( type === "apiKey" ) {
map = map.set(key, security)
+5 -2
View File
@@ -10,7 +10,7 @@ export const shownDefinitions = createSelector(
export const definitionsToAuthorize = createSelector(
state,
auth =>( { specSelectors } ) => {
() =>( { specSelectors } ) => {
let definitions = specSelectors.securityDefinitions()
let list = List()
@@ -66,7 +66,10 @@ export const authorized = createSelector(
export const isAuthorized = ( state, securities ) =>( { authSelectors } ) => {
let authorized = authSelectors.authorized()
let isAuth = false
if(!List.isList(securities)) {
return null
}
return !!securities.toJS().filter( ( security ) => {
let isAuthorized = true
@@ -1,5 +1,3 @@
import { Map } from "immutable"
// Add security to the final `execute` call ( via `extras` )
export const execute = ( oriAction, { authSelectors, specSelectors }) => ({ path, method, operation, extras }) => {
let securities = {
@@ -10,4 +8,3 @@ export const execute = ( oriAction, { authSelectors, specSelectors }) => ({ path
return oriAction({ path, method, operation, securities, ...extras })
}
+6 -3
View File
@@ -4,16 +4,19 @@ import { createSelector } from "reselect"
import { Map } from "immutable"
export default function downloadUrlPlugin (toolbox) {
let { fn, Im } = toolbox
let { fn } = toolbox
const actions = {
download: (url)=> ({ errActions, specSelectors, specActions }) => {
let { fetch } = fn
url = url || specSelectors.url()
specActions.updateLoadingStatus("loading")
fetch(url, {
fetch({
url,
loadSpec: true,
credentials: "same-origin",
headers: {
"Accept": "application/json"
"Accept": "application/json,*/*"
}
}).then(next,next)
+2 -2
View File
@@ -20,14 +20,14 @@ export function newThrownErrBatch(errors) {
}
}
export function newSpecErr(err, action) {
export function newSpecErr(err) {
return {
type: NEW_SPEC_ERR,
payload: err
}
}
export function newAuthErr(err, action) {
export function newAuthErr(err) {
return {
type: NEW_AUTH_ERR,
payload: err
@@ -1,4 +1,3 @@
import concat from "lodash/concat"
import reduce from "lodash/reduce"
let request = require.context("./transformers/", true, /\.js$/)
let errorTransformers = []
@@ -1,6 +1,5 @@
import get from "lodash/get"
import last from "lodash/get"
import { fromJS, List } from "immutable"
import { fromJS } from "immutable"
export function transform(errors, { jsSpec }) {
// LOOK HERE THIS TRANSFORMER IS CURRENTLY DISABLED 😃
+24 -8
View File
@@ -47,7 +47,7 @@ export const sampleFromSchema = (schema, config={}) => {
let obj = {}
for (var name in props) {
if ( !props[name].readOnly || includeReadOnly ) {
obj[name] = sampleFromSchema(props[name])
obj[name] = sampleFromSchema(props[name], { includeReadOnly: includeReadOnly })
}
}
@@ -55,7 +55,7 @@ export const sampleFromSchema = (schema, config={}) => {
obj.additionalProp1 = {}
} else if ( additionalProperties ) {
let additionalProps = objectify(additionalProperties)
let additionalPropVal = sampleFromSchema(additionalProps)
let additionalPropVal = sampleFromSchema(additionalProps, { includeReadOnly: includeReadOnly })
for (let i = 1; i < 4; i++) {
obj["additionalProp" + i] = additionalPropVal
@@ -65,7 +65,7 @@ export const sampleFromSchema = (schema, config={}) => {
}
if(type === "array") {
return [ sampleFromSchema(items) ]
return [ sampleFromSchema(items, { includeReadOnly: includeReadOnly }) ]
}
if(schema["enum"]) {
@@ -127,8 +127,12 @@ export const sampleXmlFromSchema = (schema, config={}) => {
if (xml.wrapped) {
res[displayName] = []
if (Array.isArray(defaultValue)) {
if (Array.isArray(example)) {
example.forEach((v)=>{
items.example = v
res[displayName].push(sampleXmlFromSchema(items, config))
})
} else if (Array.isArray(defaultValue)) {
defaultValue.forEach((v)=>{
items.default = v
res[displayName].push(sampleXmlFromSchema(items, config))
@@ -145,14 +149,20 @@ export const sampleXmlFromSchema = (schema, config={}) => {
let _res = []
if (Array.isArray(defaultValue)) {
if (Array.isArray(example)) {
example.forEach((v)=>{
items.example = v
_res.push(sampleXmlFromSchema(items, config))
})
return _res
} else if (Array.isArray(defaultValue)) {
defaultValue.forEach((v)=>{
items.default = v
_res.push(sampleXmlFromSchema(items, config))
})
return _res
}
return sampleXmlFromSchema(items, config)
}
}
@@ -176,7 +186,13 @@ export const sampleXmlFromSchema = (schema, config={}) => {
} else {
props[propName].xml.name = props[propName].xml.name || propName
props[propName].example = props[propName].example !== undefined ? props[propName].example : example[propName]
res[displayName].push(sampleXmlFromSchema(props[propName]))
let t = sampleXmlFromSchema(props[propName])
if (Array.isArray(t)) {
res[displayName] = res[displayName].concat(t)
} else {
res[displayName].push(t)
}
}
}
}
+6 -1
View File
@@ -1,4 +1,5 @@
import YAML from "js-yaml"
import parseUrl from "url-parse"
import serializeError from "serialize-error"
// Actions conform to FSA (flux-standard-actions)
@@ -184,8 +185,12 @@ export const logRequest = (req) => {
// Actually fire the request via fn.execute
// (For debugging) and ease of testing
export const executeRequest = (req) => ({fn, specActions, errActions}) => {
export const executeRequest = (req) => ({fn, specActions, specSelectors}) => {
let { pathName, method } = req
// if url is relative, parseUrl makes it absolute by inferring from `window.location`
req.contextUrl = parseUrl(specSelectors.url()).toString()
let parsedRequest = Object.assign({}, req)
if ( pathName && method ) {
parsedRequest.operationId = method.toLowerCase() + "-" + pathName
-4
View File
@@ -51,7 +51,6 @@ export default {
[VALIDATE_PARAMS]: ( state, { payload: { pathMethod } } ) => {
let operation = state.getIn( [ "resolved", "paths", ...pathMethod ] )
let parameters = operation.get("parameters")
let isXml = /xml/i.test(operation.get("consumes_value"))
return state.updateIn( [ "resolved", "paths", ...pathMethod, "parameters" ], fromJS([]), parameters => {
@@ -64,9 +63,6 @@ export default {
})
},
[ClEAR_VALIDATE_PARAMS]: ( state, { payload: { pathMethod } } ) => {
let operation = state.getIn( [ "resolved", "paths", ...pathMethod ] )
let parameters = operation.get("parameters")
return state.updateIn( [ "resolved", "paths", ...pathMethod, "parameters" ], fromJS([]), parameters => {
return parameters.withMutations( parameters => {
for ( let i = 0, len = parameters.count(); i < len; i++ ) {
+6 -2
View File
@@ -224,7 +224,7 @@ export const requestFor = (state, path, method) => {
return requests(state).getIn([path, method], null)
}
export const allowTryItOutFor = (state, path, method ) => {
export const allowTryItOutFor = () => {
// This is just a hook for now.
return true
}
@@ -291,7 +291,11 @@ export function operationConsumes(state, pathMethod) {
}
export const operationScheme = ( state, path, method ) => {
return state.getIn(["scheme", path, method]) || state.getIn(["scheme", "_defaultScheme"]) || "http"
let url = state.get("url")
let matchResult = url.match(/^([a-z][a-z0-9+\-.]*):/)
let urlScheme = Array.isArray(matchResult) ? matchResult[1] : null
return state.getIn(["scheme", path, method]) || state.getIn(["scheme", "_defaultScheme"]) || urlScheme || "http"
}
export const canExecuteScheme = ( state, path, method ) => {
@@ -57,14 +57,14 @@ export default class SplitPaneMode extends React.Component {
const mode = layoutSelectors.whatMode(MODE_KEY)
const left = mode === MODE_RIGHT ? <noscript/> : children[0]
const right = mode === MODE_LEFT ? <noscript/> : children[1]
const size = this.sizeFromMode(mode, '50%')
const size = this.sizeFromMode(mode, "50%")
return (
<SplitPane
disabledClass={''}
ref={'splitPane'}
disabledClass={""}
ref={"splitPane"}
split='vertical'
defaultSize={'50%'}
defaultSize={"50%"}
primary="second"
minSize={0}
size={size}
+2 -6
View File
@@ -3,10 +3,6 @@ import ReactDOM from "react-dom"
import { connect, Provider } from "react-redux"
import omit from "lodash/omit"
const NotFoundComponent = name => ()=> <span style={{color: "red"}}> "{name}" component not found </span>
const SystemWrapper = (getSystem, ComponentToWrap ) => class extends Component {
render() {
return <ComponentToWrap {...getSystem() } {...this.props} {...this.context} />
@@ -75,10 +71,10 @@ const createClass = component => React.createClass({
}
})
const Fallback = ({ error, name }) => <div style={{ // eslint-disable-line react/prop-types
const Fallback = ({ name }) => <div style={{ // eslint-disable-line react/prop-types
padding: "1em",
"color": "#aaa"
}}>😱 <i>Could not render { name ? name : "this component" }, see console.</i></div>
}}>😱 <i>Could not render { name === "t" ? "this component" : name }, see the console.</i></div>
const wrapRender = (component) => {
const isStateless = component => !(component.prototype && component.prototype.isReactComponent)
+1 -2
View File
@@ -1,11 +1,10 @@
import BasePreset from "./base"
import allowTryItOutIfHost from "core/plugins/allow-try-it-out-if-host"
// Just the base, for now.
export default function PresetApis() {
return [
BasePreset,
allowTryItOutIfHost,
]
}
+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 BaseLayout from "core/components/layouts/base"
import * as LayoutUtils from "core/components/layout-utils"
import * as JsonSchemaComponents from "core/json-schema-components"
@@ -87,6 +89,7 @@ export default function() {
model: Model,
models: Models,
TryItOutButton,
BaseLayout
}
}
-1
View File
@@ -1,7 +1,6 @@
import { createStore, applyMiddleware, bindActionCreators, compose } from "redux"
import Im, { fromJS, Map } from "immutable"
import deepExtend from "deep-extend"
import createLogger from "redux-logger"
import { combineReducers } from "redux-immutable"
import assign from "object-assign"
import serializeError from "serialize-error"
+36 -42
View File
@@ -135,12 +135,11 @@ export function getList(iterable, keys) {
// Adapted from http://stackoverflow.com/a/2893259/454004
// Note: directly ported from CoffeeScript
export function formatXml (xml) {
var contexp, fn, formatted, indent, l, lastType, len, lines, ln, pad, reg, transitions, wsexp
var contexp, fn, formatted, indent, l, lastType, len, lines, ln, reg, transitions, wsexp
reg = /(>)(<)(\/*)/g
wsexp = /[ ]*(.*)[ ]+\n/g
contexp = /(<.+>)(.+\n)/g
xml = xml.replace(/\r\n/g, "\n").replace(reg, "$1\n$2$3").replace(wsexp, "$1\n").replace(contexp, "$1\n$2")
pad = 0
formatted = ""
lines = xml.split("\n")
indent = 0
@@ -164,7 +163,7 @@ export function formatXml (xml) {
"other->other": 0
}
fn = function(ln) {
var fromTo, j, key, padding, type, types, value
var fromTo, key, padding, type, types, value
types = {
single: Boolean(ln.match(/<.+\/>/)),
closing: Boolean(ln.match(/<\/.+>/)),
@@ -187,11 +186,13 @@ export function formatXml (xml) {
padding = ""
indent += transitions[fromTo]
padding = ((function() {
var m, ref1, results
/* eslint-disable no-unused-vars */
var m, ref1, results, j
results = []
for (j = m = 0, ref1 = indent; 0 <= ref1 ? m < ref1 : m > ref1; j = 0 <= ref1 ? ++m : --m) {
results.push(" ")
}
/* eslint-enable no-unused-vars */
return results
})()).join("")
if (fromTo === "opening->closing") {
@@ -215,19 +216,9 @@ export function formatXml (xml) {
export function highlight (el) {
const MAX_LENGTH = 5000
var
_window = window,
_document = document,
appendChild = "appendChild",
test = "test",
// style and color templates
textShadow = ";text-shadow:",
opacity = "opacity:.",
_0px_0px = " 0px 0px ",
_3px_0px_5 = "3px 0px 5",
brace = ")",
i,
microlighted
test = "test"
if (!el) return ""
if (el.textContent.length > MAX_LENGTH) { return el.textContent }
@@ -260,14 +251,7 @@ export function highlight (el) {
lastTokenType,
// flag determining if token is multi-character
multichar,
node,
// calculating the colors for the style templates
colorArr = /(\d*\, \d*\, \d*)(, ([.\d]*))?/g.exec(
_window.getComputedStyle(el).color
),
pxColor = "px rgba("+colorArr[1]+",",
alpha = colorArr[3]||1
node
// running through characters and highlighting
while (prev2 = prev1,
@@ -468,6 +452,17 @@ export const propChecker = (props, nextProps, objectList=[], ignoreList=[]) => {
|| objectList.some( objectPropName => !eq(props[objectPropName], nextProps[objectPropName])))
}
const validateNumber = ( val ) => {
if ( !/^-?\d+(.?\d+)?$/.test(val)) {
return "Value must be a number"
}
}
const validateInteger = ( val ) => {
if ( !/^-?\d+$/.test(val)) {
return "Value must be integer"
}
}
// validation of parameters before execute
export const validateParam = (param, isXml) => {
@@ -517,29 +512,16 @@ export const validateParam = (param, isXml) => {
return errors
}
const validateNumber = ( val ) => {
if ( !/^\d+(.?\d+)?$/.test(val)) {
return "Value must be a number"
}
}
const validateInteger = ( val ) => {
if ( !/^\d+$/.test(val)) {
return "Value must be integer"
}
}
export const getSampleSchema = (schema, contentType="", config={}) => {
if (/xml/.test(contentType)) {
if (!schema.xml || !schema.xml.name) {
let name
schema.xml = schema.xml || {}
if (schema.$$ref) {
let match = schema.$$ref.match(/\S*\/(\S+)$/)
schema.xml.name = match[1]
} else if (schema.type || schema.items || schema.properties || schema.additionalProperties) {
return '<?xml version="1.0" encoding="UTF-8"?>\n<!-- XML example cannot be generated -->'
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- XML example cannot be generated -->"
} else {
return null
}
@@ -555,13 +537,25 @@ export const parseSeach = () => {
let search = window.location.search
if ( search != "" ) {
let params = search.substr(1).split("&");
let params = search.substr(1).split("&")
for (let i in params) {
i = params[i].split("=");
map[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
i = params[i].split("=")
map[decodeURIComponent(i[0])] = decodeURIComponent(i[1])
}
}
return map;
}
return map
}
export const btoa = (str) => {
let buffer
if (str instanceof Buffer) {
buffer = str
} else {
buffer = new Buffer(str.toString(), "utf-8")
}
return buffer.toString("base64")
}
+25 -17
View File
@@ -1,20 +1,28 @@
var win = {
location: {},
history: {},
open: () => {},
close: () => {}
}
try {
win = window
var props = ["File", "Blob", "FormData"]
for (var prop of props) {
if (prop in window) {
win[prop] = window[prop]
}
function makeWindow() {
var win = {
location: {},
history: {},
open: () => {},
close: () => {}
}
} catch( e ) {
console.error(e)
if(typeof window === "undefined") {
return win
}
try {
win = window
var props = ["File", "Blob", "FormData"]
for (var prop of props) {
if (prop in window) {
win[prop] = window[prop]
}
}
} catch( e ) {
console.error(e)
}
return win
}
export default win
module.exports = makeWindow()
+7 -7
View File
@@ -1,5 +1,4 @@
import YAML from "js-yaml"
import { parseSeach } from "core/utils"
import yamlConfig from "../../../swagger-config.yaml"
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
@@ -27,9 +26,7 @@ export default function configPlugin (toolbox) {
return fetch(url)
},
getConfigByUrl: (callback)=> ({ specActions }) => {
let config = parseSeach()
let configUrl = config.config
getConfigByUrl: (configUrl, cb)=> ({ specActions }) => {
if (configUrl) {
return specActions.downloadConfig(configUrl).then(next, next)
}
@@ -37,9 +34,12 @@ export default function configPlugin (toolbox) {
function next(res) {
if (res instanceof Error || res.status >= 400) {
specActions.updateLoadingStatus("failedConfig")
console.log(res.statusText + " " + configUrl)
specActions.updateLoadingStatus("failedConfig")
specActions.updateUrl("")
console.error(res.statusText + " " + configUrl)
cb(null)
} else {
callback(parseYamlConfig(res.text))
cb(parseYamlConfig(res.text))
}
}
}
@@ -70,4 +70,4 @@ export function filterConfigs (configs) {
}
return filteredConfigs
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
import Topbar from './topbar.jsx'
import Topbar from "./topbar.jsx"
export default function () {
return {
+3 -3
View File
@@ -1,5 +1,5 @@
import StandaloneLayout from './layout'
import '../style/main.scss'
import StandaloneLayout from "./layout"
import "../style/main.scss"
import TopbarPlugin from "plugins/topbar"
@@ -14,4 +14,4 @@ let preset = [
}
]
export default preset
module.exports = preset
+13 -56
View File
@@ -1,4 +1,4 @@
import React, { PropTypes } from 'react'
import React, { PropTypes } from "react"
export default class StandaloneLayout extends React.Component {
@@ -6,35 +6,23 @@ export default class StandaloneLayout extends React.Component {
errSelectors: PropTypes.object.isRequired,
errActions: PropTypes.object.isRequired,
specActions: PropTypes.object.isRequired,
specSelectors: PropTypes.object.isRequired,
layoutSelectors: PropTypes.object.isRequired,
layoutActions: PropTypes.object.isRequired
layoutActions: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired
}
render() {
let { specSelectors, specActions, getComponent, errSelectors, errActions, spec, readOnly } = this.props
let { getComponent, specSelectors } = this.props
let info = specSelectors.info()
let url = specSelectors.url()
let basePath = specSelectors.basePath()
let host = specSelectors.host()
let securityDefinitions = specSelectors.securityDefinitions()
let externalDocs = specSelectors.externalDocs()
let schemes = specSelectors.schemes()
let Info = getComponent("info")
let Operations = getComponent("operations", true)
let Models = getComponent("models", true)
let AuthorizeBtn = getComponent("authorizeBtn", true)
let Container = getComponent("Container")
let Row = getComponent("Row")
let Col = getComponent("Col")
let Button = getComponent("Button")
let Errors = getComponent("errors", true)
const SplitPaneMode = getComponent("SplitPaneMode", true)
const Schemes = getComponent("schemes")
const Topbar = getComponent("Topbar", true)
const BaseLayout = getComponent("BaseLayout", true)
const OnlineValidatorBadge = getComponent("onlineValidatorBadge", true)
const loadingStatus = specSelectors.loadingStatus()
return (
@@ -56,43 +44,12 @@ export default class StandaloneLayout extends React.Component {
<h4 className="title">Failed to load config.</h4>
</div>
}
{ loadingStatus === "success" &&
<div>
<Errors/>
<Row className="information-container">
<Col mobile={12}>
{ info.count() ? (
<Info info={ info } url={ url } host={ host } basePath={ basePath } externalDocs={externalDocs} getComponent={getComponent}/>
) : null }
</Col>
</Row>
<div className="scheme-container">
<Col className="schemes wrapper" mobile={12}>
{ schemes && schemes.size ? (
<Schemes schemes={ schemes } specActions={ specActions } />
) : null }
{ securityDefinitions ? (
<AuthorizeBtn />
) : null }
</Col>
</div>
<Row>
<Col mobile={12} desktop={12} >
<Operations/>
</Col>
</Row>
<Row>
<Col mobile={12} desktop={12} >
<Models/>
</Col>
</Row>
</div> }
<Row>
<Col>
<OnlineValidatorBadge />
</Col>
</Row>
{ !loadingStatus || loadingStatus === "success" && <BaseLayout/> }
<Row>
<Col>
<OnlineValidatorBadge />
</Col>
</Row>
</Container>
)
}
+2 -2
View File
@@ -136,8 +136,8 @@
svg
{
width: 100%;
height: 100%;
width: 20px;
height: 20px;
}
}
+5
View File
@@ -24,6 +24,11 @@
@include text_code();
}
small
{
color: #666;
}
}
hgroup
+12
View File
@@ -307,6 +307,16 @@ body
@include method($_color-disabled);
}
.opblock-schemes
{
padding: 8px 20px;
.schemes-title
{
padding: 0 10px 0 0;
}
}
}
@@ -482,6 +492,8 @@ body
margin: 0;
padding: 10px;
white-space: pre-wrap;
border-radius: 4px;
background: #41444e;
+1 -2
View File
@@ -3,10 +3,9 @@ import React from "react"
import expect, { createSpy } from "expect"
import { shallow } from "enzyme"
import Operation from "components/operation"
import Collapse from "react-collapse"
describe("<Operation/>", function(){
it("blanket tests", function(){
it.skip("blanket tests", function(){
let props = {
operation: {get: ()=>{}},
+16 -16
View File
@@ -21,7 +21,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X POST http://example.com -H "Accept: application/json" -H "content-type: application/json" -d {"id":0,"name":"doggie","status":"available"}')
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"Accept: application/json\" -H \"content-type: application/json\" -d {\"id\":0,\"name\":\"doggie\",\"status\":\"available\"}")
})
it("does not change the case of header in curl", function() {
@@ -35,7 +35,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X POST http://example.com -H "conTenT Type: application/Moar"')
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"conTenT Type: application/Moar\"")
})
it("prints a curl statement with an array of query params", function() {
@@ -46,7 +46,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X GET http://swaggerhub.com/v1/one?name=john|smith')
expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\"")
})
it("prints a curl statement with an array of query params and auth", function() {
@@ -60,7 +60,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X GET http://swaggerhub.com/v1/one?name=john|smith -H "authorization: Basic Zm9vOmJhcg=="')
expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"authorization: Basic Zm9vOmJhcg==\"")
})
it("prints a curl statement with html", function() {
@@ -71,13 +71,13 @@ describe("curlify", function() {
accept: "application/json"
},
body: {
description: '<b>Test</b>'
description: "<b>Test</b>"
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X GET http://swaggerhub.com/v1/one?name=john|smith -H "accept: application/json" -d {"description":"<b>Test</b>"}')
expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
})
it("handles post body with html", function() {
@@ -88,13 +88,13 @@ describe("curlify", function() {
accept: "application/json"
},
body: {
description: '<b>Test</b>'
description: "<b>Test</b>"
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X POST http://swaggerhub.com/v1/one?name=john|smith -H "accept: application/json" -d {"description":"<b>Test</b>"}')
expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
})
it("handles post body with special chars", function() {
@@ -102,14 +102,14 @@ describe("curlify", function() {
url: "http://swaggerhub.com/v1/one?name=john|smith",
method: "POST",
body: {
description: '@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .\n' +
'@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .'
description: "@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .\n" +
"@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> ."
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X POST http://swaggerhub.com/v1/one?name=john|smith -d {"description":"@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> ."}')
expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -d {\"description\":\"@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .\"}")
})
it("handles delete form with parameters", function() {
@@ -123,7 +123,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X DELETE http://example.com -H "accept: application/x-www-form-urlencoded"')
expect(curlified).toEqual("curl -X DELETE \"http://example.com\" -H \"accept: application/x-www-form-urlencoded\"")
})
it("should print a curl with formData", function() {
@@ -136,7 +136,7 @@ describe("curlify", function() {
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("prints a curl post statement from an object", function() {
@@ -153,7 +153,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X POST http://example.com -H "accept: application/json" -d {"id":10101}')
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d {\"id\":10101}")
})
it("prints a curl post statement from a string containing a single quote", function() {
@@ -163,12 +163,12 @@ describe("curlify", function() {
headers: {
accept: "application/json"
},
body: '{"id":"foo\'bar"}'
body: "{\"id\":\"foo'bar\"}"
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual('curl -X POST http://example.com -H "accept: application/json" -d "{\\"id\\":\\"foo\'bar\\"}"')
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d \"{\\\"id\\\":\\\"foo'bar\\\"}\"")
})
})
+1 -1
View File
@@ -1,5 +1,5 @@
/* eslint-env mocha */
import expect, { createSpy } from "expect"
import expect from "expect"
import { transformPathToArray } from "core/path-translator"
describe("validation plugin - path translator", function(){
-268
View File
@@ -1,268 +0,0 @@
/* eslint-env mocha */
import expect from "expect"
import { pathForPosition, positionRangeForPath } from "corePlugins/ast/ast"
describe.skip("ASTManager", function() {
describe("#pathForPosition", function() {
describe("out of range", function() {
it("returns empty array for out of range row", function(done) {
var position = {line: 3, column: 0}
var assertPath = function(path) {
expect(path).toEqual([])
done()
}
pathForPosition("swagger: 2.0", position)
.then(assertPath)
})
it("returns empty array for out of range column", function(done) {
var position = {line: 0, column: 100}
var assertPath = function(path) {
expect(path).toEqual([])
done()
}
pathForPosition("swagger: 2.0", position)
.then(assertPath)
})
})
describe("when document is a simple hash `swagger: 2.0`", function() {
it("should return empty array when pointer is at middle of the hash key", function(done) {
var position = {line: 0, column: 3}
pathForPosition("swagger: 2.0", position).then(function(path) {
expect(path).toEqual([])
done()
})
})
it("should return ['swagger'] when pointer is at the value", function(done) {
var position = {line: 0, column: 10}
pathForPosition("swagger: 2.0", position).then(function(path) {
expect(path).toEqual(["swagger"])
done()
})
})
})
describe("when document is an array: ['abc', 'cde']", function() {
var yaml = [
/*
0
01234567 */
/* 0 */ "- abc",
/* 1 */ "- def"
].join("\n")
it("should return empty array when pointer is at array dash", function(done) {
var position = {line: 0, column: 0}
pathForPosition(yaml, position).then(function(path) {
expect(path).toEqual([])
done()
})
})
it("should return ['0'] when pointer is at abc", function(done) {
var position = {line: 0, column: 3}
pathForPosition(yaml, position).then(function(path) {
expect(path).toEqual(["0"])
done()
})
})
it("should return ['1'] when pointer is at abc", function(done) {
var position = {line: 1, column: 3}
pathForPosition(yaml, position).then(function(path) {
expect(path).toEqual(["1"])
done()
})
})
})
describe("when document is an array of arrays", function() {
var yaml = [
/*
0 10
0123456789012345 */
/* 0 */ "-",
/* 1 */ " - abc",
/* 2 */ " - def",
/* 3 */ "-",
/* 4 */ " - ABC",
/* 5 */ " - DEF"
].join("\n")
it("should return ['0', '0'] when pointer is at 'abc'", function(done) {
var position = {line: 1, column: 5}
pathForPosition(yaml, position).then(function(path) {
expect(path).toEqual(["0", "0"])
done()
})
})
})
describe("when document is an array of hashs", function() {
var yaml = [
/*
0 10
0123456789012345 */
/* 0 */ "- key: value",
/* 1 */ " num: 1",
/* 2 */ "- name: Tesla",
/* 3 */ " year: 2016"
].join("\n")
it("should return ['0'] when pointer is at 'key'", function(done) {
var position = {line: 0, column: 3}
pathForPosition(yaml, position).then(function(path) {
expect(path).toEqual(["0"])
done()
})
})
it("should return ['0', 'key'] when pointer is at 'value'", function(done) {
var position = {line: 0, column: 9}
pathForPosition(yaml, position).then(function(path) {
expect(path).toEqual(["0", "key"])
done()
})
})
it("should return ['1', 'year'] when pointer is at '2016'", function(done) {
var position = {line: 3, column: 10}
pathForPosition(yaml, position).then(function(path) {
expect(path).toEqual(["1", "year"])
done()
})
})
})
describe("full document", function() {
var yaml = [
/*
0 10 20 30
012345678901234567890123456789012345678 */
/* 0 */ "swagger: '2.0'",
/* 1 */ "info:",
/* 2 */ " title: Test document",
/* 3 */ " version: 0.0.1",
/* 4 */ " contact:",
/* 5 */ " name: Sahar",
/* 6 */ " url: github.com",
/* 7 */ " email: me@example.com",
/* 8 */ " "
].join("\n")
it("should return ['info', 'contact', 'email'] when pointer is at me@", function(done) {
var position = {line: 7, column: 13}
pathForPosition(yaml, position).then(function(path) {
expect(path).toEqual(["info", "contact", "email"])
done()
})
})
})
})
describe("#positionRangeForPath", function() {
it("return {{-1, -1}, {-1, -1}} for invalid paths", function(done) {
var yaml = [
"key: value",
"anotherKey: value"
].join("\n")
positionRangeForPath(yaml, ["invalid"])
.then(function(position) {
expect(position.start).toEqual({line: -1, column: -1})
expect(position.end).toEqual({line: -1, column: -1})
done()
})
})
describe("when document is a simple hash `swagger: 2.0`", function() {
var yaml = "swagger: 2.0"
it("return {0, 0} for start of empty array path (root)", function(done) {
positionRangeForPath(yaml, []).then(function(position) {
expect(position.start).toEqual({line: 0, column: 0})
done()
})
})
it("return {0, 12} for end of empty array path (root)", function(done) {
positionRangeForPath(yaml, []).then(function(position) {
expect(position.end).toEqual({line: 0, column: 12})
done()
})
})
it("return {0, 9} for start of ['swagger']", function(done) {
positionRangeForPath(yaml, ["swagger"]).then(function(position) {
expect(position.start).toEqual({line: 0, column: 9})
done()
})
})
it("return {0, 12} for end of ['swagger']", function(done) {
positionRangeForPath(yaml, ["swagger"]).then(function(position) {
expect(position.end).toEqual({line: 0, column: 12})
done()
})
})
})
describe("when document is an array of primitives", function() {
var yaml = [
"key:",
" - value1",
" - value2"
].join("\n")
it("returns {1, 4} for ['key', '0']", function(done) {
positionRangeForPath(yaml, ["key", "0"]).then(function(position) {
expect(position.start).toEqual({line: 1, column: 4})
done()
})
})
})
describe("full document", function() {
var yaml = [
/*
0 10 20 30
012345678901234567890123456789012345678 */
/* 0 */ "swagger: '2.0'",
/* 1 */ "info:",
/* 2 */ " title: Test document",
/* 3 */ " version: 0.0.1",
/* 4 */ " contact:",
/* 5 */ " name: Sahar",
/* 6 */ " url: github.com",
/* 7 */ " email: me@example.com",
/* 8 */ " "
].join("\n")
it("returns {2, 2} for start of ['info']", function(done) {
positionRangeForPath(yaml, ["info"]).then(function(position) {
expect(position.start).toEqual({line: 2, column: 2})
done()
})
})
it("returns {5, 10} for start of ['info', 'contact', 'name']", function(done) {
positionRangeForPath(yaml, ["info", "contact", "name"]).then(function(position) {
expect(position.start).toEqual({line: 5, column: 10})
done()
})
})
it("returns {5, 15} for end of ['info', 'contact', 'name']", function(done) {
positionRangeForPath(yaml, ["info", "contact", "name"]).then(function(position) {
expect(position.end).toEqual({line: 5, column: 15})
done()
})
})
})
})
})
+1 -2
View File
@@ -1,6 +1,5 @@
/* eslint-env mocha */
import expect, { createSpy } from "expect"
import { fromJS } from "immutable"
import { execute } from "corePlugins/auth/spec-wrap-actions"
describe("spec plugin - actions", function(){
@@ -18,7 +17,7 @@ describe("spec plugin - actions", function(){
// When
let executeFn = execute(oriExecute, system)
let executePromise = executeFn({})
executeFn({})
// Then
expect(oriExecute.calls.length).toEqual(1)
@@ -1,4 +1,4 @@
import expect, { createSpy } from "expect"
import expect from "expect"
import { Map, List } from "immutable"
import { transform } from "corePlugins/err/error-transformers/transformers/not-of-type"
@@ -1,5 +1,5 @@
import expect, { createSpy } from "expect"
import { Map, List, fromJS } from "immutable"
import expect from "expect"
import { fromJS } from "immutable"
import { transform } from "corePlugins/err/error-transformers/transformers/parameter-oneof"
describe.skip("err plugin - tranformers - parameter oneof", () => {
+47 -1
View File
@@ -396,7 +396,7 @@ describe("createXMLExample", function () {
})
it("returns array with default values with wrapped=true", function () {
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>one</animal>\n</animals>"
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>1</animal>\n\t<animal>2</animal>\n</animals>"
var definition = {
items: {
"enum": ["one", "two"],
@@ -405,6 +405,7 @@ describe("createXMLExample", function () {
name: "animal"
}
},
"default": ["1", "2"],
xml: {
wrapped: true,
name: "animals"
@@ -413,8 +414,53 @@ describe("createXMLExample", function () {
expect(sut(definition)).toEqual(expected)
})
it("returns array with example values with ", function () {
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>1</animal>\n\t<animal>2</animal>\n</animals>"
var definition = {
type: "object",
properties: {
"animal": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"1",
"2"
]
}
},
xml: {
name: "animals"
}
}
expect(sut(definition)).toEqual(expected)
})
it("returns array with example values with wrapped=true", function () {
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>1</animal>\n\t<animal>2</animal>\n</animals>"
var definition = {
type: "array",
items: {
type: "string",
xml: {
name: "animal"
}
},
"example": [ "1", "2" ],
xml: {
wrapped: true,
name: "animals"
}
}
expect(sut(definition)).toEqual(expected)
})
})
describe("object", function () {
it("returns object with 2 properties", function () {
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<aliens>\n\t<alien>string</alien>\n\t<dog>0</dog>\n</aliens>"
+2 -3
View File
@@ -25,7 +25,7 @@ describe("spec plugin - actions", function(){
// When
let executeFn = execute({ path: "/one", method: "get"})
let executePromise = executeFn(system)
executeFn(system)
// Then
expect(system.specActions.executeRequest.calls[0].arguments[0]).toEqual({
@@ -60,7 +60,7 @@ describe("spec plugin - actions", function(){
// When
let executeFn = execute({ hi: "hello" })
let executePromise = executeFn(system)
executeFn(system)
// Then
expect(system.specActions.executeRequest.calls[0].arguments[0]).toInclude({hi: "hello"})
@@ -72,7 +72,6 @@ describe("spec plugin - actions", function(){
xit("should call fn.execute with arg ", function(){
const response = {}
const system = {
fn: {
execute: createSpy().andReturn(Promise.resolve())
+41 -2
View File
@@ -1,7 +1,7 @@
/* eslint-env mocha */
import expect, { createSpy } from "expect"
import expect from "expect"
import { fromJS } from "immutable"
import { parameterValues, contentTypeValues } from "corePlugins/spec/selectors"
import { parameterValues, contentTypeValues, operationScheme } from "corePlugins/spec/selectors"
describe("spec plugin - selectors", function(){
@@ -92,4 +92,43 @@ describe("spec plugin - selectors", function(){
})
describe("operationScheme", function(){
it("should return the correct scheme for a remote spec that doesn't specify a scheme", function(){
// Given
let state = fromJS({
url: "https://generator.swagger.io/api/swagger.json",
resolved: {
paths: {
"/one": {
get: {
"consumes_value": "one",
"produces_value": "two"
}
}
}
}
})
// When
let scheme = operationScheme(state, ["/one"], "get")
// Then
expect(scheme).toEqual("https")
})
// it("should be ok, if no operation found", function(){
// // Given
// let state = fromJS({ })
//
// // When
// let contentTypes = contentTypeValues(state, [ "/one", "get" ])
// // Then
// expect(contentTypes.toJS()).toEqual({
// requestContentType: undefined,
// responseContentType: undefined
// })
// })
})
})
+2 -1
View File
@@ -240,6 +240,7 @@ describe("bound system", function(){
statePlugins: {
kyle: {
wrapActions: {
// eslint-disable-next-line no-unused-vars
simple: (ori) => (arg) => (sys) => {
return { type: "called" }
}
@@ -256,7 +257,7 @@ describe("bound system", function(){
})
})
describe("selectors", function(){
+1 -1
View File
@@ -1,5 +1,5 @@
/* eslint-env mocha */
import expect, { createSpy } from "expect"
import expect from "expect"
import { fromJS } from "immutable"
import { mapToList } from "core/utils"
+1
View File
@@ -13,6 +13,7 @@ module.exports = require('./make-webpack-config.js')({
entry: {
'swagger-ui-bundle': [
'babel-polyfill',
'./src/core/index.js'
]
},
+1
View File
@@ -15,6 +15,7 @@ module.exports = require('./make-webpack-config.js')({
entry: {
"swagger-ui": [
'babel-polyfill',
'./src/style/main.scss',
'./src/core/index.js'
]
+5 -4
View File
@@ -9,10 +9,11 @@ module.exports = require("./make-webpack-config")({
},
devtool: "eval",
entry: {
'SwaggerUIBundle': [
'swagger-ui-bundle': [
'babel-polyfill',
'./src/core/index.js'
],
'SwaggerUIStandalonePreset': [
'swagger-ui-standalone-preset': [
'./src/standalone/index.js'
]
},
@@ -26,8 +27,8 @@ module.exports = require("./make-webpack-config")({
},
devServer: {
port: 3200,
path: path.join(__dirname, 'dist'),
publicPath: "/dist",
path: path.join(__dirname, 'dev-helpers'),
publicPath: "/",
noInfo: true,
colors: true,
hot: true,