Compare commits

...
209 Commits
Author SHA1 Message Date
Tony Tam 855b31d73b switched to snippet view #491 2014-07-12 20:30:28 -07:00
Tony Tam 7945dec86c updated versions, swagger-js 2014-07-12 20:14:38 -07:00
Tony Tam 011f70935d fixed #340 with empty body, updated swagger-js 2014-07-10 22:36:41 -07:00
Tony Tam f0a099728c Merge branch 'master' of github.com:wordnik/swagger-ui 2014-07-03 12:19:47 -07:00
Tony Tam d673d5d1cb Merge pull request #479 from tillig/patch-2
Fix handling for jQuery response headers
2014-06-17 17:36:19 -07:00
Travis Illig 8ad843fc4f Fix handling for jQuery response headers
Fixes the way response headers are parsed when using the jQuery client. Enables the response headers to be properly viewed in the UI. Previous logic consistently returned an empty set of headers. Includes minor changes to allow the use of JS strict mode, at least for this function.
2014-06-17 15:23:22 -07:00
Tony Tam 1b89ab4128 Merge pull request #477 from paladox2015/patch-3
Update underscore-min.js
2014-06-17 10:53:32 -07:00
Tony Tam bfc0c987df Merge pull request #478 from tillig/patch-1
Fix handling for jQuery response headers
2014-06-17 10:45:42 -07:00
Travis Illig e250ab3e66 Fix handling for jQuery response headers
Fixes the way response headers are parsed when using the jQuery client. Enables the response headers to be properly viewed in the UI. Previous logic consistently returned an empty set of headers. Includes minor changes to allow the use of JS strict mode, at least for this function.
2014-06-17 09:46:12 -07:00
paladox2015 25c33cb472 Update underscore-min.js 2014-06-17 12:59:06 +01:00
Tony Tam b8e4317929 updated to support explicit keys 2014-06-12 17:50:23 -07:00
Tony Tam c2dd77ff3a Merge pull request #435 from JoergAdler/master
The list of scopes now RFC6749 Sec.3.3 compliant
2014-06-01 16:35:58 -07:00
Tony Tam 4b535adcb7 bumped version 2014-05-14 09:45:38 -04:00
Tony Tam 05588bb669 fix for upload with no files 2014-05-14 09:45:18 -04:00
Tony Tam f7694d8525 updated with version number 2014-04-30 09:30:59 -07:00
Samuel Raghunath d96fd58016 Updated index.html to include css links for print media 2014-04-29 14:49:51 -04:00
Tony Tam 8d0c9107e7 updated version for release 2014-04-29 11:13:43 -07:00
Tony Tam 1f3746a846 rebuilt distro for #331 2014-04-29 09:58:33 -07:00
FilippQoma 9cedc0b4d7 ~ "Error Status Codes" -> "Response Messages"
+ "Response Model" column in OperationView template
+ Response Model in Response Messages
2014-04-29 19:20:31 +03:00
Tony Tam ca47551d93 updated swagger.js version 2014-04-27 21:36:04 -07:00
Tony Tam 15afbcf14f added emitting version into swagger-ui.js file 2014-04-27 20:54:12 -07:00
Kyle J. Ginavan 34ab47e9e7 moved css scoping to less templates per owners request, converted highlight.default.css to less, and made reset css its only include as it is difficult to scope due to html and body tag css overrides 2014-04-11 09:59:19 -05:00
Kyle J. Ginavan 84f4e670fc added scope to swagger, therefore, it can be included/embedded within other applications and not have css bleed. 2014-04-11 08:53:26 -05:00
Pat f6380d17e5 Update README.md 2014-04-09 10:14:50 -07:00
Jörg Adler 52db742a10 The list of scopes now RFC6749 Sec.3.3 compliant
See http://tools.ietf.org/html/rfc6749#section-3.3 for details.

The callback url is now determined correctly if the swagger index.html file and
therefore the o2c.html is not in root directory of the host.

Also the popup opens more than one authorization-request-tab in firefox
(seems to append the on-click js method instead of replacing it)
2014-04-03 12:31:02 +02:00
webron a536583890 Update README.md 2014-03-23 13:14:41 +02:00
Tony Tam a36da91d7e updated oauth2 support into a single config 2014-03-20 15:38:56 -07:00
Tony Tam 96c14e43a9 updated oauth2 support into a single config 2014-03-20 15:38:30 -07:00
Tony Tam 2edd7ac058 Merge branch 'master' of github.com:wordnik/swagger-ui 2014-03-19 21:50:41 -07:00
Tony Tam da63a33845 merged from oauth2 branch 2014-03-19 21:50:31 -07:00
Tony Tam 579abd6848 Merge pull request #402 from HughePaul/feature-requirefordistdir
Add index.js file that returns the dist location when require()d
2014-03-19 20:03:45 -07:00
Tony Tam 1f6aa46e52 updated swagger-js, version 2014-03-19 08:28:16 -07:00
webron c9652472a2 Create LICENSE 2014-03-19 16:08:07 +02:00
Tony Tam aeffecd8d4 rebuilt per #417 2014-03-18 19:47:04 -07:00
Tony Tam 9e8e62c17c Merge pull request #417 from spil-johan/master
Don't send empty form fields as undefined for file uploads
2014-03-18 19:46:09 -07:00
Tony Tam c69c6f8d34 rebuilt per #418 2014-03-18 19:45:41 -07:00
Tony Tam fac6d94886 Merge pull request #418 from spil-johan/headers
Fix header response on file upload
2014-03-18 19:44:43 -07:00
Tony Tam a5556d7f01 added options styling, swagger-js update, per #420 2014-03-18 19:41:49 -07:00
Tony Tam 8f665f76da Merge pull request #414 from mondia/master
Multi-selection in query parameter 'allowableValues' listbox for 'array' param type.
2014-03-12 12:35:38 -07:00
Johan.Bloemberg 191416e666 Fix header response on file upload 2014-03-10 11:41:45 +01:00
Johan.Bloemberg e84acba53e Don't send empty form fields as undefined for file uploads 2014-03-10 11:18:43 +01:00
valdemon 1a346fbf26 Modified commit for the https://github.com/wordnik/swagger-ui/pull/414
Brings backward compatibility for the 'allowMultiple' attribute.
2014-03-06 12:39:49 +01:00
Tony Tam 28ac6f8745 rebuilt 2014-03-05 17:08:53 -08:00
Tony Tam 77aa535a0f Merge pull request #413 from spil-johan/master
No request url or response body data on file upload
2014-03-05 17:08:10 -08:00
Tony Tam 2a9453531d updated client 2014-03-05 17:06:09 -08:00
Tony Tam 467cac23cc Merge branch 'normalized' 2014-03-05 16:52:18 -08:00
Tony Tam d6738ede2b Merge branch 'normalized' of github.com:wordnik/swagger-ui into normalized 2014-03-05 16:50:49 -08:00
Tony Tam 5dffa48ac7 fix for toggle operation 2014-03-05 16:50:24 -08:00
Tony Tam 2393feacae Merge pull request #411 from MendeleyStack/normalized-fix
fixed id construction in toggleOperationContent
2014-03-05 16:33:26 -08:00
Johan.Bloemberg a539691568 Fix content and response url on file uploads 2014-03-05 14:10:10 +01:00
Joyce Stack 5418738956 fixed id construction in toggleOperationContent 2014-03-05 10:08:23 +00:00
Tony Tam c92e9a14b9 fix for #410, varibles declared in closures cause ie8 pains 2014-03-04 23:30:15 -08:00
Tony Tam dc7b663239 updated files 2014-02-27 23:35:36 -08:00
Tony Tam 7b77ffd079 ie8 fixes 2014-02-27 19:55:56 -08:00
Tony Tam 2a642f5a5f fix for https://github.com/wordnik/swagger-js/issues/81 2014-02-26 12:13:42 -08:00
Paul Winkler 99b3f7d00e Add index.js file that returns the dist location and version when required 2014-02-21 10:10:49 +00:00
Tony Tam aa848529c0 updated swagger-js 2014-02-19 11:49:15 -08:00
Tony Tam 7108afc191 updated swagger-js version 2014-02-19 11:17:26 -08:00
Tony Tam 0095768ab7 fix for https://github.com/wordnik/swagger-ui/pull/399 2014-02-18 15:54:36 -08:00
Tony Tam 31e772f0bf fix for array params 2014-02-18 10:59:49 -08:00
Tony Tam b41b200061 fixes for allowable values 2014-02-16 08:26:38 -08:00
Tony Tam 65a5bc34eb updated swagger-js per https://github.com/wordnik/swagger-ui/pull/394#issuecomment-35181116 https://github.com/wordnik/swagger-ui/pull/394#issuecomment-35181116 2014-02-16 07:58:18 -08:00
Tony Tam cc49093471 updated swagger-js versions 2014-02-13 14:11:31 -08:00
Tony Tam b336076a19 updated version 2014-02-12 07:38:49 -08:00
Tony Tam b8943665a2 updated client to 2.0.13 2014-02-12 07:37:41 -08:00
Tony Tam 0c0ffc569f updated swagger-client 2014-02-03 22:25:57 -08:00
Tony Tam 18ce470f12 merge of #369, https://github.com/wordnik/swagger-js/issues/74 2014-02-03 17:51:05 -08:00
Tony Tam 53593b796e fix for #387 2014-02-03 16:20:07 -08:00
Tony Tam 2378b176f5 fix for #388 2014-02-03 08:28:22 -08:00
Tony Tam 7dd5142df2 fix for #381 2014-01-27 07:13:12 -08:00
Tony Tam 6b400b22fe updated version 2014-01-23 20:40:40 -08:00
Tony Tam c22d94b940 updated swagger-js client, support for IE8 2014-01-23 20:40:10 -08:00
Tony Tam e7b9525911 updated swagger-js version to address #377, #72 2014-01-21 18:31:26 -08:00
Tony Tam ede80844a5 Merge pull request #376 from ilesm/mediatypes2
Added support for pretty-printing responses that use extended media type subtypes
2014-01-19 15:53:39 -08:00
Michael Iles eea0d72a85 Added support for pretty-printing responses for media types with
extended subtypes. For example the media type
'application/vnd.myresource+json; version=1.2' will be correctly
recognized as JSON and pretty-printed. Conforms to RFC 6838, 6839.
2014-01-19 14:46:55 -05:00
Tony Tam 15acb15af6 fix for #248 2014-01-02 19:54:10 -08:00
Tony Tam 54d0a8ec09 Update README.md 2014-01-02 09:28:35 -08:00
Tony Tam 105c516f5f Merge pull request #365 from xinvincible21/master
safe-JSON-parsing-check-for-type-undefined
2013-12-29 05:44:43 -08:00
invincible 542d4fe478 safe-JSON-parsing-check-for-type-undefined 2013-12-27 13:51:50 -05:00
Tony Tam 97e96ba3d9 rebuilt client 2013-12-20 17:37:55 -08:00
Tony Tam 73eaf9f564 Merge pull request #364 from bmatsuo/dont-upload-all-files
restrict uploaded file inputs to those in the form being submitted
2013-12-20 17:36:26 -08:00
Bryan Matsuo fc0ccd4486 restrict uploaded file inputs to those in the form being submitted 2013-12-20 17:17:06 -08:00
Tony Tam 7f68c35742 Merge pull request #358 from autayeu/selfclosingtag
removed selfclosing tag #332 - reapplied e4d01c5 by thadudexx
2013-12-19 12:02:29 -08:00
Aliaksandr Autayeu dc1bc43a19 removed selfclosing tag #332 - reapplied e4d01c5 by thadudexx 2013-12-14 16:13:06 +01:00
Tony Tam c32f6e836d updated version 2013-11-29 22:08:07 -08:00
Tony Tam 34bd474bff fix for #288 2013-11-29 22:07:37 -08:00
Tony Tam 4601f62702 fix for #334 2013-11-06 21:06:27 -08:00
Tony Tam 2bddfb688a Merge pull request #327 from georgeOsdDev/master
Add image contents type resopnse handler
2013-11-04 09:57:57 -08:00
Tony Tam b7458010f1 Merge pull request #326 from aerotech/upstream
Request URL updates for all operations in our resource
2013-11-04 09:21:57 -08:00
Tony Tam 49f480440b Merge pull request #332 from thadudexx/master
Small cosmetic update index.html
2013-10-18 16:31:54 -07:00
thadudexx e4d01c57bf Update index.html
removed selfclosing tag
2013-10-15 17:24:05 +02:00
Tony Tam 187517dfe3 fixed package to include less 2013-10-10 11:41:23 -07:00
Takeharu Oshida 846628f1f3 Match all image types 2013-10-08 16:44:28 +09:00
Takeharu Oshida 355380a5c4 Add image contents type resopnse handler 2013-10-08 14:30:48 +09:00
Pavel Puchkarev 6db63006a6 fixing request_url updates for all operations in one resource 2013-10-07 18:14:58 -04:00
Pavel 0505d6cadf Merge pull request #1 from wordnik/master
Update to latest swagger-ui code
2013-10-07 15:06:13 -07:00
Tony Tam fcb82bdac4 merged https://github.com/wordnik/swagger-ui/pull/323 2013-10-06 15:47:13 -07:00
Tony Tam 348f1e109b updated swagger-js 2013-09-26 16:24:06 -07:00
Tony Tam abc3600994 Merge pull request #295 from tomrac87/hal_json
Proper formatting for "application/hal+json" Content-Type
2013-09-24 06:38:16 -07:00
Tony Tam 77882a0e3e Merge pull request #311 from aerotech/master
updating docs, change in sample and java required for build
2013-09-17 10:09:39 -07:00
Pavel Puchkarev 0e98639f45 updating docs, change in sample and java required for build 2013-09-17 13:04:08 -04:00
Tony Tam 3347d7e9fd merged pr for https://github.com/wordnik/swagger-js/pull/54 2013-09-16 14:54:36 -07:00
Tony Tam 929f8b61f2 Merge branch 'master' of github.com:wordnik/swagger-ui 2013-09-14 20:43:36 -07:00
Tony Tam 8158e9b25f fix for #310 2013-09-14 20:43:20 -07:00
Tony Tam a0db8582a1 fixed example 2013-09-14 09:36:14 -07:00
Tony Tam 1b662db2d2 fix for required fields showing optional 2013-09-12 11:00:27 -07:00
Tony Tam cd4fa99cc4 added resource description 2013-09-09 08:15:59 -07:00
Tony Tam bc93240199 fixed merge issue 2013-09-05 20:03:31 -07:00
Tony Tam 999367589d fix for #301, headers being URI encoded 2013-09-05 11:39:18 -07:00
Tony Tam 8a9eedfdf3 manual merge of #304 2013-09-05 10:16:10 -07:00
Tony Tam 046e534d03 manual merge of #303 2013-09-05 09:31:21 -07:00
Tony Tam 73c89ba3f6 fix for #297, enabled throbber 2013-09-03 12:41:26 -07:00
tomrac87 ff05f9113b Added proper formatting for hal+json Content-Type responses in coffeescript source file 2013-09-02 10:02:26 +02:00
Tony Tam 6c1de0b560 added enum support per #296 2013-08-29 17:27:49 -07:00
Tony Tam 4fb5b86db1 updated swagger-js to address sample schema issues 2013-08-29 17:15:50 -07:00
tomrac87 5f4eec1b8a Added proper formatting for hal+json Content-Type responses 2013-08-28 15:39:50 +02:00
Tony Tam f22efb66de fix for #279, empty boolean drop-downs 2013-08-20 12:48:14 -07:00
Tony Tam 9e25ec56c9 Merge branch 'master' of github.com:wordnik/swagger-ui 2013-08-19 11:40:19 -07:00
Tony Tam 085cc05cc7 fixed responseMessages issue per #267 2013-08-19 11:40:03 -07:00
Tony Tam 56a58143e7 Merge pull request #287 from rcrooks/master
fixing file name -- realized the typo in the link tag was replicating on...
2013-08-15 17:39:24 -07:00
Robert Crooks 7802c36646 fixing file name -- realized the typo in the link tag was replicating one in the css file name 2013-08-15 16:54:09 -04:00
Tony Tam fca0bdf12d Merge pull request #286 from bcls/master
fix for issue #285
2013-08-15 11:27:40 -07:00
Brightcove Learning Services 727d9e03e0 fix for issue #285 2013-08-15 14:07:45 -04:00
Tony Tam 888db09fd8 fixed enum, required flags 2013-08-14 16:49:08 -07:00
Tony Tam f29d53d5bc updated readme 2013-08-14 12:18:36 -07:00
Tony Tam b138359f5b updated readme 2013-08-14 11:50:58 -07:00
Tony Tam 9fccf1c3a6 updated swagger-client 2013-08-14 11:27:18 -07:00
Tony Tam 25805a4bc0 fixed petstore link 2013-08-14 10:53:31 -07:00
Tony Tam 6865ab5287 merged from develop branch 2013-08-14 10:51:15 -07:00
Tony Tam 085fc8dc7e updated handlebars 2013-08-14 10:48:48 -07:00
Tony Tam 205125cd9d fixes for content-type 2013-08-14 10:38:41 -07:00
Tony Tam 4b5e4e5d69 updated for 1.2 support 2013-08-12 08:28:40 -07:00
Tony Tam b2637fc4bc removed console log, updated swagger.js 2013-07-31 08:11:51 -07:00
Tony Tam 3c3e297949 Merge pull request #272 from thinkt4nk/master
fixed discrepancy between handlebars precompiler and runtime
2013-07-30 11:49:44 -07:00
Ryan Bales dd88dc1727 fixed discrepancy between handlebars precompiler and runtime 2013-07-30 09:43:57 -05:00
Tony Tam c6f2aada45 merged https://github.com/wordnik/swagger-js/issues/42 2013-07-18 11:40:47 -07:00
Tony Tam df20d2bd5e fix for #263 2013-07-17 16:02:47 -07:00
Tony Tam e72dbd6bc6 fix for #261 2013-07-16 20:59:46 -07:00
Tony Tam f4d77d7124 fix for #261 2013-07-16 20:57:26 -07:00
Tony Tam 390ee1c781 removed console logs 2013-07-11 16:56:03 -07:00
Tony Tam 627fd8b4d6 removed some logging 2013-07-11 16:52:48 -07:00
Tony Tam 078851ba6e fixed default URL 2013-07-11 07:59:11 -07:00
Tony Tam e980cca6b4 added api info 2013-07-11 00:26:05 -07:00
Tony Tam 187d245047 updated to use petstore instead of localhost 2013-07-09 11:54:06 -07:00
Tony Tam 58746157b3 added authorization support from swagger-js 2.0 2013-07-09 11:27:32 -07:00
Tony Tam 2a206b0a6b renamed discoveryUrl to url to match js change 2013-07-08 23:53:05 -07:00
Tony Tam 6a5dfdcedc fix for #174, #78 2013-07-08 22:03:15 -07:00
Tony Tam 8f7e8f9ee0 updated to latest swagger-js 2013-07-08 18:38:11 -07:00
Tony Tam 22e5f5ccc1 #199 2013-07-07 01:21:39 -07:00
Tony Tam 8fcaa608e0 removed swagger-client dep for now, it's copied manually 2013-07-07 01:16:48 -07:00
Tony Tam 8bac45d960 updated deps, version 2013-07-07 00:55:11 -07:00
Tony Tam 09be20c97d merged with swagger.js-2.0-develop 2013-07-07 00:53:30 -07:00
Tony Tam 7334079535 added shred library 2013-07-07 00:53:12 -07:00
Tony Tam cde29f0d9a added separate request and response templates 2013-07-07 00:52:46 -07:00
Tony Tam 7b9f8a2651 added separate request and response templates 2013-07-07 00:52:37 -07:00
Tony Tam 2dd2eb9e50 added shred library 2013-07-07 00:52:00 -07:00
Tony Tam 4a6fc1d3bd added shred library 2013-07-07 00:51:55 -07:00
Tony Tam 5794d1c0d5 Update index.html 2013-07-01 21:39:20 -07:00
Tony Tam 9efb0a798e added support for swagger-spec 1.2 2013-06-30 21:37:21 -07:00
Tony Tam dd3037f481 updated to support 1.2 spec responseMessages 2013-06-26 08:05:33 -07:00
Tony Tam d133e38f21 updated to support 1.2 spec responseMessages 2013-06-26 08:04:11 -07:00
Tony Tam 11b4d6d077 form data fix 2013-06-08 23:07:37 -07:00
Tony Tam ecf1519abf Merge branch 'master' of github.com:wordnik/swagger-ui 2013-06-08 23:04:58 -07:00
Tony Tam 4a8e5dd310 Merge pull request #216 from sibblegp/master
Create proper JSON Formatting in example models
2013-05-30 01:33:47 -07:00
Tony Tam 636f3514cb Merge branch 'master' of git://github.com/sibblegp/swagger-ui into sibblegp-master 2013-05-30 01:32:36 -07:00
Tony Tam bde3c26ece Merge branch 'master' of github.com:wordnik/swagger-ui 2013-05-30 01:32:23 -07:00
Tony Tam 78fdef4d70 Merge pull request #214 from Net-A-Porter/master
Add new column to show paramType
2013-05-30 01:32:10 -07:00
Tony Tam beab1f2eaa Merge branch 'master' of git://github.com/Net-A-Porter/swagger-ui into Net-A-Porter-master 2013-05-30 01:29:51 -07:00
Tony Tam dbfb1adc26 fixed file param name 2013-05-30 01:25:20 -07:00
George Sibble 880c8da652 Create proper example JSON 2013-05-27 17:39:35 -07:00
Ian Forsey c1efde5e5b Add new column to display the paramType 2013-05-24 17:09:57 +01:00
Tony Tam b5d2f21a6d Merge pull request #192 from earth2marsh/patch-1
minor typo correction
2013-04-23 05:32:38 -07:00
Marsh Gardiner 7200f3edbb minor typo correction 2013-04-22 22:17:45 -07:00
Tony Tam 156d0befbb merged #pr175 2013-04-11 16:04:43 -07:00
Tony Tam 84240817e1 fix for #180 2013-04-09 11:56:05 -07:00
Tony Tam 8b1cf18daa fix for sending content-type header during GET requests 2013-04-05 13:29:14 -07:00
Tony Tam e66c08907d Merge pull request #166 from JonnyJD/simpler-cors
don't set contentType for empty body
2013-04-05 13:19:41 -07:00
Tony Tam f43e96fec8 Merge pull request #179 from paulhill/master
Making fonts call protocol agnostic so it works behind https
2013-04-05 12:09:01 -07:00
Paul Hill 8ec69b272c Making fonts call protocol agnostic so it works behind https 2013-04-05 11:20:39 -07:00
Tony Tam ec15dea8c2 Merge branch 'master' of github.com:wordnik/swagger-ui 2013-04-05 08:26:28 -07:00
Tony Tam 091c3f912b updated to support file + form params in same request 2013-04-05 08:26:14 -07:00
Tony Tam 484406b95e removed reference to downloads folder 2013-03-28 13:25:26 -07:00
Johannes Dewender ae93b581d2 don't set contentType for empty body
When content-type is set to a non-standard value,
CORS requires a preflight request that needs to be handled
by the destination server.
We shouldn't require that, when no body is sent at all
and the content-type is irrelevant anyways.
2013-03-17 22:36:17 +01:00
Tony Tam 722da60f5d fixed required param bug per #163 2013-03-08 06:19:29 -08:00
Tony Tam db4175ef57 bumped version 2013-03-05 21:10:17 -08:00
Tony Tam c2292905c2 Merge pull request #155 from pdegeus/master
UI improvements
2013-03-05 21:09:16 -08:00
Pepijn de Geus c3a3f1861c Merge commit '4ee046d39c58cbf72042bf72616e9958dbf8f71a'
# By Andreas Andreou
# Via Andreas Andreou (1) and Tony Tam (1)
* commit '4ee046d39c58cbf72042bf72616e9958dbf8f71a':
  toggleOperationContent to escape resource name before querying for node
2013-03-01 09:48:35 +01:00
Tony Tam 4ee046d39c Merge pull request #154 from andyhot/master
toggleOperationContent needs to escape resource name
2013-02-28 22:24:44 -08:00
Pepijn de Geus d9285f175d More CSS cleaning. 2013-02-28 12:59:30 +01:00
Pepijn de Geus 4fb7ffdcac Fix custom bold text. 2013-02-28 11:20:25 +01:00
Pepijn de Geus d205753044 UI improvements for parameters (input and read-only) and model description.
Uses changes to swagger.js (swagger-client).
2013-02-27 17:01:25 +01:00
Pepijn de Geus 1a017d46a5 Update to Handlebars 1.0.10+, CoffeeScript 1.5 2013-02-27 16:37:40 +01:00
Andreas Andreou 29b3d1dc68 toggleOperationContent to escape resource name before querying for node 2013-02-25 16:05:03 +02:00
Tony Tam e7e95c372e updated swagger.js dependency for #136 2013-02-20 08:53:25 -08:00
Tony Tam a79a6600cc Merge branch 'master' of github.com:wordnik/swagger-ui 2013-02-08 11:57:54 -08:00
Tony Tam c016b2977f added ignore file 2013-02-08 11:57:44 -08:00
Tony Tam b6d60786c1 added swagger-client as dependency, renamed from to to avoid collisions 2013-02-08 11:54:57 -08:00
Tony Tam 39e36013b0 Merge pull request #141 from rawsyntax/master
add the correct link for distribution downloads
2013-02-04 16:37:08 -08:00
Eric Himmelreich 2a16842f6b add correct link to distribution downloads 2013-02-04 14:17:18 -05:00
Tony Tam e318616cd1 reverted default url 2013-02-04 10:39:45 -08:00
Tony Tam 9b1bd11f2d fix for #121 2013-02-01 21:32:14 -05:00
Tony Tam f195c65880 improved error handling 2013-01-31 22:02:44 -05:00
Tony Tam 1ec55a8829 update for swagger.js#14, #138, #139 2013-01-31 20:06:34 -05:00
Tony Tam 7a23876ce7 updated README for download instructions 2013-01-25 20:16:14 -08:00
Tony Tam 8a9d41ca27 added dist folder back now that git downloads are gone 2013-01-25 20:15:23 -08:00
Tony Tam f0f6a07a61 fixed file bug for indent issue and param type check 2013-01-25 20:13:09 -08:00
Tony Tam ba2263e6f3 Merge pull request #133 from Filirom1/master
Simplify build
2013-01-23 09:44:18 -08:00
Filirom1 8669ad1018 update README 2013-01-23 17:22:18 +01:00
Filirom1 baab722d64 simplify build 2013-01-23 17:20:34 +01:00
71 changed files with 21236 additions and 4593 deletions
+1 -1
View File
@@ -3,7 +3,6 @@ wordnik*.zip
*.ipr
*.iml
*.iws
dist/
lib/*.jar
META-INF/
web/
@@ -20,3 +19,4 @@ reports/*
swagger-ui.sublime-workspace
.idea
.project
node_modules/*
+7
View File
@@ -0,0 +1,7 @@
*.sublime-*
example.html
*.tgz
.classpath
.project
.npmignore
node_modules
+31 -8
View File
@@ -1,6 +1,7 @@
fs = require 'fs'
path = require 'path'
{exec} = require 'child_process'
less = require 'less'
sourceFiles = [
'SwaggerUi'
@@ -12,6 +13,8 @@ sourceFiles = [
'view/ParameterView'
'view/SignatureView'
'view/ContentTypeView'
'view/ResponseContentTypeView'
'view/ParameterContentTypeView'
]
@@ -62,19 +65,38 @@ task 'dist', 'Build a distribution', ->
throw err if err
fs.unlink 'dist/_swagger-ui.coffee'
console.log ' : Combining with javascript...'
exec 'cat src/main/javascript/doc.js dist/_swagger-ui-templates.js dist/_swagger-ui.js > dist/swagger-ui.js', (err, stdout, stderr) ->
throw err if err
fs.unlink 'dist/_swagger-ui.js'
fs.unlink 'dist/_swagger-ui-templates.js'
console.log ' : Minifying all...'
exec 'java -jar "./bin/yuicompressor-2.4.7.jar" --type js -o ' + 'dist/swagger-ui.min.js ' + 'dist/swagger-ui.js', (err, stdout, stderr) ->
fs.readFile 'package.json', 'utf8', (err, fileContents) ->
obj = JSON.parse(fileContents)
exec 'echo "// swagger-ui.js" > dist/swagger-ui.js'
exec 'echo "// version ' + obj.version + '" >> dist/swagger-ui.js'
exec 'cat src/main/javascript/doc.js dist/_swagger-ui-templates.js dist/_swagger-ui.js >> dist/swagger-ui.js', (err, stdout, stderr) ->
throw err if err
pack()
fs.unlink 'dist/_swagger-ui.js'
fs.unlink 'dist/_swagger-ui-templates.js'
console.log ' : Minifying all...'
exec 'java -jar "./bin/yuicompressor-2.4.7.jar" --type js -o ' + 'dist/swagger-ui.min.js ' + 'dist/swagger-ui.js', (err, stdout, stderr) ->
throw err if err
lessc()
lessc = ->
# Someone who knows CoffeeScript should make this more Coffee-licious
console.log ' : Compiling LESS...'
less.render fs.readFileSync("src/main/less/screen.less", 'utf8'), (err, css) ->
fs.writeFileSync("src/main/html/css/screen.css", css)
less.render fs.readFileSync("src/main/less/reset.less", 'utf8'), (err, css) ->
fs.writeFileSync("src/main/html/css/reset.css", css)
pack()
pack = ->
console.log ' : Packaging...'
exec 'cp -r lib dist'
console.log ' : Copied swagger-ui libs'
exec 'cp -r node_modules/swagger-client/lib/swagger.js dist/lib'
console.log ' : Copied swagger dependencies'
exec 'cp -r src/main/html/* dist'
console.log ' : Copied html dependencies'
console.log ' !'
task 'spec', "Run the test suite", ->
@@ -104,6 +126,7 @@ task 'watch', 'Watch source files for changes and autocompile', ->
watchFiles("src/main/template")
watchFiles("src/main/javascript")
watchFiles("src/main/html")
watchFiles("src/main/less")
watchFiles("src/test")
notify = (message) ->
@@ -112,4 +135,4 @@ notify = (message) ->
# options =
# title: 'CoffeeScript'
# image: 'bin/CoffeeScript.png'
# try require('growl') message, options
# try require('growl') message, options
+11
View File
@@ -0,0 +1,11 @@
Copyright 2014 Reverb Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+49 -44
View File
@@ -1,31 +1,35 @@
Swagger UI
==========
# Swagger UI
Swagger UI is part of [Swagger](http://swagger.wordnik.com/) project. The Swagger project allows you to produce, visualize and consume your OWN RESTful
services. No proxy or 3rd party services required. Do it your own way.
Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically
generate beautiful documentation and sandbox from a [Swagger-compliant](https://github.com/wordnik/swagger-core/wiki) API. Because Swagger UI has no
dependencies, you can host it in any server environment, or on your local machine.
Swagger UI is part of Swagger project. The Swagger project allows you to produce, visualize and consume your OWN RESTful services. No proxy or 3rd party services required. Do it your own way.
How to Use It
-------------
Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically
generate beautiful documentation and sandbox from a Swagger-compliant API. Because Swagger UI has no dependencies, you can host it in any server environment, or on your local machine.
## What's Swagger?
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swager removes the guesswork in calling the service.
Check out [Swagger-Spec](https://github.com/wordnik/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
## How to Use It
### Download
You can use the swagger-ui code AS-IS! No need to build or recompile--just [download](https://github.com/wordnik/swagger-ui/downloads) the distribution,
unpack and start using it. If you like swagger-ui as-is, stop here.
You can use the swagger-ui code AS-IS! No need to build or recompile--just clone this repo and use the pre-built files in the `dist` folder. If you like swagger-ui as-is, stop here.
### Build
You can rebuild swagger-ui on your own to tweak it or just so you can say you did. To do so, follow these steps:
1. Install [CoffeeScript](http://coffeescript.org/#installation) which will give you [cake](http://coffeescript.org/#cake)
2. Install [handlebars](http://handlebarsjs.com/) using 'npm install handlebars -g'
3. Run cake dist
4. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
1. install [handlebars](http://handlebarsjs.com/)
2. install java
3. npm install
4. npm run-script build
5. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
### Use
Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.wordnik.com/api/resources.json) service and show its APIs.
You can enter your own server url and click explore to view the API.
Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.wordnik.com/api/api-docs) service and show its APIs. You can enter your own server url and click explore to view the API.
### Customize
You may choose to customize Swagger UI for your organization. Here is an overview of whats in its various directories:
@@ -38,23 +42,20 @@ You may choose to customize Swagger UI for your organization. Here is an overvie
- src/main/coffeescript: main code in CoffeeScript
- src/main/templates: [handlebars](http://handlebarsjs.com/) templates used to render swagger-ui
- src/main/html: the html files, some images and css
- src/main/javascript: some legacy javascript referenced by CofffeeScript code
- src/main/javascript: some legacy javascript referenced by CoffeeScript code
### SwaggerUi
To use swagger-ui you should take a look at the [source of swagger-ui html page](https://github.com/wordnik/swagger-ui/tree/master/src/main/html) and customize it. This basically requires you to instantiate a SwaggerUi object and call load() on it as below:
```javascript
window.swaggerUi = new SwaggerUi({
discoveryUrl:"http://petstore.swagger.wordnik.com/api/resources.json",
dom_id:"swagger-ui-container",
apiKey:"special-key",
supportHeaderParams: false,
headers: { "Authorization": "XXXX", "someOtherHeader": "YYYY" },
supportedSubmitMethods: ['get', 'post', 'put']
url:"http://petstore.swagger.wordnik.com/api/api-docs",
dom_id:"swagger-ui-container"
});
window.swaggerUi.load();
```
* *discoveryUrl* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/wordnik/swagger-core/wiki)
* *url* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/wordnik/swagger-core/wiki)
* *dom_id parameter* is the the id of a dom element inside which SwaggerUi will put the user interface for swagger
* *booleanValues* SwaggerUI renders boolean data types as a dropdown. By default it provides a 'true' and 'false' string as the possible choices. You can use this parameter to change the values in dropdown to be something else, for example 0 and 1 by setting booleanValues to new Array(0, 1)
* *docExpansion* controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details)
@@ -64,40 +65,44 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
### HTTP Methods and API Invocation
swagger-ui supports invocation of all HTTP methods APIs but only GET methods APIs are enabled by default. You can choose to enable other HTTP methods like POST, PUT and DELETE. This can be enabled by [setting the supportedSubmitMethods parameter when creating SwaggerUI instance](https://github.com/wordnik/swagger-ui/blob/f2e63c65a759421aad590b7275371cd0c06c74ea/src/main/html/index.html#L49).
swagger-ui supports invocation of all HTTP methods APIs including GET, PUT, POST, DELETE, PATCH, OPTIONS. These are handled in the [swagger-js](https://github.com/wordnik/swagger-js) project, please see there for specifics on their usage.
For example if you wanted to enable GET, POST and PUT but not for DELETE, you'd set this as:
supportedSubmitMethods: ['get', 'post', 'put']
_Note that for POST/PUT body, you'd need to paste in the request data in an appropriate format which your service can unmarshall_
### Header Parameters
header parameters are supported. However because of [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/) restrictions, swagger-ui, by default, does not send header parameters. This can be enabled by [setting the supportHeaderParams to true when creating SwaggerUI instance](https://github.com/wordnik/swagger-ui/blob/f2e63c65a759421aad590b7275371cd0c06c74ea/src/main/html/index.html#L48) as below:
Header params are supported through a pluggable mechanism in [swagger-js](https://github.com/wordnik/swagger-js). You can see the [index.html](https://github.com/wordnik/swagger-ui/blob/master/dist/index.html) for a sample of how to dynamically set headers:
supportHeaderParams: true
```js
// add a new ApiKeyAuthorization when the api-key changes in the ui.
$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
if(key && key.trim() != "") {
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "header"));
}
})
```
This will add header `api_key` with value `key` on every call to the server. You can substitute `query` to send the values as a query param.
### Custom Header Parameters - (For Basic auth etc)
If you have some header parameters which you need to send with every request, use the headers as below:
headers: { "Authorization": "XXXX", "someOtherHeader": "YYYY" }
```js
window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "XXXX", "header"));
```
### Api Key Parameter
If you enter an api key in swagger-ui, it sends a parameter named 'api\_key' as a query (or as a header param if you've enabled it as described above). You may not want to use the name 'api\_key' as the name of this parameter. You can change its name by setting the _apiKeyName_ parameter when you instantiate a SwaggerUI instance. For example to call it 'sessionId'
Note! You can pass multiple header params on a single request, just use unique names for them (`key` is used in the above example).
apiKeyName: "sessionId"
How to Improve It
-----------------
## How to Improve It
Create your own fork of [wordnik/swagger-ui](https://github.com/wordnik/swagger-ui)
To share your changes, [submit a pull request](https://github.com/wordnik/swagger-ui/pull/new/master).
License
-------
Since the javascript files are compiled from coffeescript, please submit changes in the *.coffee files! We have to reject changes only in the .js files as they will be lost on each build of the ui.
Copyright 2011-2012 Wordnik, Inc.
## License
Copyright 2011-2013 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
+125
View File
@@ -0,0 +1,125 @@
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
+1221
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 980 B

+87
View File
@@ -0,0 +1,87 @@
<!DOCTYPE html>
<html>
<head>
<title>Swagger UI</title>
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/>
<script type="text/javascript" src="lib/shred.bundle.js"></script>
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
<script src='lib/handlebars-1.0.0.js' type='text/javascript'></script>
<script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='lib/swagger.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<!-- enabling this will enable oauth2 implicit scope support -->
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
url: "http://petstore.swagger.wordnik.com/api/api-docs",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none"
});
$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
log("added key " + key);
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
}
})
window.swaggerUi.load();
});
</script>
</head>
<body class="swagger-section">
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="http://swagger.wordnik.com">swagger</a>
<form id='api_selector'>
<div class='input icon-btn'>
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
</div>
<div class='input icon-btn'>
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
</div>
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
<div class='input'><a id="explore" href="#">Explore</a></div>
</form>
</div>
</div>
<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>
+38
View File
@@ -0,0 +1,38 @@
// Backbone.js 0.9.2
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
(function(){var l=this,y=l.Backbone,z=Array.prototype.slice,A=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:l.Backbone={};g.VERSION="0.9.2";var f=l._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var i=l.jQuery||l.Zepto||l.ender;g.setDomLibrary=function(a){i=a};g.noConflict=function(){l.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,k=g.Events={on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks=
{});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,h,g,j,q;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(h=e[d],delete e[d],h&&(b||c))for(g=h.tail;(h=h.next)!==g;)if(j=h.callback,q=h.context,b&&j!==b||c&&q!==c)this.on(d,j,q);return this}},trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(p);for(g=
z.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};k.bind=k.on;k.unbind=k.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent=
{};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,k,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null==
b?"":""+b)},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},h=this.attributes,g=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(h[e],a)||c.unset&&f.has(h,e))delete g[e],(c.silent?this._silent:
b)[e]=!0;c.unset?delete h[e]:h[e]=a;!f.isEqual(j[e],a)||f.has(h,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)};
a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;c.success=function(a,b,e){b=h.parse(a,e);if(c.wait){delete c.wait;b=f.extend(d||{},b)}if(!h.set(b,c))return false;i?i(h,a):h.trigger("sync",h,a,c)};c.error=g.wrapError(c.error,
h,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),!1;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync||g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t();
return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending=
{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length||
!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var r=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);b.comparator&&(this.comparator=b.comparator);
this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};f.extend(r.prototype,k,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,i,j={},k={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++){if(!(e=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");g=e.cid;i=e.id;j[g]||this._byCid[g]||null!=i&&(k[i]||this._byId[i])?
l.push(c):j[g]=k[i]=e}for(c=l.length;c--;)a.splice(l[c],1);c=0;for(d=a.length;c<d;c++)(e=a[c]).on("all",this._onModelEvent,this),this._byCid[e.cid]=e,null!=e.id&&(this._byId[e.id]=e);this.length+=d;A.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a));this.comparator&&this.sort({silent:!0});if(b.silent)return this;c=0;for(d=this.models.length;c<d;c++)if(j[(e=this.models[c]).cid])b.index=c,e.trigger("add",e,this,b);return this},remove:function(a,b){var c,d,e,g;b||(b={});a=f.isArray(a)?
a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,f.extend({at:0},b));return a},
shift:function(a){var b=this.at(0);this.remove(b,a);return b},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return f.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==b.get(c))return!1;return!0})},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);1==this.comparator.length?
this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();this.add(a,f.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?f.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d,
e,f){b[a.add?"add":"reset"](b.parse(d,f),a);c&&c(b,d)};a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(e,f){b.wait&&c.add(e,b);d?d(e,f):e.trigger("sync",a,f,b)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId=
{};this._byCid={}},_prepareModel:function(a,b){b||(b={});a instanceof o?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1));return a},_removeReference:function(a){this==a.collection&&delete a.collection;a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,
arguments))}});f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){r.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});var u=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},B=/:\w+/g,
C=/\*\w+/g,D=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(u.prototype,k,{initialize:function(){},route:function(a,b,c){g.history||(g.history=new m);f.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,f.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,
this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(D,"\\$&").replace(B,"([^/]+)").replace(C,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});var m=g.History=function(){this.handlers=[];f.bindAll(this,"checkUrl")},s=/^[#\/]/,E=/msie [\w.]+/;m.started=!1;f.extend(m.prototype,k,{interval:50,getHash:function(a){return(a=(a?a.location:window.location).href.match(/#(.*)$/))?a[1]:
""},getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=this.getHash();a.indexOf(this.options.root)||(a=a.substr(this.options.root.length));return a.replace(s,"")},start:function(a){if(m.started)throw Error("Backbone.history has already been started");m.started=!0;this.options=f.extend({},{root:"/"},this.options,a);this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=
!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=E.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=i('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?i(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?i(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,
this.interval));this.fragment=a;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=this.getHash().replace(s,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},
stop:function(){i(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);m.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a==this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,
function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m.started)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(s,"");this.fragment!=c&&(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.getHash(this.iframe))&&(b.replace||
this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},F=/^(\S+)\s*(.*)$/,w="model,collection,el,id,attributes,className,tagName".split(",");
f.extend(v.prototype,k,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&i(a).attr(b);c&&i(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof i?a:i(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=n(this,"events"))){this.undelegateEvents();
for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(F),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b<c;b++){var d=w[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,
!1);else{var a=n(this,"attributes")||{};this.id&&(a.id=this.id);this.className&&(a["class"]=this.className);this.setElement(this.make(this.tagName,a),!1)}}});o.extend=r.extend=u.extend=v.extend=function(a,b){var c=G(this,a,b);c.extend=this.extend;return c};var H={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=H[a];c||(c={});var e={type:d,dataType:"json"};c.url||(e.url=n(b,"url")||t());if(!c.data&&b&&("create"==a||"update"==a))e.contentType="application/json",
e.data=JSON.stringify(b.toJSON());g.emulateJSON&&(e.contentType="application/x-www-form-urlencoded",e.data=e.data?{model:e.data}:{});if(g.emulateHTTP&&("PUT"===d||"DELETE"===d))g.emulateJSON&&(e.data._method=d),e.type="POST",e.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)};"GET"!==e.type&&!g.emulateJSON&&(e.processData=!1);return i.ajax(f.extend(e,c))};g.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var x=function(){},G=function(a,
b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)};f.extend(d,a);x.prototype=a.prototype;d.prototype=new x;b&&f.extend(d.prototype,b);c&&f.extend(d,c);d.prototype.constructor=d;d.__super__=a.prototype;return d},n=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified');}}).call(this);
+2278
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+2
View File
File diff suppressed because one or more lines are too long
+18
View File
@@ -0,0 +1,18 @@
/*
* jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
* http://benalman.com/projects/jquery-bbq-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this);
/*
* jQuery hashchange event - v1.2 - 2/11/2010
* http://benalman.com/projects/jquery-hashchange-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
+1
View File
@@ -0,0 +1 @@
(function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery);
+8
View File
@@ -0,0 +1,8 @@
/*
jQuery Wiggle
Author: WonderGroup, Jordan Thomas
URL: http://labs.wondergroup.com/demos/mini-ui/index.html
License: MIT (http://en.wikipedia.org/wiki/MIT_License)
*/
jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
+2765
View File
File diff suppressed because it is too large Load Diff
+193
View File
@@ -0,0 +1,193 @@
// The purpose of the `Content` object is to abstract away the data conversions
// to and from raw content entities as strings. For example, you want to be able
// to pass in a Javascript object and have it be automatically converted into a
// JSON string if the `content-type` is set to a JSON-based media type.
// Conversely, you want to be able to transparently get back a Javascript object
// in the response if the `content-type` is a JSON-based media-type.
// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
// The `Content` constructor takes an options object, which *must* have either a
// `body` or `data` property and *may* have a `type` property indicating the
// media type. If there is no `type` attribute, a default will be inferred.
var Content = function(options) {
this.body = options.body;
this.data = options.data;
this.type = options.type;
};
Content.prototype = {
// Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
//
// toString: function() { return this.body; }
//
// Commented out, but I've forgotten why. :/
};
// `Content` objects have the following attributes:
Object.defineProperties(Content.prototype,{
// - **type**. Typically accessed as `content.type`, reflects the `content-type`
// header associated with the request or response. If not passed as an options
// to the constructor or set explicitly, it will infer the type the `data`
// attribute, if possible, and, failing that, will default to `text/plain`.
type: {
get: function() {
if (this._type) {
return this._type;
} else {
if (this._data) {
switch(typeof this._data) {
case "string": return "text/plain";
case "object": return "application/json";
}
}
}
return "text/plain";
},
set: function(value) {
this._type = value;
return this;
},
enumerable: true
},
// - **data**. Typically accessed as `content.data`, reflects the content entity
// converted into Javascript data. This can be a string, if the `type` is, say,
// `text/plain`, but can also be a Javascript object. The conversion applied is
// based on the `processor` attribute. The `data` attribute can also be set
// directly, in which case the conversion will be done the other way, to infer
// the `body` attribute.
data: {
get: function() {
if (this._body) {
return this.processor.parser(this._body);
} else {
return this._data;
}
},
set: function(data) {
if (this._body&&data) Errors.setDataWithBody(this);
this._data = data;
return this;
},
enumerable: true
},
// - **body**. Typically accessed as `content.body`, reflects the content entity
// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
// `data` attribute, the `body` attribute will be inferred and vice-versa. If
// you attempt to set both, an exception is raised.
body: {
get: function() {
if (this._data) {
return this.processor.stringify(this._data);
} else {
return this._body.toString();
}
},
set: function(body) {
if (this._data&&body) Errors.setBodyWithData(this);
this._body = body;
return this;
},
enumerable: true
},
// - **processor**. The functions that will be used to convert to/from `data` and
// `body` attributes. You can add processors. The two that are built-in are for
// `text/plain`, which is basically an identity transformation and
// `application/json` and other JSON-based media types (including custom media
// types with `+json`). You can add your own processors. See below.
processor: {
get: function() {
var processor = Content.processors[this.type];
if (processor) {
return processor;
} else {
// Return the first processor that matches any part of the
// content type. ex: application/vnd.foobar.baz+json will match json.
var main = this.type.split(";")[0];
var parts = main.split(/\+|\//);
for (var i=0, l=parts.length; i < l; i++) {
processor = Content.processors[parts[i]]
}
return processor || {parser:identity,stringify:toString};
}
},
enumerable: true
},
// - **length**. Typically accessed as `content.length`, returns the length in
// bytes of the raw content entity.
length: {
get: function() {
if (typeof Buffer !== 'undefined') {
return Buffer.byteLength(this.body);
}
return this.body.length;
}
}
});
Content.processors = {};
// The `registerProcessor` function allows you to add your own processors to
// convert content entities. Each processor consists of a Javascript object with
// two properties:
// - **parser**. The function used to parse a raw content entity and convert it
// into a Javascript data type.
// - **stringify**. The function used to convert a Javascript data type into a
// raw content entity.
Content.registerProcessor = function(types,processor) {
// You can pass an array of types that will trigger this processor, or just one.
// We determine the array via duck-typing here.
if (types.forEach) {
types.forEach(function(type) {
Content.processors[type] = processor;
});
} else {
// If you didn't pass an array, we just use what you pass in.
Content.processors[types] = processor;
}
};
// Register the identity processor, which is used for text-based media types.
var identity = function(x) { return x; }
, toString = function(x) { return x.toString(); }
Content.registerProcessor(
["text/html","text/plain","text"],
{ parser: identity, stringify: toString });
// Register the JSON processor, which is used for JSON-based media types.
Content.registerProcessor(
["application/json; charset=utf-8","application/json","json"],
{
parser: function(string) {
return JSON.parse(string);
},
stringify: function(data) {
return JSON.stringify(data); }});
var qs = require('querystring');
// Register the post processor, which is used for JSON-based media types.
Content.registerProcessor(
["application/x-www-form-urlencoded"],
{ parser : qs.parse, stringify : qs.stringify });
// Error functions are defined separately here in an attempt to make the code
// easier to read.
var Errors = {
setDataWithBody: function(object) {
throw new Error("Attempt to set data attribute of a content object " +
"when the body attributes was already set.");
},
setBodyWithData: function(object) {
throw new Error("Attempt to set body attribute of a content object " +
"when the data attributes was already set.");
}
}
module.exports = Content;
+218
View File
@@ -0,0 +1,218 @@
var appName;
var popupMask;
var popupDialog;
var clientId;
var realm;
function handleLogin() {
var scopes = [];
if(window.swaggerUi.api.authSchemes
&& window.swaggerUi.api.authSchemes.oauth2
&& window.swaggerUi.api.authSchemes.oauth2.scopes) {
scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
}
if(window.swaggerUi.api
&& window.swaggerUi.api.info) {
appName = window.swaggerUi.api.info.title;
}
if(popupDialog.length > 0)
popupDialog = popupDialog.last();
else {
popupDialog = $(
[
'<div class="api-popup-dialog">',
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
'<div class="api-popup-content">',
'<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.',
'<a href="#">Learn how to use</a>',
'</p>',
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
'<ul class="api-popup-scopes">',
'</ul>',
'<p class="error-msg"></p>',
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
'</div>',
'</div>'].join(''));
$(document.body).append(popupDialog);
popup = popupDialog.find('ul.api-popup-scopes').empty();
for (i = 0; i < scopes.length; i ++) {
scope = scopes[i];
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
if (scope.description) {
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
}
str += '</label></li>';
popup.append(str);
}
var $win = $(window),
dw = $win.width(),
dh = $win.height(),
st = $win.scrollTop(),
dlgWd = popupDialog.outerWidth(),
dlgHt = popupDialog.outerHeight(),
top = (dh -dlgHt)/2 + st,
left = (dw - dlgWd)/2;
popupDialog.css({
top: (top < 0? 0 : top) + 'px',
left: (left < 0? 0 : left) + 'px'
});
popupDialog.find('button.api-popup-cancel').click(function() {
popupMask.hide();
popupDialog.hide();
});
popupDialog.find('button.api-popup-authbtn').click(function() {
popupMask.hide();
popupDialog.hide();
var authSchemes = window.swaggerUi.api.authSchemes;
var location = window.location;
var locationUrl = location.protocol + '//' + location.host + location.pathname;
var redirectUrl = locationUrl.replace("index.html","").concat("/o2c.html").replace("//o2c.html","/o2c.html");
var url = null;
var p = window.swaggerUi.api.authSchemes;
for (var key in p) {
if (p.hasOwnProperty(key)) {
var o = p[key].grantTypes;
for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
url = dets.loginEndpoint.url + "?response_type=token";
window.swaggerUi.tokenName = dets.tokenName;
}
}
}
}
var scopes = [];
var scopeForUrl='';
var o = $('.api-popup-scopes').find('input:checked');
for(var k =0; k < o.length; k++) {
scopes.push($(o[k]).attr("scope"));
if(k > 0){
scopeForUrl+=' ';
}
scopeForUrl+=$(o[k]).attr("scope");
}
window.enabledScopes=scopes;
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopeForUrl);
window.open(url);
});
}
popupMask.show();
popupDialog.show();
return;
}
function handleLogout() {
for(key in window.authorizations.authz){
window.authorizations.remove(key)
}
window.enabledScopes = null;
$('.api-ic.ic-on').addClass('ic-off');
$('.api-ic.ic-on').removeClass('ic-on');
// set the info box
$('.api-ic.ic-warning').addClass('ic-error');
$('.api-ic.ic-warning').removeClass('ic-warning');
}
function initOAuth(opts) {
var o = (opts||{});
var errors = [];
appName = (o.appName||errors.push("missing appName"));
popupMask = (o.popupMask||$('#api-common-mask'));
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
clientId = (o.clientId||errors.push("missing client id"));
realm = (o.realm||errors.push("missing realm"));
if(errors.length > 0){
log("auth unable initialize oauth: " + errors);
return;
}
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
$('.api-ic').click(function(s) {
if($(s.target).hasClass('ic-off'))
handleLogin();
else {
handleLogout();
}
false;
});
}
function onOAuthComplete(token) {
if(token) {
if(token.error) {
var checkbox = $('input[type=checkbox],.secured')
checkbox.each(function(pos){
checkbox[pos].checked = false;
});
alert(token.error);
}
else {
var b = token[window.swaggerUi.tokenName];
if(b){
// if all roles are satisfied
var o = null;
$.each($('.auth #api_information_panel'), function(k, v) {
var children = v;
if(children && children.childNodes) {
var requiredScopes = [];
$.each((children.childNodes), function (k1, v1){
var inner = v1.innerHTML;
if(inner)
requiredScopes.push(inner);
});
var diff = [];
for(var i=0; i < requiredScopes.length; i++) {
var s = requiredScopes[i];
if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
diff.push(s);
}
}
if(diff.length > 0){
o = v.parentNode;
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
// sorry, not all scopes are satisfied
$(o).find('.api-ic').addClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error');
}
else {
o = v.parentNode;
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
// all scopes are satisfied
$(o).find('.api-ic').addClass('ic-info');
$(o).find('.api-ic').removeClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error');
}
}
});
window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
}
}
}
}
+1569
View File
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
// Underscore.js 1.3.3
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore
(function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break;
g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a,
c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.map===z)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(A&&
a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,
c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,
a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&
(e={value:a,computed:b})});return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){d=Math.floor(Math.random()*(f+1));b[f]=b[d];b[d]=a});return b};b.sortBy=function(a,c,d){var e=b.isFunction(c)?c:function(a){return a[c]};return b.pluck(b.map(a,function(a,b,c){return{value:a,criteria:e.call(d,a,b,c)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c===void 0?1:d===void 0?-1:c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};
j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?i.call(a):a.toArray&&b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=b.take=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,
0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,
e=[];a.length<3&&(c=true);b.reduce(d,function(d,g,h){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[h])}return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=
i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(F&&a.lastIndexOf===F)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){if(arguments.length<=
1){b=a||0;a=0}for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+d}return g};var H=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));H.prototype=a.prototype;var b=new H,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=
i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i,j=b.debounce(function(){h=
g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);j()},c));g?h=true:i=a.apply(d,e);j();g=true;return i}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments;d&&!e&&a.apply(f,g);clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));
return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&
c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=
function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"};
b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,
b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId=
function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape||
u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};
b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d,
this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
+15
View File
@@ -0,0 +1,15 @@
<script>
var qp = null;
if(window.location.hash) {
qp = location.hash.substring(1);
}
else {
qp = location.search.substring(1);
}
qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
function(key, value) {
return key===""?value:decodeURIComponent(value) }
):{}
window.opener.onOAuthComplete(qp);
window.close();
</script>
+2269
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+7
View File
@@ -0,0 +1,7 @@
var pack = require('./package');
var path = require('path');
module.exports = {
version: pack.version,
dist: path.resolve(__dirname, 'dist')
};
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2765
View File
File diff suppressed because it is too large Load Diff
+193
View File
@@ -0,0 +1,193 @@
// The purpose of the `Content` object is to abstract away the data conversions
// to and from raw content entities as strings. For example, you want to be able
// to pass in a Javascript object and have it be automatically converted into a
// JSON string if the `content-type` is set to a JSON-based media type.
// Conversely, you want to be able to transparently get back a Javascript object
// in the response if the `content-type` is a JSON-based media-type.
// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
// The `Content` constructor takes an options object, which *must* have either a
// `body` or `data` property and *may* have a `type` property indicating the
// media type. If there is no `type` attribute, a default will be inferred.
var Content = function(options) {
this.body = options.body;
this.data = options.data;
this.type = options.type;
};
Content.prototype = {
// Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
//
// toString: function() { return this.body; }
//
// Commented out, but I've forgotten why. :/
};
// `Content` objects have the following attributes:
Object.defineProperties(Content.prototype,{
// - **type**. Typically accessed as `content.type`, reflects the `content-type`
// header associated with the request or response. If not passed as an options
// to the constructor or set explicitly, it will infer the type the `data`
// attribute, if possible, and, failing that, will default to `text/plain`.
type: {
get: function() {
if (this._type) {
return this._type;
} else {
if (this._data) {
switch(typeof this._data) {
case "string": return "text/plain";
case "object": return "application/json";
}
}
}
return "text/plain";
},
set: function(value) {
this._type = value;
return this;
},
enumerable: true
},
// - **data**. Typically accessed as `content.data`, reflects the content entity
// converted into Javascript data. This can be a string, if the `type` is, say,
// `text/plain`, but can also be a Javascript object. The conversion applied is
// based on the `processor` attribute. The `data` attribute can also be set
// directly, in which case the conversion will be done the other way, to infer
// the `body` attribute.
data: {
get: function() {
if (this._body) {
return this.processor.parser(this._body);
} else {
return this._data;
}
},
set: function(data) {
if (this._body&&data) Errors.setDataWithBody(this);
this._data = data;
return this;
},
enumerable: true
},
// - **body**. Typically accessed as `content.body`, reflects the content entity
// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
// `data` attribute, the `body` attribute will be inferred and vice-versa. If
// you attempt to set both, an exception is raised.
body: {
get: function() {
if (this._data) {
return this.processor.stringify(this._data);
} else {
return this._body.toString();
}
},
set: function(body) {
if (this._data&&body) Errors.setBodyWithData(this);
this._body = body;
return this;
},
enumerable: true
},
// - **processor**. The functions that will be used to convert to/from `data` and
// `body` attributes. You can add processors. The two that are built-in are for
// `text/plain`, which is basically an identity transformation and
// `application/json` and other JSON-based media types (including custom media
// types with `+json`). You can add your own processors. See below.
processor: {
get: function() {
var processor = Content.processors[this.type];
if (processor) {
return processor;
} else {
// Return the first processor that matches any part of the
// content type. ex: application/vnd.foobar.baz+json will match json.
var main = this.type.split(";")[0];
var parts = main.split(/\+|\//);
for (var i=0, l=parts.length; i < l; i++) {
processor = Content.processors[parts[i]]
}
return processor || {parser:identity,stringify:toString};
}
},
enumerable: true
},
// - **length**. Typically accessed as `content.length`, returns the length in
// bytes of the raw content entity.
length: {
get: function() {
if (typeof Buffer !== 'undefined') {
return Buffer.byteLength(this.body);
}
return this.body.length;
}
}
});
Content.processors = {};
// The `registerProcessor` function allows you to add your own processors to
// convert content entities. Each processor consists of a Javascript object with
// two properties:
// - **parser**. The function used to parse a raw content entity and convert it
// into a Javascript data type.
// - **stringify**. The function used to convert a Javascript data type into a
// raw content entity.
Content.registerProcessor = function(types,processor) {
// You can pass an array of types that will trigger this processor, or just one.
// We determine the array via duck-typing here.
if (types.forEach) {
types.forEach(function(type) {
Content.processors[type] = processor;
});
} else {
// If you didn't pass an array, we just use what you pass in.
Content.processors[types] = processor;
}
};
// Register the identity processor, which is used for text-based media types.
var identity = function(x) { return x; }
, toString = function(x) { return x.toString(); }
Content.registerProcessor(
["text/html","text/plain","text"],
{ parser: identity, stringify: toString });
// Register the JSON processor, which is used for JSON-based media types.
Content.registerProcessor(
["application/json; charset=utf-8","application/json","json"],
{
parser: function(string) {
return JSON.parse(string);
},
stringify: function(data) {
return JSON.stringify(data); }});
var qs = require('querystring');
// Register the post processor, which is used for JSON-based media types.
Content.registerProcessor(
["application/x-www-form-urlencoded"],
{ parser : qs.parse, stringify : qs.stringify });
// Error functions are defined separately here in an attempt to make the code
// easier to read.
var Errors = {
setDataWithBody: function(object) {
throw new Error("Attempt to set data attribute of a content object " +
"when the body attributes was already set.");
},
setBodyWithData: function(object) {
throw new Error("Attempt to set body attribute of a content object " +
"when the data attributes was already set.");
}
}
module.exports = Content;
+218
View File
@@ -0,0 +1,218 @@
var appName;
var popupMask;
var popupDialog;
var clientId;
var realm;
function handleLogin() {
var scopes = [];
if(window.swaggerUi.api.authSchemes
&& window.swaggerUi.api.authSchemes.oauth2
&& window.swaggerUi.api.authSchemes.oauth2.scopes) {
scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
}
if(window.swaggerUi.api
&& window.swaggerUi.api.info) {
appName = window.swaggerUi.api.info.title;
}
if(popupDialog.length > 0)
popupDialog = popupDialog.last();
else {
popupDialog = $(
[
'<div class="api-popup-dialog">',
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
'<div class="api-popup-content">',
'<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.',
'<a href="#">Learn how to use</a>',
'</p>',
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
'<ul class="api-popup-scopes">',
'</ul>',
'<p class="error-msg"></p>',
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
'</div>',
'</div>'].join(''));
$(document.body).append(popupDialog);
popup = popupDialog.find('ul.api-popup-scopes').empty();
for (i = 0; i < scopes.length; i ++) {
scope = scopes[i];
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
if (scope.description) {
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
}
str += '</label></li>';
popup.append(str);
}
var $win = $(window),
dw = $win.width(),
dh = $win.height(),
st = $win.scrollTop(),
dlgWd = popupDialog.outerWidth(),
dlgHt = popupDialog.outerHeight(),
top = (dh -dlgHt)/2 + st,
left = (dw - dlgWd)/2;
popupDialog.css({
top: (top < 0? 0 : top) + 'px',
left: (left < 0? 0 : left) + 'px'
});
popupDialog.find('button.api-popup-cancel').click(function() {
popupMask.hide();
popupDialog.hide();
});
popupDialog.find('button.api-popup-authbtn').click(function() {
popupMask.hide();
popupDialog.hide();
var authSchemes = window.swaggerUi.api.authSchemes;
var location = window.location;
var locationUrl = location.protocol + '//' + location.host + location.pathname;
var redirectUrl = locationUrl.replace("index.html","").concat("/o2c.html").replace("//o2c.html","/o2c.html");
var url = null;
var p = window.swaggerUi.api.authSchemes;
for (var key in p) {
if (p.hasOwnProperty(key)) {
var o = p[key].grantTypes;
for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
url = dets.loginEndpoint.url + "?response_type=token";
window.swaggerUi.tokenName = dets.tokenName;
}
}
}
}
var scopes = [];
var scopeForUrl='';
var o = $('.api-popup-scopes').find('input:checked');
for(var k =0; k < o.length; k++) {
scopes.push($(o[k]).attr("scope"));
if(k > 0){
scopeForUrl+=' ';
}
scopeForUrl+=$(o[k]).attr("scope");
}
window.enabledScopes=scopes;
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopeForUrl);
window.open(url);
});
}
popupMask.show();
popupDialog.show();
return;
}
function handleLogout() {
for(key in window.authorizations.authz){
window.authorizations.remove(key)
}
window.enabledScopes = null;
$('.api-ic.ic-on').addClass('ic-off');
$('.api-ic.ic-on').removeClass('ic-on');
// set the info box
$('.api-ic.ic-warning').addClass('ic-error');
$('.api-ic.ic-warning').removeClass('ic-warning');
}
function initOAuth(opts) {
var o = (opts||{});
var errors = [];
appName = (o.appName||errors.push("missing appName"));
popupMask = (o.popupMask||$('#api-common-mask'));
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
clientId = (o.clientId||errors.push("missing client id"));
realm = (o.realm||errors.push("missing realm"));
if(errors.length > 0){
log("auth unable initialize oauth: " + errors);
return;
}
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
$('.api-ic').click(function(s) {
if($(s.target).hasClass('ic-off'))
handleLogin();
else {
handleLogout();
}
false;
});
}
function onOAuthComplete(token) {
if(token) {
if(token.error) {
var checkbox = $('input[type=checkbox],.secured')
checkbox.each(function(pos){
checkbox[pos].checked = false;
});
alert(token.error);
}
else {
var b = token[window.swaggerUi.tokenName];
if(b){
// if all roles are satisfied
var o = null;
$.each($('.auth #api_information_panel'), function(k, v) {
var children = v;
if(children && children.childNodes) {
var requiredScopes = [];
$.each((children.childNodes), function (k1, v1){
var inner = v1.innerHTML;
if(inner)
requiredScopes.push(inner);
});
var diff = [];
for(var i=0; i < requiredScopes.length; i++) {
var s = requiredScopes[i];
if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
diff.push(s);
}
}
if(diff.length > 0){
o = v.parentNode;
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
// sorry, not all scopes are satisfied
$(o).find('.api-ic').addClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error');
}
else {
o = v.parentNode;
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
// all scopes are satisfied
$(o).find('.api-ic').addClass('ic-info');
$(o).find('.api-ic').removeClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error');
}
}
});
window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
}
}
}
}
+1505 -684
View File
File diff suppressed because it is too large Load Diff
+26
View File
@@ -0,0 +1,26 @@
{
"name": "swagger-ui",
"version": "2.0.18",
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
"scripts": {
"build": "PATH=$PATH:./node_modules/.bin cake dist",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/wordnik/swagger-ui.git"
},
"author": {
"name": "Tony Tam",
"email": "fehguy@gmail.com",
"url": "http://developer.wordnik.com"
},
"license": "Apache",
"readmeFilename": "README.md",
"dependencies": {
"coffee-script": "~1.5.0",
"swagger-client": "2.0.29",
"handlebars": "~1.0.10",
"less": "~1.4.2"
}
}
+28 -5
View File
@@ -34,16 +34,22 @@ class SwaggerUi extends Backbone.Router
# Event handler for when url/key is received from user
updateSwaggerUi: (data) ->
@options.discoveryUrl = data.discoveryUrl
@options.apiKey = data.apiKey
@options.url = data.url
@load()
# Create an api and render
load: ->
# Initialize the API object
@mainView?.clear()
@headerView.update(@options.discoveryUrl, @options.apiKey)
url = @options.url
if url.indexOf("http") isnt 0
url = @buildUrl(window.location.href.toString(), url)
@options.url = url
@headerView.update(url)
@api = new SwaggerApi(@options)
@api.build()
@api
# This is bound to success handler for SwaggerApi
# so it gets called when SwaggerApi completes loading
@@ -52,8 +58,8 @@ class SwaggerUi extends Backbone.Router
@mainView = new MainView({model: @api, el: $('#' + @dom_id)}).render()
@showMessage()
switch @options.docExpansion
when "full" then Docs.expandOperationsForResource('')
when "list" then Docs.collapseOperationsForResource('')
when "full" then Docs.expandOperationsForResource('')
when "list" then Docs.collapseOperationsForResource('')
@options.onComplete(@api, @) if @options.onComplete
setTimeout(
=>
@@ -61,6 +67,23 @@ class SwaggerUi extends Backbone.Router
400
)
buildUrl: (base, url) ->
log "base is " + base
if url.indexOf("/") is 0
parts = base.split("/")
base = parts[0] + "//" + parts[2]
base + url
else
endOfPath = base.length
if base.indexOf("?") > -1
endOfPath = Math.min(endOfPath, base.indexOf("?"))
if base.indexOf("#") > -1
endOfPath = Math.min(endOfPath, base.indexOf("#"))
base = base.substring(0, endOfPath);
if base.indexOf( "/", base.length - 1 ) isnt -1
return base + url
return base + "/" + url
# Shows message on topbar of the ui
showMessage: (data = '') ->
$('#message-bar').removeClass 'message-fail'
@@ -5,15 +5,10 @@ class ContentTypeView extends Backbone.View
template = @template()
$(@el).html(template(@model))
@isParam = @model.isParam
if @isParam
$('label[for=contentType]', $(@el)).text('Parameter content type:')
else
$('label[for=contentType]', $(@el)).text('Response Content Type')
$('label[for=contentType]', $(@el)).text('Response Content Type')
@
template: ->
Handlebars.templates.content_type
Handlebars.templates.content_type
+5 -6
View File
@@ -9,17 +9,16 @@ class HeaderView extends Backbone.View
initialize: ->
showPetStore: (e) ->
@trigger(
'update-swagger-ui'
{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json", apiKey:"special-key"}
{url:"http://petstore.swagger.wordnik.com/api/api-docs"}
)
showWordnikDev: (e) ->
@trigger(
'update-swagger-ui'
{discoveryUrl:"http://api.wordnik.com/v4/resources.json", apiKey:""}
{url:"http://api.wordnik.com/v4/resources.json"}
)
showCustomOnKeyup: (e) ->
@@ -29,10 +28,10 @@ class HeaderView extends Backbone.View
e?.preventDefault()
@trigger(
'update-swagger-ui'
{discoveryUrl: $('#input_baseUrl').val(), apiKey: $('#input_apiKey').val()}
{url: $('#input_baseUrl').val(), apiKey: $('#input_apiKey').val()}
)
update: (url, apiKey, trigger = false) ->
$('#input_baseUrl').val url
$('#input_apiKey').val apiKey
@trigger 'update-swagger-ui', {discoveryUrl:url, apiKey:apiKey} if trigger
#$('#input_apiKey').val apiKey
@trigger 'update-swagger-ui', {url:url} if trigger
+12 -2
View File
@@ -6,12 +6,22 @@ class MainView extends Backbone.View
$(@el).html(Handlebars.templates.main(@model))
# Render each resource
@addResource resource for resource in @model.resourcesArray
resources = {}
counter = 0
for resource in @model.apisArray
id = resource.name
while typeof resources[id] isnt 'undefined'
id = id + "_" + counter
counter += 1
resource.id = id
resources[id] = resource
@addResource resource
@
addResource: (resource) ->
# Render a resource and add it to resources li
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.name, className: 'resource'})
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.id, className: 'resource'})
$('#resources').append resourceView.render().el
clear: ->
+210 -77
View File
@@ -1,17 +1,60 @@
class OperationView extends Backbone.View
invocationUrl: null
events: {
'submit .sandbox' : 'submitOperation'
'click .submit' : 'submitOperation'
'click .response_hider' : 'hideResponse'
'click .toggleOperation' : 'toggleOperationContent'
'submit .sandbox' : 'submitOperation'
'click .submit' : 'submitOperation'
'click .response_hider' : 'hideResponse'
'click .toggleOperation' : 'toggleOperationContent'
'mouseenter .api-ic' : 'mouseEnter'
'mouseout .api-ic' : 'mouseExit'
}
initialize: ->
mouseEnter: (e) ->
elem = $(e.currentTarget.parentNode).find('#api_information_panel')
x = event.pageX
y = event.pageY
scX = $(window).scrollLeft()
scY = $(window).scrollTop()
scMaxX = scX + $(window).width()
scMaxY = scY + $(window).height()
wd = elem.width()
hgh = elem.height()
if (x + wd > scMaxX)
x = scMaxX - wd
if (x < scX)
x = scX
if (y + hgh > scMaxY)
y = scMaxY - hgh
if (y < scY)
y = scY
pos = {}
pos.top = y
pos.left = x
elem.css(pos)
$(e.currentTarget.parentNode).find('#api_information_panel').show()
mouseExit: (e) ->
$(e.currentTarget.parentNode).find('#api_information_panel').hide()
render: ->
isMethodSubmissionSupported = jQuery.inArray(@model.httpMethod, @model.supportedSubmitMethods()) >= 0
isMethodSubmissionSupported = true #jQuery.inArray(@model.method, @model.supportedSubmitMethods) >= 0
@model.isReadOnly = true unless isMethodSubmissionSupported
@model.oauth = null
if @model.authorizations
for k, v of @model.authorizations
if k == "oauth2"
if @model.oauth == null
@model.oauth = {}
if @model.oauth.scopes is undefined
@model.oauth.scopes = []
for o in v
@model.oauth.scopes.push o
$(@el).html(Handlebars.templates.operation(@model))
if @model.responseClassSignature and @model.responseClassSignature != 'string'
@@ -23,25 +66,35 @@ class OperationView extends Backbone.View
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
$('.model-signature', $(@el)).append responseSignatureView.render().el
else
$('.model-signature', $(@el)).html(@model.responseClass)
$('.model-signature', $(@el)).html(@model.type)
contentTypeModel =
isParam: false
supportedContentTypes: @model.supportedContentTypes
contentTypeView = new ContentTypeView({model: contentTypeModel})
$('.content-type', $(@el)).append contentTypeView.render().el
contentTypeModel.consumes = @model.consumes
contentTypeModel.produces = @model.produces
for param in @model.parameters
type = param.type || param.dataType
if type.toLowerCase() == 'file'
if !contentTypeModel.consumes
log "set content type "
contentTypeModel.consumes = 'multipart/form-data'
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
# Render each parameter
@addParameter param for param in @model.parameters
@addParameter param, contentTypeModel.consumes for param in @model.parameters
# Render each response code
@addStatusCode statusCode for statusCode in @model.errorResponses
@addStatusCode statusCode for statusCode in @model.responseMessages
@
addParameter: (param) ->
addParameter: (param, consumes) ->
# Render a parameter
param.consumes = consumes
paramView = new ParameterView({model: param, tagName: 'tr', readOnly: @model.isReadOnly})
$('.operation-params', $(@el)).append paramView.render().el
@@ -66,76 +119,132 @@ class OperationView extends Backbone.View
# if error free submit it
if error_free
map = {}
for o in form.serializeArray()
opts = {parent: @}
isFileUpload = false
for o in form.find("input")
if(o.value? && jQuery.trim(o.value).length > 0)
map[o.name] = o.value
if o.type is "file"
isFileUpload = true
isFileUpload = $('input[type~="file"]').size != 0
for o in form.find("textarea")
if(o.value? && jQuery.trim(o.value).length > 0)
map["body"] = o.value
for o in form.find("select")
val = this.getSelectedValue o
if(val? && jQuery.trim(val).length > 0)
map[o.name] = val
opts.responseContentType = $("div select[name=responseContentType]", $(@el)).val()
opts.requestContentType = $("div select[name=parameterContentType]", $(@el)).val()
$(".response_throbber", $(@el)).show()
if isFileUpload
# requires HTML5 compatible browser
bodyParam = new FormData()
@handleFileUpload map, form
else
@model.do(map, opts, @showCompleteStatus, @showErrorStatus, @)
# add params
for param in @model.parameters
if param.paramType is 'body'
success: (response, parent) ->
parent.showCompleteStatus response
handleFileUpload: (map, form) ->
for o in form.serializeArray()
if(o.value? && jQuery.trim(o.value).length > 0)
map[o.name] = o.value
# requires HTML5 compatible browser
bodyParam = new FormData()
params = 0
# add params
for param in @model.parameters
if param.paramType is 'form'
if map[param.name] != undefined
bodyParam.append(param.name, map[param.name])
# add files
$.each $('input[type~="file"]'), (i, el) ->
bodyParam.append($(el).attr('name'), el.files[0])
# headers in operation
headerParams = {}
for param in @model.parameters
if param.paramType is 'header'
headerParams[param.name] = map[param.name]
console.log(bodyParam)
log headerParams
# add files
for el in form.find('input[type~="file"]')
if typeof el.files[0] isnt 'undefined'
bodyParam.append($(el).attr('name'), el.files[0])
params += 1
log(bodyParam)
@invocationUrl =
if @model.supportHeaderParams()
headerParams = @model.getHeaderParams(map)
@model.urlify(map, false)
else
bodyParam = null
for param in @model.parameters
if param.paramType is 'body'
bodyParam = map[param.name]
@model.urlify(map, true)
log "bodyParam = " + bodyParam
$(".request_url", $(@el)).html "<pre>" + @invocationUrl + "</pre>"
headerParams = null
invocationUrl =
if @model.supportHeaderParams()
headerParams = @model.getHeaderParams(map)
@model.urlify(map, false)
else
@model.urlify(map, true)
obj =
type: @model.method
url: @invocationUrl
headers: headerParams
data: bodyParam
dataType: 'json'
contentType: false
processData: false
error: (data, textStatus, error) =>
@showErrorStatus(@wrap(data), @)
success: (data) =>
@showResponse(data, @)
complete: (data) =>
@showCompleteStatus(@wrap(data), @)
log 'submitting ' + invocationUrl
# apply authorizations
if window.authorizations
window.authorizations.apply obj
if params is 0
obj.data.append("fake", "true");
$(".request_url", $(@el)).html "<pre>" + invocationUrl + "</pre>"
$(".response_throbber", $(@el)).show()
jQuery.ajax(obj)
false
# end of file-upload nastiness
obj =
type: @model.httpMethod
url: invocationUrl
headers: headerParams
data: bodyParam
dataType: 'json'
processData: false
error: (xhr, textStatus, error) =>
@showErrorStatus(xhr, textStatus, error)
success: (data) =>
@showResponse(data)
complete: (data) =>
@showCompleteStatus(data)
# wraps a jquery response as a shred response
obj.contentType = "application/json" if (obj.type.toLowerCase() == "post" or obj.type.toLowerCase() == "put" or obj.type.toLowerCase() == "patch")
obj.contentType = false if isFileUpload
paramContentTypeField = $("td select[name=contentType]", $(@el)).val()
if paramContentTypeField
obj.contentType = paramContentTypeField
wrap: (data) ->
headers = {}
headerArray = data.getAllResponseHeaders().split("\r")
for i in headerArray
h = i.split(':')
if (h[0] != undefined && h[1] != undefined)
headers[h[0].trim()] = h[1].trim()
responseContentTypeField = $('.content > .content-type > div > select[name=contentType]', $(@el)).val()
if responseContentTypeField
obj.headers = if obj.headers? then obj.headers else {}
obj.headers.accept = responseContentTypeField
jQuery.ajax(obj)
false
# $.getJSON(invocationUrl, (r) => @showResponse(r)).complete((r) => @showCompleteStatus(r)).error (r) => @showErrorStatus(r)
o = {}
o.content = {}
o.content.data = data.responseText
o.headers = headers
o.request = {}
o.request.url = @invocationUrl
o.status = data.status
o
getSelectedValue: (select) ->
if !select.multiple
select.value
else
options = []
options.push opt.value for opt in select.options when opt.selected
if options.length > 0
options.join ","
else
null
# handler for hide response link
hideResponse: (e) ->
@@ -149,14 +258,13 @@ class OperationView extends Backbone.View
prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>")
$(".response_body", $(@el)).html escape(prettyJson)
# Show error from server
showErrorStatus: (data) ->
@showStatus data
showErrorStatus: (data, parent) ->
parent.showStatus data
# show the status codes
showCompleteStatus: (data) ->
@showStatus data
showCompleteStatus: (data, parent) ->
parent.showStatus data
# Adapted from http://stackoverflow.com/a/2893259/454004
formatXml: (xml) ->
@@ -218,22 +326,47 @@ class OperationView extends Backbone.View
# puts the response data in UI
showStatus: (data) ->
try
code = $('<code />').text(JSON.stringify(JSON.parse(data.responseText), null, 2))
showStatus: (response) ->
if response.content is undefined
content = response.data
url = response.url
else
content = response.content.data
url = response.request.url
headers = response.headers
# if server is nice, and sends content-type back, we can use it
contentType = if headers && headers["Content-Type"] then headers["Content-Type"].split(";")[0].trim() else null
if !content
code = $('<code />').text("no content")
pre = $('<pre class="json" />').append(code)
catch error
code = $('<code />').text(@formatXml(data.responseText))
else if contentType is "application/json" || /\+json$/.test(contentType)
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " "))
pre = $('<pre class="json" />').append(code)
else if contentType is "application/xml" || /\+xml$/.test(contentType)
code = $('<code />').text(@formatXml(content))
pre = $('<pre class="xml" />').append(code)
else if contentType is "text/html"
code = $('<code />').html(content)
pre = $('<pre class="xml" />').append(code)
else if /^image\//.test(contentType)
pre = $('<img>').attr('src',url)
else
# don't know what to render!
code = $('<code />').text(content)
pre = $('<pre class="json" />').append(code)
response_body = pre
$(".response_code", $(@el)).html "<pre>" + data.status + "</pre>"
$(".request_url", $(@el)).html "<pre>" + url + "</pre>"
$(".response_code", $(@el)).html "<pre>" + response.status + "</pre>"
$(".response_body", $(@el)).html response_body
$(".response_headers", $(@el)).html "<pre>" + data.getAllResponseHeaders() + "</pre>"
$(".response_headers", $(@el)).html "<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>"
$(".response", $(@el)).slideDown()
$(".response_hider", $(@el)).show()
$(".response_throbber", $(@el)).hide()
hljs.highlightBlock($('.response_body', $(@el))[0])
toggleOperationContent: ->
elem = $('#' + @model.resourceName + "_" + @model.nickname + "_" + @model.httpMethod + "_" + @model.number + "_content")
elem = $('#' + Docs.escapeResourceName(@model.parentId) + "_" + @model.nickname + "_content")
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)
@@ -0,0 +1,14 @@
class ParameterContentTypeView extends Backbone.View
initialize: ->
render: ->
template = @template()
$(@el).html(template(@model))
$('label[for=parameterContentType]', $(@el)).text('Parameter content type:')
@
template: ->
Handlebars.templates.parameter_content_type
@@ -1,9 +1,16 @@
class ParameterView extends Backbone.View
initialize: ->
Handlebars.registerHelper 'isArray',
(param, opts) ->
if param.type.toLowerCase() == 'array' || param.allowMultiple
opts.fn(@)
else
opts.inverse(@)
render: ->
type = @model.type || @model.dataType
@model.isBody = true if @model.paramType == 'body'
@model.isFile = true if @model.dataType == 'file'
@model.isFile = true if type.toLowerCase() == 'file'
template = @template()
$(@el).html(template(@model))
@@ -19,12 +26,23 @@ class ParameterView extends Backbone.View
else
$('.model-signature', $(@el)).html(@model.signature)
contentTypeModel =
isParam: true
supportedContentTypes: @model.supportedContentTypes
isParam = false
contentTypeView = new ContentTypeView({model: contentTypeModel})
$('.content-type', $(@el)).append contentTypeView.render().el
if @model.isBody
isParam = true
contentTypeModel =
isParam: isParam
contentTypeModel.consumes = @model.consumes
if isParam
parameterContentTypeView = new ParameterContentTypeView({model: contentTypeModel})
$('.parameter-content-type', $(@el)).append parameterContentTypeView.render().el
else
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
@
+14 -2
View File
@@ -4,10 +4,22 @@ class ResourceView extends Backbone.View
render: ->
$(@el).html(Handlebars.templates.resource(@model))
@number = 0
methods = {}
# Render each operation
@addOperation operation for operation in @model.operationsArray
for operation in @model.operationsArray
counter = 0
id = operation.nickname
while typeof methods[id] isnt 'undefined'
id = id + "_" + counter
counter += 1
methods[id] = operation
operation.nickname = id
operation.parentId = @model.id
@addOperation operation
@
addOperation: (operation) ->
@@ -0,0 +1,14 @@
class ResponseContentTypeView extends Backbone.View
initialize: ->
render: ->
template = @template()
$(@el).html(template(@model))
$('label[for=responseContentType]', $(@el)).text('Response Content Type')
@
template: ->
Handlebars.templates.response_content_type
@@ -11,7 +11,7 @@ class SignatureView extends Backbone.View
template = @template()
$(@el).html(template(@model))
@switchToDescription()
@switchToSnippet()
@isParam = @model.isParam
@@ -4,6 +4,17 @@ class StatusCodeView extends Backbone.View
render: ->
template = @template()
$(@el).html(template(@model))
if swaggerUi.api.models.hasOwnProperty @model.responseModel
responseModel =
sampleJSON: JSON.stringify(swaggerUi.api.models[@model.responseModel].createJSONSample(), null, 2)
isParam: false
signature: swaggerUi.api.models[@model.responseModel].getMockSignature()
responseModelView = new SignatureView({model: responseModel, tagName: 'div'})
$('.model-signature', @$el).append responseModelView.render().el
else
$('.model-signature', @$el).html ''
@
template: ->
+125
View File
@@ -0,0 +1,125 @@
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
+1213 -1582
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

+73 -92
View File
@@ -1,106 +1,87 @@
<!DOCTYPE html>
<html>
<head>
<title>Swagger UI</title>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
<link href='css/hightlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
<script src='lib/handlebars-1.0.rc.1.js' type='text/javascript'></script>
<script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='lib/swagger.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<title>Swagger UI</title>
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/>
<script type="text/javascript" src="lib/shred.bundle.js"></script>
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
<script src='lib/handlebars-1.0.0.js' type='text/javascript'></script>
<script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='lib/swagger.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<style type="text/css">
.swagger-ui-wrap {
max-width: 960px;
margin-left: auto;
margin-right: auto;
<!-- enabling this will enable oauth2 implicit scope support -->
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
url: "http://petstore.swagger.wordnik.com/api/api-docs",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
.icon-btn {
cursor: pointer;
}
#message-bar {
min-height: 30px;
text-align: center;
padding-top: 10px;
}
.message-success {
color: #89BF04;
}
.message-fail {
color: #cc0000;
}
</style>
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",
apiKey:"special-key",
dom_id:"swagger-ui-container",
supportHeaderParams: false,
supportedSubmitMethods: ['get', 'post', 'put'],
onComplete: function(swaggerApi, swaggerUi){
if(console) {
console.log("Loaded SwaggerUI")
console.log(swaggerApi);
console.log(swaggerUi);
}
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
},
onFailure: function(data) {
if(console) {
console.log("Unable to Load SwaggerUI");
console.log(data);
}
},
docExpansion: "none"
});
window.swaggerUi.load();
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none"
});
</script>
$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
log("added key " + key);
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
}
})
window.swaggerUi.load();
});
</script>
</head>
<body>
<body class="swagger-section">
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="http://swagger.wordnik.com">swagger</a>
<form id='api_selector'>
<div class='input icon-btn'>
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
</div>
<div class='input icon-btn'>
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
</div>
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl"
type="text"/></div>
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
<div class='input'><a id="explore" href="#">Explore</a></div>
</form>
</div>
</div>
<div id="message-bar" class="swagger-ui-wrap">
&nbsp;
</div>
<div id="swagger-ui-container" class="swagger-ui-wrap">
<div class="swagger-ui-wrap">
<a id="logo" href="http://swagger.wordnik.com">swagger</a>
<form id='api_selector'>
<div class='input icon-btn'>
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
</div>
<div class='input icon-btn'>
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
</div>
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
<div class='input'><a id="explore" href="#">Explore</a></div>
</form>
</div>
</div>
<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>
+15
View File
@@ -0,0 +1,15 @@
<script>
var qp = null;
if(window.location.hash) {
qp = location.hash.substring(1);
}
else {
qp = location.search.substring(1);
}
qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
function(key, value) {
return key===""?value:decodeURIComponent(value) }
):{}
window.opener.onOAuthComplete(qp);
window.close();
</script>
+17 -13
View File
@@ -62,9 +62,14 @@ function clippyCopiedCallback(a) {
}
// Logging function that accounts for browsers that don't have window.console
function log() {
if (window.console) console.log.apply(console,arguments);
}
log = function(){
log.history = log.history || [];
log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};
// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
if (Function.prototype.bind && console && typeof console.log == "object") {
[
@@ -86,7 +91,7 @@ var Docs = {
switch (fragments.length) {
case 1:
// Expand all operations for the resource and scroll to it
// log('shebang resource:' + fragments[0]);
log('shebang resource:' + fragments[0]);
var dom_id = 'resource_' + fragments[0];
Docs.expandEndpointListForResource(fragments[0]);
@@ -94,18 +99,18 @@ var Docs = {
break;
case 2:
// Refer to the endpoint DOM element, e.g. #words_get_search
// log('shebang endpoint: ' + fragments.join('_'));
log('shebang endpoint: ' + fragments.join('_'));
// Expand Resource
Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false});
// Expand Resource
Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false});
// Expand operation
// Expand operation
var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content";
// log("li_dom_id " + li_dom_id);
// log("li_content_dom_id " + li_content_dom_id);
log("li_dom_id " + li_dom_id);
log("li_content_dom_id " + li_content_dom_id);
Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false});
@@ -180,5 +185,4 @@ var Docs = {
collapseOperation: function(elem) {
elem.slideUp();
}
};
};
+83
View File
@@ -0,0 +1,83 @@
.swagger-section {
.title {
font-style: bold;
}
.secondary_form {
display: none;
}
.main_image {
display: block;
margin-left: auto;
margin-right: auto;
}
.oauth_body {
margin-left: 100px;
margin-right: 100px;
}
.oauth_submit {
text-align: center;
}
.api-popup-dialog {
z-index: 10000;
position: absolute;
width: 500px;
background: #FFF;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
display: none;
font-size: 13px;
color: #777;
.api-popup-title{
font-size: 24px;
padding: 10px 0;
}
.api-popup-title{
font-size: 24px;
padding: 10px 0;
}
p.error-msg {
padding-left: 5px;
padding-bottom: 5px;
}
button.api-popup-authbtn {
height: 30px;
}
button.api-popup-cancel {
height: 30px;
}
}
.api-popup-scopes {
padding: 10px 20px;
li {
padding: 5px 0;
line-height: 20px;
}
.api-scope-desc {
padding-left: 20px;
font-style: italic;
}
li input {
position: relative;
top: 2px;
}
}
.api-popup-actions {
padding-top: 10px;
}
}
@@ -1,8 +1,6 @@
/*
/* Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org> */
Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
*/
.swagger-section {
pre code {
display: block; padding: 0.5em;
@@ -133,3 +131,5 @@ pre .xml .css,
pre .xml .cdata {
opacity: 0.5;
}
}
+51
View File
@@ -0,0 +1,51 @@
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
+139
View File
@@ -0,0 +1,139 @@
@import 'src/main/less/highlight_default.less';
@import 'src/main/less/specs.less';
@import 'src/main/less/auth.less';
.swagger-section {
.access {
float: right;
}
.auth {
float: right;
}
#api_information_panel {
position: absolute;
background: #FFF;
border: 1px solid #ccc;
border-radius: 5px;
display: none;
font-size: 13px;
max-width: 300px;
line-height: 30px;
color: black;
padding: 5px;
p {
.api-msg-enabled {
color: green;
}
.api-msg-disabled {
color: red;
}
}
}
.api-ic {
height: 18px;
vertical-align: middle;
display: inline-block;
background: url(../images/explorer_icons.png) no-repeat;
}
.ic-info {
background-position: 0 0;
width: 18px;
margin-top: -7px;
margin-left: 4px;
}
.ic-warning {
background-position: -60px 0;
width: 18px;
margin-top: -7px;
margin-left: 4px;
}
.ic-error {
background-position: -30px 0;
width: 18px;
margin-top: -7px;
margin-left: 4px;
}
.ic-off {
background-position: -90px 0;
width: 58px;
margin-top: -4px;
cursor: pointer;
}
.ic-on {
background-position: -160px 0;
width: 58px;
margin-top: -4px;
cursor: pointer;
}
#header {
background-color: #89bf04;
padding: 14px;
a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white;
}
form#api_selector {
display: block;
clear: none;
float: right;
.input {
display: block;
clear: none;
float: left;
margin: 0 10px 0 0;
input#input_apiKey {
width: 200px;
}
input#input_baseUrl {
width: 400px;
}
a#explore {
display: block;
text-decoration: none;
font-weight: bold;
padding: 6px 8px;
font-size: 0.9em;
color: white;
background-color: #547f00;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
}
a#explore:hover {
background-color: #547f00;
}
input {
font-size: 0.9em;
padding: 3px;
margin: 0;
}
}
}
}
#content_message {
margin: 10px 15px;
font-style: italic;
color: #999999;
}
#message-bar {
min-height: 30px;
text-align: center;
padding-top: 10px;
}
}
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1,10 +1,10 @@
<label for="contentType"></label>
<select name="contentType">
{{#if supportedContentTypes}}
{{#each supportedContentTypes}}
{{#if produces}}
{{#each produces}}
<option value="{{{this}}}">{{{this}}}</option>
{{/each}}
{{else}}
<option value="application/json">application/json</option>
<option value="application/json">application/json</option>
{{/if}}
</select>
+9 -1
View File
@@ -1,4 +1,12 @@
<div class='info' id='api_info'>
{{#if info}}
<div class="info_title">{{info.title}}</div>
<div class="info_description">{{{info.description}}}</div>
{{#if info.termsOfServiceUrl}}<div class="info_tos"><a href="{{info.termsOfServiceUrl}}">Terms of service</a></div>{{/if}}
{{#if info.contact}}<div class='info_contact'><a href="mailto:{{info.contact}}">Contact the developer</a></div>{{/if}}
{{#if info.license}}<div class='info_license'><a href='{{info.licenseUrl}}'>{{info.license}}</a></div>{{/if}}
{{/if}}
</div>
<div class='container' id='resources_container'>
<ul id='resources'>
</ul>
+100 -80
View File
@@ -1,82 +1,102 @@
<ul class='operations' >
<li class='{{httpMethod}} operation' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_{{number}}'>
<div class='heading'>
<h3>
<span class='http_method'>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{httpMethod}}</a>
</span>
<span class='path'>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{path}}</a>
</span>
</h3>
<ul class='options'>
<li>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{{summary}}}</a>
</li>
</ul>
</div>
<div class='content' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_{{number}}_content' style='display:none'>
{{#if notes}}
<h4>Implementation Notes</h4>
<p>{{{notes}}}</p>
{{/if}}
{{#if responseClass}}
<h4>Response Class</h4>
<p><span class="model-signature" /></p>
<br/>
<div class="content-type" />
{{/if}}
<form accept-charset='UTF-8' class='sandbox'>
<div style='margin:0;padding:0;display:inline'></div>
<h4>Parameters</h4>
<table class='fullwidth'>
<thead>
<tr>
<th style="width: 100px; max-width: 100px" >Parameter</th>
<th style="width: 310px; max-width: 310px">Value</th>
<th style="width: 200px; max-width: 200px">Description</th>
<th style="width: 320px; max-width: 330px">Data Type</th>
</tr>
</thead>
<tbody class="operation-params">
<ul class='operations' >
<li class='{{method}} operation' id='{{parentId}}_{{nickname}}'>
<div class='heading'>
<h3>
<span class='http_method'>
<a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{method}}</a>
</span>
<span class='path'>
<a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{path}}</a>
</span>
</h3>
<ul class='options'>
<li>
<a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{{summary}}}</a>
</li>
</ul>
</div>
<div class='content' id='{{parentId}}_{{nickname}}_content' style='display:none'>
{{#if notes}}
<h4>Implementation Notes</h4>
<p>{{{notes}}}</p>
{{/if}}
{{#oauth}}
<div class="auth">
<span class="api-ic ic-error"></span>{{/oauth}}
{{#each oauth}}
<div id="api_information_panel" style="top: 526px; left: 776px; display: none;">
{{#each this}}
<div title='{{{this.description}}}'>{{this.scope}}</div>
{{/each}}
</div>
{{/each}}
{{#oauth}}</div>{{/oauth}}
{{#oauth}}
<div class='access'>
<span class="api-ic ic-off" title="click to authenticate"></span>
</div>
{{/oauth}}
{{#if type}}
<h4>Response Class</h4>
<p><span class="model-signature" /></p>
<br/>
<div class="response-content-type" />
{{/if}}
<form accept-charset='UTF-8' class='sandbox'>
<div style='margin:0;padding:0;display:inline'></div>
{{#if parameters}}
<h4>Parameters</h4>
<table class='fullwidth'>
<thead>
<tr>
<th style="width: 100px; max-width: 100px">Parameter</th>
<th style="width: 310px; max-width: 310px">Value</th>
<th style="width: 200px; max-width: 200px">Description</th>
<th style="width: 100px; max-width: 100px">Parameter Type</th>
<th style="width: 220px; max-width: 230px">Data Type</th>
</tr>
</thead>
<tbody class="operation-params">
</tbody>
</table>
{{#if errorResponses}}
<div style='margin:0;padding:0;display:inline'></div>
<h4>Status Codes</h4>
<table class='fullwidth'>
<thead>
<tr>
<th>HTTP Status Code</th>
<th>Reason</th>
</tr>
</thead>
<tbody class="operation-status">
</tbody>
</table>
{{/if}}
{{#if isReadOnly}}
{{else}}
<div class='sandbox_header'>
<input class='submit' name='commit' type='button' value='Try it out!' />
<a href='#' class='response_hider' style='display:none'>Hide Response</a>
<img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />
</div>
{{/if}}
</form>
<div class='response' style='display:none'>
<h4>Request URL</h4>
<div class='block request_url'></div>
<h4>Response Body</h4>
<div class='block response_body'></div>
<h4>Response Code</h4>
<div class='block response_code'></div>
<h4>Response Headers</h4>
<div class='block response_headers'></div>
</div>
</div>
</li>
</ul>
</tbody>
</table>
{{/if}}
{{#if responseMessages}}
<div style='margin:0;padding:0;display:inline'></div>
<h4>Response Messages</h4>
<table class='fullwidth'>
<thead>
<tr>
<th>HTTP Status Code</th>
<th>Reason</th>
<th>Response Model</th>
</tr>
</thead>
<tbody class="operation-status">
</tbody>
</table>
{{/if}}
{{#if isReadOnly}}
{{else}}
<div class='sandbox_header'>
<input class='submit' name='commit' type='button' value='Try it out!' />
<a href='#' class='response_hider' style='display:none'>Hide Response</a>
<img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />
</div>
{{/if}}
</form>
<div class='response' style='display:none'>
<h4>Request URL</h4>
<div class='block request_url'></div>
<h4>Response Body</h4>
<div class='block response_body'></div>
<h4>Response Code</h4>
<div class='block response_code'></div>
<h4>Response Headers</h4>
<div class='block response_headers'></div>
</div>
</div>
</li>
</ul>
+5 -4
View File
@@ -4,26 +4,27 @@
{{#if isBody}}
{{#if isFile}}
<input type="file" name='{{name}}'/>
<div class="parameter-content-type" />
{{else}}
{{#if defaultValue}}
<textarea class='body-textarea' name='{{name}}'>{{defaultValue}}</textarea>
{{else}}
<textarea class='body-textarea' name='{{name}}'></textarea>
<br />
<div class="content-type" />
<div class="parameter-content-type" />
{{/if}}
{{/if}}
{{else}}
{{#if defaultValue}}
<input minlength='0' name='{{name}}' placeholder='' type='text' value='{{defaultValue}}'/>
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value='{{defaultValue}}'/>
{{else}}
<input minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
{{/if}}
{{/if}}
</td>
<td>{{{description}}}</td>
<td>{{{paramType}}}</td>
<td>
<span class="model-signature"></span>
</td>
+20 -16
View File
@@ -1,21 +1,25 @@
<td class='code'>{{name}}</td>
<td>
<select name='{{name}}'>
{{#if required}}
<select {{#isArray this}} multiple='multiple'{{/isArray}} class='parameter' name='{{name}}'>
{{#if required}}
{{else}}
{{#if defaultValue}}
{{else}}
{{#isArray this}}
{{else}}
{{#if defaultValue}}
{{else}}
<option selected="" value=''></option>
{{/if}}
{{/if}}
{{#each allowableValues.descriptiveValues}}
{{#if isDefault}}
<option value='{{value}}'>{{value}} (default)</option>
{{else}}
<option value='{{value}}'>{{value}}</option>
{{/if}}
{{/each}}
</select>
<option selected="" value=''></option>
{{/isArray}}
{{/if}}
{{/if}}
{{#each allowableValues.descriptiveValues}}
{{#if isDefault}}
<option selected="" value='{{value}}'>{{value}} (default)</option>
{{else}}
<option value='{{value}}'>{{value}}</option>
{{/if}}
{{/each}}
</select>
</td>
<td>{{{description}}}</td>
<td><span class="model-signature"></span></td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
+6 -1
View File
@@ -3,8 +3,13 @@
{{#if isBody}}
<textarea class='body-textarea' readonly='readonly' name='{{name}}'>{{defaultValue}}</textarea>
{{else}}
{{defaultValue}}
{{#if defaultValue}}
{{defaultValue}}
{{else}}
(empty)
{{/if}}
{{/if}}
</td>
<td>{{{description}}}</td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
@@ -3,8 +3,13 @@
{{#if isBody}}
<textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='{{name}}'>{{defaultValue}}</textarea>
{{else}}
{{defaultValue}}
{{#if defaultValue}}
{{defaultValue}}
{{else}}
(empty)
{{/if}}
{{/if}}
</td>
<td>{{{description}}}</td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
+5 -4
View File
@@ -9,17 +9,17 @@
{{else}}
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'></textarea>
<br />
<div class="content-type" />
<div class="parameter-content-type" />
{{/if}}
{{/if}}
{{else}}
{{#if isFile}}
<input class='required' type='file' name='{{name}}'/>
<input class='parameter' class='required' type='file' name='{{name}}'/>
{{else}}
{{#if defaultValue}}
<input class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{defaultValue}}'/>
<input class='parameter required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{defaultValue}}'/>
{{else}}
<input class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/>
<input class='parameter required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/>
{{/if}}
{{/if}}
{{/if}}
@@ -27,4 +27,5 @@
<td>
<strong>{{{description}}}</strong>
</td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
@@ -0,0 +1,10 @@
<label for="parameterContentType"></label>
<select name="parameterContentType">
{{#if consumes}}
{{#each consumes}}
<option value="{{{this}}}">{{{this}}}</option>
{{/each}}
{{else}}
<option value="application/json">application/json</option>
{{/if}}
</select>
+23 -23
View File
@@ -1,27 +1,27 @@
<div class='heading'>
<h2>
<a href='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">/{{name}}</a>
</h2>
<ul class='options'>
<li>
<a href='#!/{{name}}' id='endpointListTogger_{{name}}'
onclick="Docs.toggleEndpointListForResource('{{name}}');">Show/Hide</a>
</li>
<li>
<a href='#' onclick="Docs.collapseOperationsForResource('{{name}}'); return false;">
List Operations
</a>
</li>
<li>
<a href='#' onclick="Docs.expandOperationsForResource('{{name}}'); return false;">
Expand Operations
</a>
</li>
<li>
<a href='{{url}}'>Raw</a>
</li>
</ul>
<h2>
<a href='#!/{{id}}' onclick="Docs.toggleEndpointListForResource('{{id}}');">{{name}}</a> {{#description}} : {{/description}}{{{description}}}
</h2>
<ul class='options'>
<li>
<a href='#!/{{id}}' id='endpointListTogger_{{id}}'
onclick="Docs.toggleEndpointListForResource('{{id}}');">Show/Hide</a>
</li>
<li>
<a href='#' onclick="Docs.collapseOperationsForResource('{{id}}'); return false;">
List Operations
</a>
</li>
<li>
<a href='#' onclick="Docs.expandOperationsForResource('{{id}}'); return false;">
Expand Operations
</a>
</li>
<li>
<a href='{{url}}'>Raw</a>
</li>
</ul>
</div>
<ul class='endpoints' id='{{name}}_endpoint_list' style='display:none'>
<ul class='endpoints' id='{{id}}_endpoint_list' style='display:none'>
</ul>
@@ -0,0 +1,10 @@
<label for="responseContentType"></label>
<select name="responseContentType">
{{#if produces}}
{{#each produces}}
<option value="{{{this}}}">{{{this}}}</option>
{{/each}}
{{else}}
<option value="application/json">application/json</option>
{{/if}}
</select>
+2 -2
View File
@@ -1,3 +1,3 @@
<td width='15%' class='code'>{{code}}</td>
<td>{{{reason}}}</td>
<td>{{{message}}}</td>
<td width='50%'><span class="model-signature" /></td>
+2 -3
View File
@@ -1,5 +1,4 @@
window.api_key = 'a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5'
window.discoveryUrl = "http://api.wordnik.com/v4/resources.json"
window.url = "http://api.wordnik.com/v4/resources.json"
describe 'SwaggerUi', ->
@@ -8,7 +7,7 @@ describe 'SwaggerUi', ->
beforeEach ->
window.ui = new SwaggerUi
api_key: window.api_key
discoveryUrl: window.discoveryUrl
url: window.url
waitsFor ->
ui.ready