Compare commits

..
169 Commits
Author SHA1 Message Date
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
Ayush Gupta 2212f73492 closes #107 2012-12-04 22:11:55 +05:30
Ayush Gupta eb4198ccd0 using the latest swagger.js 2012-12-03 22:58:01 +05:30
Ayush Gupta 5e714918aa closes #98 2012-12-03 22:57:02 +05:30
Tony Tam 24dc86fb4c Merge pull request #104 from pose/master
Fixing template that was broken during merge
2012-12-03 06:47:55 -08:00
Alberto Pose 3edb6437fb Fixing merge problem 2012-11-29 15:36:52 -03:00
Tony Tam 356ae491aa fixed duplicate model, updated example name 2012-11-27 16:03:54 -08:00
Tony Tam 7bc8109e88 re-merged #96 2012-11-27 15:04:12 -08:00
Tony Tam 3fd37c3ef6 Merge pull request #102 from sequielo/patch-1
Update src/main/javascript/doc.js
2012-11-27 13:48:06 -08:00
Tony Tam 586c6d6292 Merge pull request #103 from pose/xml-pretty-print
Adding XML pretty printing to responses
2012-11-27 13:47:51 -08:00
Alberto Pose 12bdd38406 Adding fallback to XML when JSON response parsing fails. 2012-11-27 18:24:32 -03:00
sequielo 369b639329 Update src/main/javascript/doc.js
fixed #101: expand operations for resource when resource paramenter is an empty string.
2012-11-27 00:14:47 -02:00
Tony Tam 3f9ed33f7f added missing files per #100 2012-11-26 13:47:34 -08:00
Tony Tam d1bffc8fb4 manual merge of #97 2012-11-25 21:52:30 -08:00
Tony Tam 55f0c1a2f8 Merge pull request #95 from pose/json-response-pretty-print
Adding JSON sample UI to response
2012-11-25 21:10:52 -08:00
Tony Tam 03e21019d2 Merge pull request #94 from pose/titles-fix
Small change to signature titles
2012-11-25 21:10:16 -08:00
Tony Tam 75fd46ef21 Merge pull request #96 from pose/operation-nonce
Adding operation number to create a unique href for the <a/> tag.
2012-11-25 21:09:40 -08:00
Alberto Pose 75ff471425 Adding operation number to create a unique href for the <a/> tag. 2012-11-22 17:45:40 -03:00
Alberto Pose dd1b2219b8 Adding JSON sample UI to response 2012-11-21 13:20:09 -03:00
Alberto Pose f5cfee8296 Small improvements to some titles 2012-11-21 11:50:05 -03:00
Ayush Gupta a1337cf118 coffeescript compiled swagger.js for #91 2012-11-20 14:36:16 +05:30
Ayush Gupta 2bc67cbcae Merge pull request #91 from predicador37/master
Fixes Issue  #68 in a generic way for any param with any regex
2012-11-20 01:04:08 -08:00
predicador37 30886478d4 fixes https://github.com/wordnik/swagger-core/issues/68 in a generic way. Should work with all params. 2012-11-20 09:28:03 +01:00
Ayush Gupta fc320397e9 fix from https://github.com/wordnik/swagger-core/issues/68 2012-11-20 12:04:10 +05:30
Tony Tam 9b58ed5430 redo of PR #88, #89, #90 2012-11-19 19:51:28 -08:00
Tony Tam 2d62bddfb8 updated to 1.1.4 2012-11-19 19:30:42 -08:00
Ayush Gupta cfa2006042 closes #83 2012-11-16 12:11:47 +05:30
Ayush Gupta 3dca74c08f closes #84 2012-11-16 12:01:30 +05:30
Alberto Pose fd6379140d Adding syntax highlight to JSON snippets and responses. 2012-11-15 18:13:33 -03:00
Alberto Pose ab572e87be Removing console.log 2012-11-15 12:25:28 -03:00
Alberto Pose 9687a8084f Adding 'snippet' tab to parameter datatype signature UI
This new section displays how a complex datatype should look like providing some sample code for the developer using Swagger.
2012-11-14 17:33:51 -03:00
62 changed files with 19490 additions and 4044 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
+21 -2
View File
@@ -1,6 +1,7 @@
fs = require 'fs'
path = require 'path'
{exec} = require 'child_process'
less = require 'less'
sourceFiles = [
'SwaggerUi'
@@ -10,6 +11,10 @@ sourceFiles = [
'view/OperationView'
'view/StatusCodeView'
'view/ParameterView'
'view/SignatureView'
'view/ContentTypeView'
'view/ResponseContentTypeView'
'view/ParameterContentTypeView'
]
@@ -67,12 +72,25 @@ task 'dist', 'Build a distribution', ->
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
pack()
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) ->
console.log err
fs.writeFileSync("src/main/html/css/screen.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", ->
@@ -102,6 +120,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) ->
@@ -110,4 +129,4 @@ notify = (message) ->
# options =
# title: 'CoffeeScript'
# image: 'bin/CoffeeScript.png'
# try require('growl') message, options
# try require('growl') message, options
+36 -36
View File
@@ -1,31 +1,28 @@
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 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 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.
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 +35,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,28 +58,32 @@ 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'
apiKeyName: "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).
How to Improve It
-----------------
@@ -94,10 +92,12 @@ Create your own fork of [wordnik/swagger-ui](https://github.com/wordnik/swagger-
To share your changes, [submit a pull request](https://github.com/wordnik/swagger-ui/pull/new/master).
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.
License
-------
Copyright 2011-2012 Wordnik, Inc.
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.
+135
View File
@@ -0,0 +1,135 @@
/*
Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
*/
pre code {
display: block; padding: 0.5em;
background: #F0F0F0;
}
pre code,
pre .subst,
pre .tag .title,
pre .lisp .title,
pre .clojure .built_in,
pre .nginx .title {
color: black;
}
pre .string,
pre .title,
pre .constant,
pre .parent,
pre .tag .value,
pre .rules .value,
pre .rules .value .number,
pre .preprocessor,
pre .ruby .symbol,
pre .ruby .symbol .string,
pre .aggregate,
pre .template_tag,
pre .django .variable,
pre .smalltalk .class,
pre .addition,
pre .flow,
pre .stream,
pre .bash .variable,
pre .apache .tag,
pre .apache .cbracket,
pre .tex .command,
pre .tex .special,
pre .erlang_repl .function_or_atom,
pre .markdown .header {
color: #800;
}
pre .comment,
pre .annotation,
pre .template_comment,
pre .diff .header,
pre .chunk,
pre .markdown .blockquote {
color: #888;
}
pre .number,
pre .date,
pre .regexp,
pre .literal,
pre .smalltalk .symbol,
pre .smalltalk .char,
pre .go .constant,
pre .change,
pre .markdown .bullet,
pre .markdown .link_url {
color: #080;
}
pre .label,
pre .javadoc,
pre .ruby .string,
pre .decorator,
pre .filter .argument,
pre .localvars,
pre .array,
pre .attr_selector,
pre .important,
pre .pseudo,
pre .pi,
pre .doctype,
pre .deletion,
pre .envvar,
pre .shebang,
pre .apache .sqbracket,
pre .nginx .built_in,
pre .tex .formula,
pre .erlang_repl .reserved,
pre .prompt,
pre .markdown .link_label,
pre .vhdl .attribute,
pre .clojure .attribute,
pre .coffeescript .property {
color: #88F
}
pre .keyword,
pre .id,
pre .phpdoc,
pre .title,
pre .built_in,
pre .aggregate,
pre .css .tag,
pre .javadoctag,
pre .phpdoc,
pre .yardoctag,
pre .smalltalk .class,
pre .winutils,
pre .bash .variable,
pre .apache .tag,
pre .go .typename,
pre .tex .command,
pre .markdown .strong,
pre .request,
pre .status {
font-weight: bold;
}
pre .markdown .emphasis {
font-style: italic;
}
pre .nginx .built_in {
font-weight: normal;
}
pre .coffeescript .javascript,
pre .javascript .xml,
pre .tex .formula,
pre .xml .javascript,
pre .xml .vbscript,
pre .xml .css,
pre .xml .cdata {
opacity: 0.5;
}
+1070
View File
File diff suppressed because it is too large Load Diff
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

+78
View File
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html>
<head>
<title>Swagger UI</title>
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
<link href='css/highlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='screen' 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>
<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")
$('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>
<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;
+1427
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);
+2118
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
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+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;
+983 -255
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.4",
"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.9",
"handlebars": "~1.0.10",
"less": "~1.4.2"
}
}
+21 -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,16 @@ class SwaggerUi extends Backbone.Router
400
)
buildUrl: (base, url) ->
log "base is " + base
parts = base.split("/")
base = parts[0] + "//" + parts[2]
if url.indexOf("/") is 0
base + url
else
base + "/" + url
# Shows message on topbar of the ui
showMessage: (data = '') ->
$('#message-bar').removeClass 'message-fail'
@@ -0,0 +1,14 @@
class ContentTypeView extends Backbone.View
initialize: ->
render: ->
template = @template()
$(@el).html(template(@model))
$('label[for=contentType]', $(@el)).text('Response Content Type')
@
template: ->
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/resources.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
+1 -1
View File
@@ -6,7 +6,7 @@ class MainView extends Backbone.View
$(@el).html(Handlebars.templates.main(@model))
# Render each resource
@addResource resource for resource in @model.resourcesArray
@addResource resource for resource in @model.apisArray
@
addResource: (resource) ->
+233 -70
View File
@@ -1,4 +1,6 @@
class OperationView extends Backbone.View
invocationUrl: null
events: {
'submit .sandbox' : 'submitOperation'
'click .submit' : 'submitOperation'
@@ -9,21 +11,49 @@ class OperationView extends Backbone.View
initialize: ->
render: ->
isMethodSubmissionSupported = jQuery.inArray(@model.httpMethod, @model.supportedSubmitMethods()) >= 0
isMethodSubmissionSupported = true #jQuery.inArray(@model.method, @model.supportedSubmitMethods) >= 0
@model.isReadOnly = true unless isMethodSubmissionSupported
$(@el).html(Handlebars.templates.operation(@model))
if @model.responseClassSignature and @model.responseClassSignature != 'string'
signatureModel =
sampleJSON: @model.responseSampleJSON
isParam: false
signature: @model.responseClassSignature
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
$('.model-signature', $(@el)).append responseSignatureView.render().el
else
$('.model-signature', $(@el)).html(@model.type)
contentTypeModel =
isParam: false
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
@@ -48,67 +78,118 @@ 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
if isFileUpload
# requires HTML5 compatible browser
bodyParam = new FormData()
for o in form.find("select")
val = this.getSelectedValue o
if(val? && jQuery.trim(val).length > 0)
map[o.name] = val
# add params
for param in @model.parameters
if param.paramType is 'body'
bodyParam.append(param.name, map[param.name])
opts.responseContentType = $("div select[name=responseContentType]", $(@el)).val()
opts.requestContentType = $("div select[name=parameterContentType]", $(@el)).val()
# add files
$.each $('input[type~="file"]'), (i, el) ->
bodyParam.append($(el).attr('name'), el.files[0])
console.log(bodyParam)
else
bodyParam = null
for param in @model.parameters
if param.paramType is 'body'
bodyParam = map[param.name]
log "bodyParam = " + bodyParam
headerParams = null
invocationUrl =
if @model.supportHeaderParams()
headerParams = @model.getHeaderParams(map)
@model.urlify(map, false)
else
@model.urlify(map, true)
log 'submitting ' + invocationUrl
$(".request_url", $(@el)).html "<pre>" + invocationUrl + "</pre>"
$(".response_throbber", $(@el)).show()
if isFileUpload
@handleFileUpload map, form
else
@model.do(map, opts, @showCompleteStatus, @showErrorStatus, @)
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)
success: (response, parent) ->
parent.showCompleteStatus response
obj.contentType = "application/json" if (obj.type.toLowerCase() == "put" or obj.type.toLowerCase() == "patch")
obj.contentType = false if isFileUpload
jQuery.ajax(obj)
false
# $.getJSON(invocationUrl, (r) => @showResponse(r)).complete((r) => @showCompleteStatus(r)).error (r) => @showErrorStatus(r)
handleFileUpload: (map, form) ->
log "it's a file upload"
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()
# add params
for param in @model.parameters
if param.paramType is 'form'
bodyParam.append(param.name, map[param.name])
# headers in operation
headerParams = {}
for param in @model.parameters
if param.paramType is 'header'
headerParams[param.name] = map[param.name]
log headerParams
# add files
for el in form.find('input[type~="file"]')
bodyParam.append($(el).attr('name'), el.files[0])
log(bodyParam)
@invocationUrl =
if @model.supportHeaderParams()
headerParams = @model.getHeaderParams(map)
@model.urlify(map, false)
else
@model.urlify(map, true)
$(".request_url", $(@el)).html "<pre>" + @invocationUrl + "</pre>"
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), @)
# apply authorizations
if window.authorizations
window.authorizations.apply obj
jQuery.ajax(obj)
false
# end of file-upload nastiness
# wraps a jquery response as a shred response
wrap: (data) ->
o = {}
o.content = {}
o.content.data = data.responseText
o.getHeaders = () => {"Content-Type": data.headers("Content-Type")}
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) ->
@@ -120,30 +201,112 @@ class OperationView extends Backbone.View
# Show response from server
showResponse: (response) ->
prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>")
$(".response_body", $(@el)).html prettyJson
$(".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) ->
reg = /(>)(<)(\/*)/g
wsexp = /[ ]*(.*)[ ]+\n/g
contexp = /(<.+>)(.+\n)/g
xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2')
pad = 0
formatted = ''
lines = xml.split('\n')
indent = 0
lastType = 'other'
# 4 types of tags - single, closing, opening, other (text, doctype, comment) - 4*4 = 16 transitions
transitions =
'single->single': 0
'single->closing': -1
'single->opening': 0
'single->other': 0
'closing->single': 0
'closing->closing': -1
'closing->opening': 0
'closing->other': 0
'opening->single': 1
'opening->closing': 0
'opening->opening': 1
'opening->other': 1
'other->single': 0
'other->closing': -1
'other->opening': 0
'other->other': 0
for ln in lines
do (ln) ->
types =
# is this line a single tag? ex. <br />
single: Boolean(ln.match(/<.+\/>/))
# is this a closing tag? ex. </a>
closing: Boolean(ln.match(/<\/.+>/))
# is this even a tag (that's not <!something>)
opening: Boolean(ln.match(/<[^!?].*>/))
[type] = (key for key, value of types when value)
type = if type is undefined then 'other' else type
fromTo = lastType + '->' + type
lastType = type
padding = ''
indent += transitions[fromTo]
padding = (' ' for j in [0...(indent)]).join('')
if fromTo == 'opening->closing'
#substr removes line break (\n) from prev loop
formatted = formatted.substr(0, formatted.length - 1) + ln + '\n'
else
formatted += padding + ln + '\n'
formatted
# puts the response data in UI
showStatus: (data) ->
try
response_body = "<pre>" + JSON.stringify(JSON.parse(data.responseText), null, 2).replace(/\n/g, "<br>") + "</pre>"
catch error
response_body = "<span style='color:red'>&nbsp;&nbsp;&nbsp;[unable to parse as json; raw response below]</span><br><pre>" + data.responseText + "</pre>"
$(".response_code", $(@el)).html "<pre>" + data.status + "</pre>"
showStatus: (response) ->
content = response.data
headers = response.headers
# if server is nice, and sends content-type back, we can use it
contentType = if 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)
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',response.url)
else
# don't know what to render!
code = $('<code />').text(content)
pre = $('<pre class="json" />').append(code)
response_body = pre
$(".request_url", $(@el)).html "<pre>" + response.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 + "_content");
elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_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
@@ -2,12 +2,42 @@ class ParameterView extends Backbone.View
initialize: ->
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))
signatureModel =
sampleJSON: @model.sampleJSON
isParam: true
signature: @model.signature
if @model.sampleJSON
signatureView = new SignatureView({model: signatureModel, tagName: 'div'})
$('.model-signature', $(@el)).append signatureView.render().el
else
$('.model-signature', $(@el)).html(@model.signature)
isParam = false
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
@
# Return an appropriate template based on if the parameter is a list, readonly, required
@@ -4,11 +4,18 @@ class ResourceView extends Backbone.View
render: ->
$(@el).html(Handlebars.templates.resource(@model))
@number = 0
# Render each operation
@addOperation operation for operation in @model.operationsArray
@
addOperation: (operation) ->
operation.number = @number
# Render an operation and add it to operations li
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'})
$('.endpoints', $(@el)).append operationView.render().el
$('.endpoints', $(@el)).append operationView.render().el
@number++
@@ -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
@@ -0,0 +1,51 @@
class SignatureView extends Backbone.View
events: {
'click a.description-link' : 'switchToDescription'
'click a.snippet-link' : 'switchToSnippet'
'mousedown .snippet' : 'snippetToTextArea'
}
initialize: ->
render: ->
template = @template()
$(@el).html(template(@model))
@switchToDescription()
@isParam = @model.isParam
if @isParam
$('.notice', $(@el)).text('Click to set as parameter value')
@
template: ->
Handlebars.templates.signature
# handler for show signature
switchToDescription: (e) ->
e?.preventDefault()
$(".snippet", $(@el)).hide()
$(".description", $(@el)).show()
$('.description-link', $(@el)).addClass('selected')
$('.snippet-link', $(@el)).removeClass('selected')
# handler for show sample
switchToSnippet: (e) ->
e?.preventDefault()
$(".description", $(@el)).hide()
$(".snippet", $(@el)).show()
$('.snippet-link', $(@el)).addClass('selected')
$('.description-link', $(@el)).removeClass('selected')
# handler for snippet to text area
snippetToTextArea: (e) ->
if @isParam
e?.preventDefault()
textArea = $('textarea', $(@el.parentNode.parentNode.parentNode))
if $.trim(textArea.val()) == ''
textArea.val(@model.sampleJSON)
+135
View File
@@ -0,0 +1,135 @@
/*
Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
*/
pre code {
display: block; padding: 0.5em;
background: #F0F0F0;
}
pre code,
pre .subst,
pre .tag .title,
pre .lisp .title,
pre .clojure .built_in,
pre .nginx .title {
color: black;
}
pre .string,
pre .title,
pre .constant,
pre .parent,
pre .tag .value,
pre .rules .value,
pre .rules .value .number,
pre .preprocessor,
pre .ruby .symbol,
pre .ruby .symbol .string,
pre .aggregate,
pre .template_tag,
pre .django .variable,
pre .smalltalk .class,
pre .addition,
pre .flow,
pre .stream,
pre .bash .variable,
pre .apache .tag,
pre .apache .cbracket,
pre .tex .command,
pre .tex .special,
pre .erlang_repl .function_or_atom,
pre .markdown .header {
color: #800;
}
pre .comment,
pre .annotation,
pre .template_comment,
pre .diff .header,
pre .chunk,
pre .markdown .blockquote {
color: #888;
}
pre .number,
pre .date,
pre .regexp,
pre .literal,
pre .smalltalk .symbol,
pre .smalltalk .char,
pre .go .constant,
pre .change,
pre .markdown .bullet,
pre .markdown .link_url {
color: #080;
}
pre .label,
pre .javadoc,
pre .ruby .string,
pre .decorator,
pre .filter .argument,
pre .localvars,
pre .array,
pre .attr_selector,
pre .important,
pre .pseudo,
pre .pi,
pre .doctype,
pre .deletion,
pre .envvar,
pre .shebang,
pre .apache .sqbracket,
pre .nginx .built_in,
pre .tex .formula,
pre .erlang_repl .reserved,
pre .prompt,
pre .markdown .link_label,
pre .vhdl .attribute,
pre .clojure .attribute,
pre .coffeescript .property {
color: #88F
}
pre .keyword,
pre .id,
pre .phpdoc,
pre .title,
pre .built_in,
pre .aggregate,
pre .css .tag,
pre .javadoctag,
pre .phpdoc,
pre .yardoctag,
pre .smalltalk .class,
pre .winutils,
pre .bash .variable,
pre .apache .tag,
pre .go .typename,
pre .tex .command,
pre .markdown .strong,
pre .request,
pre .status {
font-weight: bold;
}
pre .markdown .emphasis {
font-style: italic;
}
pre .nginx .built_in {
font-weight: normal;
}
pre .coffeescript .javascript,
pre .javascript .xml,
pre .tex .formula,
pre .xml .javascript,
pre .xml .vbscript,
pre .xml .css,
pre .xml .cdata {
opacity: 0.5;
}
+1065 -1512
View File
File diff suppressed because it is too large Load Diff
+56 -81
View File
@@ -1,97 +1,72 @@
<!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/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>
<title>Swagger UI</title>
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
<link href='css/highlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='screen' 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>
<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")
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none"
});
<style type="text/css">
.swagger-ui-wrap {
max-width: 960px;
margin-left: auto;
margin-right: auto;
}
$('#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();
});
.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/resources.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);
}
},
onFailure: function(data) {
if(console) {
console.log("Unable to Load SwaggerUI");
console.log(data);
}
},
docExpansion: "none"
});
window.swaggerUi.load();
});
</script>
</script>
</head>
<body>
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="http://swagger.wordnik.com">swagger</a>
<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>
<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;
&nbsp;
</div>
<div id="swagger-ui-container" class="swagger-ui-wrap">
+23 -9
View File
@@ -115,7 +115,7 @@ var Docs = {
},
toggleEndpointListForResource: function(resource) {
var elem = $('li[id^=resource_' + Docs.escapeResourceName(resource) + '] ul.endpoints');
var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
if (elem.is(':visible')) {
Docs.collapseEndpointListForResource(resource);
} else {
@@ -125,24 +125,37 @@ var Docs = {
// Expand resource
expandEndpointListForResource: function(resource) {
$('[id^=resource_' + resource + ']').addClass('active');
var resource = Docs.escapeResourceName(resource);
if (resource == '') {
$('.resource ul.endpoints').slideDown();
return;
}
$('li#resource_' + resource).addClass('active');
var elem = $('li[id^=resource_' + Docs.escapeResourceName(resource) + '] ul.endpoints');
var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideDown();
},
// Collapse resource and mark as explicitly closed
collapseEndpointListForResource: function(resource) {
$('[id^=resource_' + resource + ']').removeClass('active');
var resource = Docs.escapeResourceName(resource);
$('li#resource_' + resource).removeClass('active');
var elem = $('li[id^=resource_' + Docs.escapeResourceName(resource) + '] ul.endpoints');
var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideUp();
},
expandOperationsForResource: function(resource) {
// Make sure the resource container is open..
Docs.expandEndpointListForResource(resource);
$('li[id^=resource_' + Docs.escapeResourceName(resource) + '] li.operation div.content').each(function() {
if (resource == '') {
$('.resource ul.endpoints li.operation div.content').slideDown();
return;
}
$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
Docs.expandOperation($(this));
});
},
@@ -150,13 +163,14 @@ var Docs = {
collapseOperationsForResource: function(resource) {
// Make sure the resource container is open..
Docs.expandEndpointListForResource(resource);
$('li[id^=resource_' + Docs.escapeResourceName(resource) + '] li.operation div.content').each(function() {
$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
Docs.collapseOperation($(this));
});
},
escapeResourceName: function(resource) {
return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&")
return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
},
expandOperation: function(elem) {
@@ -167,4 +181,4 @@ var Docs = {
elem.slideUp();
}
};
};
+50
View File
@@ -0,0 +1,50 @@
/* 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;
}
+67
View File
@@ -0,0 +1,67 @@
@import 'src/main/less/reset.less';
@import 'src/main/less/specs.less';
#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
+10
View File
@@ -0,0 +1,10 @@
<label for="contentType"></label>
<select name="contentType">
{{#if produces}}
{{#each produces}}
<option value="{{{this}}}">{{{this}}}</option>
{{/each}}
{{else}}
<option value="application/json">application/json</option>
{{/if}}
</select>
+14 -3
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>
@@ -6,6 +14,9 @@
<div class="footer">
<br>
<br>
<h4 style="color: #999">[<span style="font-variant: small-caps">base url</span>: {{basePath}}]</h4>
<h4 style="color: #999">[ <span style="font-variant: small-caps">base url</span>: {{basePath}}
{{#if apiVersion}}
, <span style="font-variant: small-caps">api version</span>: {{apiVersion}}
{{/if}}]</h4>
</div>
</div>
</div>
+83 -82
View File
@@ -1,84 +1,85 @@
<ul class='operations' >
<li class='{{httpMethod}} operation' id='{{resourceName}}_{{nickname}}_{{httpMethod}}'>
<div class='heading'>
<h3>
<span class='http_method'>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}' class="toggleOperation">{{httpMethod}}</a>
</span>
<span class='path'>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}' class="toggleOperation">{{path}}</a>
</span>
</h3>
<ul class='options'>
<li>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}' class="toggleOperation">{{{summary}}}</a>
</li>
</ul>
</div>
<div class='content' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_content' style='display:none'>
{{#if notes}}
<h4>Implementation Notes</h4>
<p>{{{notes}}}</p>
{{/if}}
{{#if responseClass}}
<h4>Response Class</h4>
{{#if responseClassSignature}}
<p><span class="model-signature">{{{responseClassSignature}}}</span></p>
{{else}}
<p>{{{responseClass}}}</p>
{{/if}}
{{/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='{{resourceName}}_{{nickname}}_{{method}}_{{number}}'>
<div class='heading'>
<h3>
<span class='http_method'>
<a href='#!/{{resourceName}}/{{nickname}}_{{method}}_{{number}}' class="toggleOperation">{{method}}</a>
</span>
<span class='path'>
<a href='#!/{{resourceName}}/{{nickname}}_{{method}}_{{number}}' class="toggleOperation">{{path}}</a>
</span>
</h3>
<ul class='options'>
<li>
<a href='#!/{{resourceName}}/{{nickname}}_{{method}}_{{number}}' class="toggleOperation">{{{summary}}}</a>
</li>
</ul>
</div>
<div class='content' id='{{resourceName}}_{{nickname}}_{{method}}_{{number}}_content' style='display:none'>
{{#if notes}}
<h4>Implementation Notes</h4>
<p>{{{notes}}}</p>
{{/if}}
{{#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>Error 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>
+8 -5
View File
@@ -4,24 +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>
<textarea class='body-textarea' name='{{name}}'></textarea>
<br />
<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">{{{signature}}}</span>
<span class="model-signature"></span>
</td>
+21 -17
View File
@@ -1,21 +1,25 @@
<td class='code'>{{name}}</td>
<td>
<select name='{{name}}'>
{{#if required}}
{{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>
<select {{#if allowMultiple}} multiple='multiple'{{/if}} class='parameter' name='{{name}}'>
{{#if required}}
{{else}}
{{#if defaultValue}}
{{else}}
{{#if allowMultiple}}
{{else}}
<option selected="" value=''></option>
{{/if}}
{{/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">{{{signature}}}</span></td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
+7 -2
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><span class="model-signature">{{{signature}}}</span></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><span class="model-signature">{{{signature}}}</span></td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
+9 -6
View File
@@ -7,22 +7,25 @@
{{#if defaultValue}}
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'>{{defaultValue}}</textarea>
{{else}}
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'></textarea>
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'></textarea>
<br />
<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}}
</td>
<td>
<strong>{{{description}}}</strong>
<strong>{{{description}}}</strong>
</td>
<td><span class="model-signature">{{{signature}}}</span></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>
+22 -22
View File
@@ -1,26 +1,26 @@
<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='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">{{name}}</a> {{#description}} : {{/description}}{{{description}}}
</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>
</div>
<ul class='endpoints' id='{{name}}_endpoint_list' style='display:none'>
@@ -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>
+18
View File
@@ -0,0 +1,18 @@
<div>
<ul class="signature-nav">
<li><a class="description-link" href="#">Model</a></li>
<li><a class="snippet-link" href="#">Model Schema</a></li>
</ul>
<div>
<div class="signature-container">
<div class="description">
{{{signature}}}
</div>
<div class="snippet">
<pre><code>{{sampleJSON}}</code></pre>
<small class="notice"></small>
</div>
</div>
+1 -2
View File
@@ -1,3 +1,2 @@
<td width='15%' class='code'>{{code}}</td>
<td>{{{reason}}}</td>
<td>{{{message}}}</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