updated to v2

This commit is contained in:
Tony Tam
2012-07-11 09:57:27 -07:00
parent a2c1c18f75
commit d2eb882e52
278 changed files with 46216 additions and 11130 deletions

View File

@@ -0,0 +1,79 @@
class SwaggerUi extends Backbone.Router
# Routes
routes:
'' : 'load'
# Defaults
dom_id: "swagger_ui"
# Attributes
options: null
api: null
headerView: null
mainView: null
# SwaggerUi accepts all the same options as SwaggerApi
initialize: (options={}) ->
Backbone.history.start pushState: true
# Allow dom_id to be overridden
if options.dom_id?
@dom_id = options.dom_id
delete options.dom_id
# Create an empty div which contains the dom_id
$('body').append('<div id="' + @dom_id + '"></div>') if not $('#' + @dom_id)?
@options = options
# Set the callbacks
@options.success = => @render()
@options.progress = (d) => @showMessage(d)
@options.failure = (d) => @onLoadFailure(d)
# Create view to handle the header inputs
@headerView = new HeaderView({el: $('#header')})
# Event handler for when the baseUrl/apiKey is entered by user
@headerView.on 'update-swagger-ui', (data) => @updateSwaggerUi(data)
@load()
# Event handler for when url/key is received from user
updateSwaggerUi: (data) ->
@options.discoveryUrl = data.discoveryUrl
@options.apiKey = data.apiKey
@load()
# Create an api and render
load: ->
# Initialize the API object
@mainView?.clear()
@headerView.update(@options.discoveryUrl, @options.apiKey)
@api = new SwaggerApi(@options)
# This is bound to success handler for SwaggerApi
# so it gets called when SwaggerApi completes loading
render: ->
@showMessage('Finished Loading Resource Information. Rendering Swagger UI...')
@mainView = new MainView({model: @api, el: $('#' + @dom_id)}).render()
@showMessage()
setTimeout(
=>
Docs.shebang()
400
)
# Shows message on topbar of the ui
showMessage: (data = '') ->
$('#message-bar').removeClass 'message-fail'
$('#message-bar').addClass 'message-success'
$('#message-bar').html data
# shows message in red
onLoadFailure: (data = '') ->
$('#message-bar').removeClass 'message-success'
$('#message-bar').addClass 'message-fail'
$('#message-bar').html data
window.SwaggerUi = SwaggerUi

View File

@@ -0,0 +1,38 @@
class HeaderView extends Backbone.View
events: {
'click #show-pet-store-icon' : 'showPetStore'
'click #show-wordnik-dev-icon' : 'showWordnikDev'
'click #explore' : 'showCustom'
'keyup #input_baseUrl' : 'showCustomOnKeyup'
'keyup #input_apiKey' : 'showCustomOnKeyup'
}
initialize: ->
showPetStore: (e) ->
@trigger(
'update-swagger-ui'
{discoveryUrl:"http://petstore.swagger.wordnik.com/api/resources.json", apiKey:"special-key"}
)
showWordnikDev: (e) ->
@trigger(
'update-swagger-ui'
{discoveryUrl:"http://api.wordnik.com/v4/resources.json", apiKey:"b39ee8d5f05d0f566a0080b4c310ceddf5dc5f7606a616f53"}
)
showCustomOnKeyup: (e) ->
@showCustom() if e.keyCode is 13
showCustom: (e) ->
e?.preventDefault()
@trigger(
'update-swagger-ui'
{discoveryUrl: $('#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

View File

@@ -0,0 +1,18 @@
class MainView extends Backbone.View
initialize: ->
render: ->
# Render the outer container for resources
$(@el).html(Handlebars.templates.main(@model))
# Render each resource
@addResource resource for resource in @model.resourcesArray
@
addResource: (resource) ->
# Render a resource and add it to resources li
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.name, className: 'resource'})
$('#resources').append resourceView.render().el
clear: ->
$(@el).html ''

View File

@@ -0,0 +1,109 @@
class OperationView extends Backbone.View
events: {
'click .submit' : 'submitOperation'
'click .response_hider' : 'hideResponse'
'click .toggleOperation' : 'toggleOperationContent'
}
initialize: ->
render: ->
$(@el).html(Handlebars.templates.operation(@model))
# Render each parameter
@addParameter param for param in @model.parameters
@
addParameter: (param) ->
# Render a parameter
paramView = new ParameterView({model: param, tagName: 'tr', readOnly: !@model.isGetMethod})
$('.operation-params', $(@el)).append paramView.render().el
submitOperation: ->
# Check for errors
form = $('.sandbox', $(@el))
error_free = true
form.find("input.required").each ->
$(@).removeClass "error"
if jQuery.trim($(@).val()) is ""
$(@).addClass "error"
$(@).wiggle
callback: => $(@).focus()
error_free = false
# if error free submit it
if error_free
map = {}
for o in form.serializeArray()
if(o.value? && jQuery.trim(o.value).length > 0)
map[o.name] = o.value
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()
obj =
type: @model.httpMethod
url: invocationUrl
headers: headerParams
# data: JSON.stringify(@body)
dataType: 'json'
error: (xhr, textStatus, error) =>
@showErrorStatus(xhr, textStatus, error)
success: (data) =>
@showResponse(data)
complete: (data) =>
@showCompleteStatus(data)
obj.contentType = "application/json" if (obj.type.toLowerCase() == "post" or obj.type.toLowerCase() == "put")
jQuery.ajax(obj)
# $.getJSON(invocationUrl, (r) => @showResponse(r)).complete((r) => @showCompleteStatus(r)).error (r) => @showErrorStatus(r)
# handler for hide response link
hideResponse: (e) ->
e?.preventDefault()
$(".response", $(@el)).slideUp()
$(".response_hider", $(@el)).fadeOut()
# Show response from server
showResponse: (response) ->
prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>")
$(".response_body", $(@el)).html prettyJson
# Show error from server
showErrorStatus: (data) ->
@showStatus data
# show the status codes
showCompleteStatus: (data) ->
@showStatus data
# 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>"
$(".response_body", $(@el)).html response_body
$(".response_headers", $(@el)).html "<pre>" + data.getAllResponseHeaders() + "</pre>"
$(".response", $(@el)).slideDown()
$(".response_hider", $(@el)).show()
$(".response_throbber", $(@el)).hide()
toggleOperationContent: ->
elem = $('#' + @model.resourceName + "_" + @model.nickname + "_" + @model.httpMethod + "_content");
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)

View File

@@ -0,0 +1,23 @@
class ParameterView extends Backbone.View
initialize: ->
render: ->
template = @template()
$(@el).html(template(@model))
@
# Return an appropriate template based on if the parameter is a list, readonly, required
template: ->
if @model.isList
Handlebars.templates.param_list
else
if @options.readOnly
if @model.required
Handlebars.templates.param_readonly_required
else
Handlebars.templates.param_readonly
else
if @model.required
Handlebars.templates.param_required
else
Handlebars.templates.param

View File

@@ -0,0 +1,14 @@
class ResourceView extends Backbone.View
initialize: ->
render: ->
$(@el).html(Handlebars.templates.resource(@model))
# Render each operation
@addOperation operation for operation in @model.operationsArray
@
addOperation: (operation) ->
# Render an operation and add it to operations li
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'})
$('.endpoints', $(@el)).append operationView.render().el

View File

@@ -0,0 +1,954 @@
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; }
body {
line-height: 1; }
ol, ul {
list-style: none; }
table {
border-collapse: collapse;
border-spacing: 0; }
caption, th, td {
text-align: left;
font-weight: normal;
vertical-align: middle; }
q, blockquote {
quotes: none; }
q:before, q:after, blockquote:before, blockquote:after {
content: "";
content: none; }
a img {
border: none; }
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary {
display: block; }
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
text-decoration: none; }
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover {
text-decoration: underline; }
h1 span.divider, h2 span.divider, h3 span.divider, h4 span.divider, h5 span.divider, h6 span.divider {
color: #aaaaaa; }
h1 {
color: #547f00;
color: black;
font-size: 1.5em;
line-height: 1.3em;
padding: 10px 0 10px 0;
font-family: "Droid Sans", sans-serif;
font-weight: bold; }
h2 {
color: #89bf04;
color: black;
font-size: 1.3em;
padding: 10px 0 10px 0; }
h2 a {
color: black; }
h2 span.sub {
font-size: 0.7em;
color: #999999;
font-style: italic; }
h2 span.sub a {
color: #777777; }
h3 {
color: black;
font-size: 1.1em;
padding: 10px 0 10px 0; }
div.heading_with_menu {
float: none;
clear: both;
overflow: hidden;
display: block; }
div.heading_with_menu h1, div.heading_with_menu h2, div.heading_with_menu h3, div.heading_with_menu h4, div.heading_with_menu h5, div.heading_with_menu h6 {
display: block;
clear: none;
float: left;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
width: 60%; }
div.heading_with_menu ul {
display: block;
clear: none;
float: right;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
margin-top: 10px; }
p {
line-height: 1.4em;
padding: 0 0 10px 0;
color: #333333; }
ol {
margin: 0px 0 10px 0;
padding: 0 0 0 18px;
list-style-type: decimal; }
ol li {
padding: 5px 0px;
font-size: 0.9em;
color: #333333; }
.markdown h3 {
color: #547f00; }
.markdown h4 {
color: #666666; }
.markdown pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
background-color: #fcf6db;
border: 1px solid black;
border-color: #e5e0c6;
padding: 10px;
margin: 0 0 10px 0; }
.markdown pre code {
line-height: 1.6em; }
.markdown p code, .markdown li code {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
background-color: #f0f0f0;
color: black;
padding: 1px 3px; }
.markdown ol, .markdown ul {
font-family: "Droid Sans", sans-serif;
margin: 5px 0 10px 0;
padding: 0 0 0 18px;
list-style-type: disc; }
.markdown ol li, .markdown ul li {
padding: 3px 0px;
line-height: 1.4em;
color: #333333; }
div.gist {
margin: 20px 0 25px 0 !important; }
p.big, div.big p {
font-size: 1 em;
margin-bottom: 10px; }
span.weak {
color: #666666; }
span.blank, span.empty {
color: #888888;
font-style: italic; }
a {
color: #547f00; }
strong {
font-family: "Droid Sans", sans-serif;
font-weight: bold;
font-weight: bold; }
.code {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; }
pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
background-color: #fcf6db;
border: 1px solid black;
border-color: #e5e0c6;
padding: 10px;
/* white-space: pre-line */ }
pre code {
line-height: 1.6em; }
.required {
font-weight: bold; }
table.fullwidth {
width: 100%; }
table thead tr th {
padding: 5px;
font-size: 0.9em;
color: #666666;
border-bottom: 1px solid #999999; }
table tbody tr.offset {
background-color: #f5f5f5; }
table tbody tr td {
padding: 6px;
font-size: 0.9em;
border-bottom: 1px solid #cccccc;
vertical-align: top;
line-height: 1.3em; }
table tbody tr:last-child td {
border-bottom: none; }
table tbody tr.offset {
background-color: #f0f0f0; }
form.form_box {
background-color: #ebf3f9;
border: 1px solid black;
border-color: #c3d9ec;
padding: 10px; }
form.form_box label {
color: #0f6ab4 !important; }
form.form_box input[type=submit] {
display: block;
padding: 10px; }
form.form_box p {
font-size: 0.9em;
padding: 0 0 15px 0;
color: #7e7b6d; }
form.form_box p a {
color: #646257; }
form.form_box p strong {
color: black; }
form.form_box p.weak {
font-size: 0.8em; }
form.formtastic fieldset.inputs ol li p.inline-hints {
margin-left: 0;
font-style: italic;
font-size: 0.9em;
margin: 0; }
form.formtastic fieldset.inputs ol li label {
display: block;
clear: both;
width: auto;
padding: 0 0 3px 0;
color: #666666; }
form.formtastic fieldset.inputs ol li label abbr {
padding-left: 3px;
color: #888888; }
form.formtastic fieldset.inputs ol li.required label {
color: black; }
form.formtastic fieldset.inputs ol li.string input, form.formtastic fieldset.inputs ol li.url input, form.formtastic fieldset.inputs ol li.numeric input {
display: block;
padding: 4px;
width: auto;
clear: both; }
form.formtastic fieldset.inputs ol li.string input.title, form.formtastic fieldset.inputs ol li.url input.title, form.formtastic fieldset.inputs ol li.numeric input.title {
font-size: 1.3em; }
form.formtastic fieldset.inputs ol li.text textarea {
font-family: "Droid Sans", sans-serif;
height: 250px;
padding: 4px;
display: block;
clear: both; }
form.formtastic fieldset.inputs ol li.select select {
display: block;
clear: both; }
form.formtastic fieldset.inputs ol li.boolean {
float: none;
clear: both;
overflow: hidden;
display: block; }
form.formtastic fieldset.inputs ol li.boolean input {
display: block;
float: left;
clear: none;
margin: 0 5px 0 0; }
form.formtastic fieldset.inputs ol li.boolean label {
display: block;
float: left;
clear: none;
margin: 0;
padding: 0; }
form.formtastic fieldset.buttons {
margin: 0;
padding: 0; }
form.fullwidth ol li.string input, form.fullwidth ol li.url input, form.fullwidth ol li.text textarea, form.fullwidth ol li.numeric input {
width: 500px !important; }
body {
font-family: "Droid Sans", sans-serif; }
body #content_message {
margin: 10px 15px;
font-style: italic;
color: #999999; }
body #header {
background-color: #89bf04;
padding: 14px; }
body #header a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(http://swagger.wordnik.com/images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white; }
body #header form#api_selector {
display: block;
clear: none;
float: right; }
body #header form#api_selector .input {
display: block;
clear: none;
float: left;
margin: 0 10px 0 0; }
body #header form#api_selector .input input {
font-size: 0.9em;
padding: 3px;
margin: 0; }
body #header form#api_selector .input input#input_baseUrl {
width: 400px; }
body #header form#api_selector .input input#input_apiKey {
width: 200px; }
body #header form#api_selector .input 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; }
body #header form#api_selector .input a#explore:hover {
background-color: #547f00; }
body p#colophon {
margin: 0 15px 40px 15px;
padding: 10px 0;
font-size: 0.8em;
border-top: 1px solid #dddddd;
font-family: "Droid Sans", sans-serif;
color: #999999;
font-style: italic; }
body p#colophon a {
text-decoration: none;
color: #547f00; }
body ul#resources {
font-family: "Droid Sans", sans-serif;
font-size: 0.9em; }
body ul#resources li.resource {
border-bottom: 1px solid #dddddd; }
body ul#resources li.resource:last-child {
border-bottom: none; }
body ul#resources li.resource div.heading {
border: 1px solid transparent;
float: none;
clear: both;
overflow: hidden;
display: block; }
body ul#resources li.resource div.heading h2 {
color: #999999;
padding-left: 0px;
display: block;
clear: none;
float: left;
font-family: "Droid Sans", sans-serif;
font-weight: bold; }
body ul#resources li.resource div.heading h2 a {
color: #999999; }
body ul#resources li.resource div.heading h2 a:hover {
color: black; }
body ul#resources li.resource div.heading ul.options {
float: none;
clear: both;
overflow: hidden;
margin: 0;
padding: 0;
display: block;
clear: none;
float: right;
margin: 14px 10px 0 0; }
body ul#resources li.resource div.heading ul.options li {
float: left;
clear: none;
margin: 0;
padding: 2px 10px;
border-right: 1px solid #dddddd; }
body ul#resources li.resource div.heading ul.options li:first-child, body ul#resources li.resource div.heading ul.options li.first {
padding-left: 0; }
body ul#resources li.resource div.heading ul.options li:last-child, body ul#resources li.resource div.heading ul.options li.last {
padding-right: 0;
border-right: none; }
body ul#resources li.resource div.heading ul.options li {
color: #666666;
font-size: 0.9em; }
body ul#resources li.resource div.heading ul.options li a {
color: #aaaaaa;
text-decoration: none; }
body ul#resources li.resource div.heading ul.options li a:hover {
text-decoration: underline;
color: black; }
body ul#resources li.resource:hover div.heading h2 a, body ul#resources li.resource.active div.heading h2 a {
color: black; }
body ul#resources li.resource:hover div.heading ul.options li a, body ul#resources li.resource.active div.heading ul.options li a {
color: #555555; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0 0 10px 0;
padding: 0 0 0 0px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0 0 0 0;
padding: 0;
background-color: #e7f0f7;
border: 1px solid black;
border-color: #c3d9ec; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 {
display: block;
clear: none;
float: left;
width: auto;
margin: 0;
padding: 0;
line-height: 1.1em;
color: black; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span {
margin: 0;
padding: 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.http_method a {
text-transform: uppercase;
background-color: #0f6ab4;
text-decoration: none;
color: white;
display: inline-block;
width: 50px;
font-size: 0.7em;
text-align: center;
padding: 7px 0 4px 0;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-o-border-radius: 2px;
-ms-border-radius: 2px;
-khtml-border-radius: 2px;
border-radius: 2px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.path {
padding-left: 10px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.path a {
color: black;
text-decoration: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.path a:hover {
text-decoration: underline; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options {
float: none;
clear: both;
overflow: hidden;
margin: 0;
padding: 0;
display: block;
clear: none;
float: right;
margin: 6px 10px 0 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li {
float: left;
clear: none;
margin: 0;
padding: 2px 10px;
border-right: 1px solid #dddddd; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:first-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.first {
padding-left: 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:last-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.last {
padding-right: 0;
border-right: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li {
border-right-color: #c3d9ec;
color: #0f6ab4;
font-size: 0.9em; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a {
color: #0f6ab4;
text-decoration: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a:hover, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a:active, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a.active {
text-decoration: underline; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content {
background-color: #ebf3f9;
border: 1px solid black;
border-color: #c3d9ec;
border-top: none;
padding: 10px;
-moz-border-radius-bottomleft: 6px;
-webkit-border-bottom-left-radius: 6px;
-o-border-bottom-left-radius: 6px;
-ms-border-bottom-left-radius: 6px;
-khtml-border-bottom-left-radius: 6px;
border-bottom-left-radius: 6px;
-moz-border-radius-bottomright: 6px;
-webkit-border-bottom-right-radius: 6px;
-o-border-bottom-right-radius: 6px;
-ms-border-bottom-right-radius: 6px;
-khtml-border-bottom-right-radius: 6px;
border-bottom-right-radius: 6px;
margin: 0 0 20px 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content h4 {
color: #0f6ab4;
font-size: 1.1em;
margin: 0;
padding: 15px 0 5px 0px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content form input[type='text'].error {
outline: 2px solid black;
outline-color: #cc0000; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header {
float: none;
clear: both;
overflow: hidden;
display: block; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header input.submit {
display: block;
clear: none;
float: left;
padding: 6px 8px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header img {
display: block;
display: block;
clear: none;
float: right; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a {
padding: 4px 0 0 10px;
color: #6fa5d2;
display: inline-block;
font-size: 0.9em; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.response div.block {
background-color: #fcf6db;
border: 1px solid black;
border-color: #e5e0c6; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.response div.block pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
padding: 10px;
font-size: 0.9em;
max-height: 400px;
overflow-y: auto; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0 0 10px 0;
padding: 0 0 0 0px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0 0 0 0;
padding: 0;
background-color: #e7f6ec;
border: 1px solid black;
border-color: #c3e8d1; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 {
display: block;
clear: none;
float: left;
width: auto;
margin: 0;
padding: 0;
line-height: 1.1em;
color: black; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span {
margin: 0;
padding: 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.http_method a {
text-transform: uppercase;
background-color: #10a54a;
text-decoration: none;
color: white;
display: inline-block;
width: 50px;
font-size: 0.7em;
text-align: center;
padding: 7px 0 4px 0;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-o-border-radius: 2px;
-ms-border-radius: 2px;
-khtml-border-radius: 2px;
border-radius: 2px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.path {
padding-left: 10px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.path a {
color: black;
text-decoration: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.path a:hover {
text-decoration: underline; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options {
float: none;
clear: both;
overflow: hidden;
margin: 0;
padding: 0;
display: block;
clear: none;
float: right;
margin: 6px 10px 0 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li {
float: left;
clear: none;
margin: 0;
padding: 2px 10px;
border-right: 1px solid #dddddd; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:first-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.first {
padding-left: 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:last-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.last {
padding-right: 0;
border-right: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li {
border-right-color: #c3e8d1;
color: #10a54a;
font-size: 0.9em; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a {
color: #10a54a;
text-decoration: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a:hover, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a:active, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a.active {
text-decoration: underline; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content {
background-color: #ebf7f0;
border: 1px solid black;
border-color: #c3e8d1;
border-top: none;
padding: 10px;
-moz-border-radius-bottomleft: 6px;
-webkit-border-bottom-left-radius: 6px;
-o-border-bottom-left-radius: 6px;
-ms-border-bottom-left-radius: 6px;
-khtml-border-bottom-left-radius: 6px;
border-bottom-left-radius: 6px;
-moz-border-radius-bottomright: 6px;
-webkit-border-bottom-right-radius: 6px;
-o-border-bottom-right-radius: 6px;
-ms-border-bottom-right-radius: 6px;
-khtml-border-bottom-right-radius: 6px;
border-bottom-right-radius: 6px;
margin: 0 0 20px 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content h4 {
color: #10a54a;
font-size: 1.1em;
margin: 0;
padding: 15px 0 5px 0px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content form input[type='text'].error {
outline: 2px solid black;
outline-color: #cc0000; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header {
float: none;
clear: both;
overflow: hidden;
display: block; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header input.submit {
display: block;
clear: none;
float: left;
padding: 6px 8px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header img {
display: block;
display: block;
clear: none;
float: right; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header a {
padding: 4px 0 0 10px;
color: #6fc992;
display: inline-block;
font-size: 0.9em; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.response div.block {
background-color: #fcf6db;
border: 1px solid black;
border-color: #e5e0c6; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.response div.block pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
padding: 10px;
font-size: 0.9em;
max-height: 400px;
overflow-y: auto; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0 0 10px 0;
padding: 0 0 0 0px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0 0 0 0;
padding: 0;
background-color: #f9f2e9;
border: 1px solid black;
border-color: #f0e0ca; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 {
display: block;
clear: none;
float: left;
width: auto;
margin: 0;
padding: 0;
line-height: 1.1em;
color: black; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span {
margin: 0;
padding: 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.http_method a {
text-transform: uppercase;
background-color: #c5862b;
text-decoration: none;
color: white;
display: inline-block;
width: 50px;
font-size: 0.7em;
text-align: center;
padding: 7px 0 4px 0;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-o-border-radius: 2px;
-ms-border-radius: 2px;
-khtml-border-radius: 2px;
border-radius: 2px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.path {
padding-left: 10px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.path a {
color: black;
text-decoration: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.path a:hover {
text-decoration: underline; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options {
float: none;
clear: both;
overflow: hidden;
margin: 0;
padding: 0;
display: block;
clear: none;
float: right;
margin: 6px 10px 0 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li {
float: left;
clear: none;
margin: 0;
padding: 2px 10px;
border-right: 1px solid #dddddd; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:first-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.first {
padding-left: 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:last-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.last {
padding-right: 0;
border-right: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li {
border-right-color: #f0e0ca;
color: #c5862b;
font-size: 0.9em; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a {
color: #c5862b;
text-decoration: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a:hover, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a:active, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a.active {
text-decoration: underline; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content {
background-color: #faf5ee;
border: 1px solid black;
border-color: #f0e0ca;
border-top: none;
padding: 10px;
-moz-border-radius-bottomleft: 6px;
-webkit-border-bottom-left-radius: 6px;
-o-border-bottom-left-radius: 6px;
-ms-border-bottom-left-radius: 6px;
-khtml-border-bottom-left-radius: 6px;
border-bottom-left-radius: 6px;
-moz-border-radius-bottomright: 6px;
-webkit-border-bottom-right-radius: 6px;
-o-border-bottom-right-radius: 6px;
-ms-border-bottom-right-radius: 6px;
-khtml-border-bottom-right-radius: 6px;
border-bottom-right-radius: 6px;
margin: 0 0 20px 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content h4 {
color: #c5862b;
font-size: 1.1em;
margin: 0;
padding: 15px 0 5px 0px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content form input[type='text'].error {
outline: 2px solid black;
outline-color: #cc0000; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header {
float: none;
clear: both;
overflow: hidden;
display: block; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header input.submit {
display: block;
clear: none;
float: left;
padding: 6px 8px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header img {
display: block;
display: block;
clear: none;
float: right; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a {
padding: 4px 0 0 10px;
color: #dcb67f;
display: inline-block;
font-size: 0.9em; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.response div.block {
background-color: #fcf6db;
border: 1px solid black;
border-color: #e5e0c6; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.response div.block pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
padding: 10px;
font-size: 0.9em;
max-height: 400px;
overflow-y: auto; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0 0 10px 0;
padding: 0 0 0 0px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0 0 0 0;
padding: 0;
background-color: #f5e8e8;
border: 1px solid black;
border-color: #e8c6c7; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 {
display: block;
clear: none;
float: left;
width: auto;
margin: 0;
padding: 0;
line-height: 1.1em;
color: black; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span {
margin: 0;
padding: 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.http_method a {
text-transform: uppercase;
background-color: #a41e22;
text-decoration: none;
color: white;
display: inline-block;
width: 50px;
font-size: 0.7em;
text-align: center;
padding: 7px 0 4px 0;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-o-border-radius: 2px;
-ms-border-radius: 2px;
-khtml-border-radius: 2px;
border-radius: 2px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.path {
padding-left: 10px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.path a {
color: black;
text-decoration: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.path a:hover {
text-decoration: underline; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options {
float: none;
clear: both;
overflow: hidden;
margin: 0;
padding: 0;
display: block;
clear: none;
float: right;
margin: 6px 10px 0 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li {
float: left;
clear: none;
margin: 0;
padding: 2px 10px;
border-right: 1px solid #dddddd; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:first-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.first {
padding-left: 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:last-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.last {
padding-right: 0;
border-right: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li {
border-right-color: #e8c6c7;
color: #a41e22;
font-size: 0.9em; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a {
color: #a41e22;
text-decoration: none; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a:hover, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a:active, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a.active {
text-decoration: underline; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content {
background-color: #f7eded;
border: 1px solid black;
border-color: #e8c6c7;
border-top: none;
padding: 10px;
-moz-border-radius-bottomleft: 6px;
-webkit-border-bottom-left-radius: 6px;
-o-border-bottom-left-radius: 6px;
-ms-border-bottom-left-radius: 6px;
-khtml-border-bottom-left-radius: 6px;
border-bottom-left-radius: 6px;
-moz-border-radius-bottomright: 6px;
-webkit-border-bottom-right-radius: 6px;
-o-border-bottom-right-radius: 6px;
-ms-border-bottom-right-radius: 6px;
-khtml-border-bottom-right-radius: 6px;
border-bottom-right-radius: 6px;
margin: 0 0 20px 0; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content h4 {
color: #a41e22;
font-size: 1.1em;
margin: 0;
padding: 15px 0 5px 0px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content form input[type='text'].error {
outline: 2px solid black;
outline-color: #cc0000; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header {
float: none;
clear: both;
overflow: hidden;
display: block; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header input.submit {
display: block;
clear: none;
float: left;
padding: 6px 8px; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header img {
display: block;
display: block;
clear: none;
float: right; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header a {
padding: 4px 0 0 10px;
color: #c8787a;
display: inline-block;
font-size: 0.9em; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.response div.block {
background-color: #fcf6db;
border: 1px solid black;
border-color: #e5e0c6; }
body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.response div.block pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
padding: 10px;
font-size: 0.9em;
max-height: 400px;
overflow-y: auto; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 B

85
src/main/html/index.html Normal file
View File

@@ -0,0 +1,85 @@
<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.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.runtime-1.0.0.beta.6.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>
<style type="text/css">
.swagger-ui-wrap {
max-width: 960px;
margin-left: auto;
margin-right: auto;
}
.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.ui = new SwaggerUi({
discoveryUrl:"http://petstore.swagger.wordnik.com/api/resources.json",
apiKey:"special-key",
dom_id:"swagger-ui-container",
supportHeaderParams: false
});
});
</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>

158
src/main/javascript/doc.js Normal file
View File

@@ -0,0 +1,158 @@
$(function() {
// Helper function for vertically aligning DOM elements
// http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
$.fn.vAlign = function() {
return this.each(function(i){
var ah = $(this).height();
var ph = $(this).parent().height();
var mh = (ph - ah) / 2;
$(this).css('margin-top', mh);
});
};
$.fn.stretchFormtasticInputWidthToParent = function() {
return this.each(function(i){
var p_width = $(this).closest("form").innerWidth();
var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
$(this).css('width', p_width - p_padding - this_padding);
});
};
$('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
// Vertically center these paragraphs
// Parent may need a min-height for this to work..
$('ul.downplayed li div.content p').vAlign();
// When a sandbox form is submitted..
$("form.sandbox").submit(function(){
var error_free = true;
// Cycle through the forms required inputs
$(this).find("input.required").each(function() {
// Remove any existing error styles from the input
$(this).removeClass('error');
// Tack the error style on if the input is empty..
if ($(this).val() == '') {
$(this).addClass('error');
$(this).wiggle();
error_free = false;
}
});
return error_free;
});
});
function clippyCopiedCallback(a) {
$('#api_key_copied').fadeIn().delay(1000).fadeOut();
// var b = $("#clippy_tooltip_" + a);
// b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
// b.attr("title", "copy to clipboard")
// },
// 500))
}
// Logging function that accounts for browsers that don't have window.console
function log() {
if (window.console) console.log.apply(console,arguments);
}
var Docs = {
shebang: function() {
// If shebang has an operation nickname in it..
// e.g. /docs/#!/words/get_search
var fragments = $.param.fragment().split('/');
fragments.shift(); // get rid of the bang
switch (fragments.length) {
case 1:
// Expand all operations for the resource and scroll to it
// log('shebang resource:' + fragments[0]);
var dom_id = 'resource_' + fragments[0];
Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false});
break;
case 2:
// Refer to the endpoint DOM element, e.g. #words_get_search
// log('shebang endpoint: ' + fragments.join('_'));
// Expand Resource
Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false});
// Expand operation
var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content";
// log("li_dom_id " + li_dom_id);
// log("li_content_dom_id " + li_content_dom_id);
Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false});
break;
}
},
toggleEndpointListForResource: function(resource) {
var elem = $('li#resource_' + resource + ' ul.endpoints');
if (elem.is(':visible')) {
Docs.collapseEndpointListForResource(resource);
} else {
Docs.expandEndpointListForResource(resource);
}
},
// Expand resource
expandEndpointListForResource: function(resource) {
$('#resource_' + resource).addClass('active');
var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideDown();
},
// Collapse resource and mark as explicitly closed
collapseEndpointListForResource: function(resource) {
$('#resource_' + resource).removeClass('active');
var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideUp();
},
expandOperationsForResource: function(resource) {
// Make sure the resource container is open..
Docs.expandEndpointListForResource(resource);
$('li#resource_' + resource + ' li.operation div.content').each(function() {
Docs.expandOperation($(this));
});
},
collapseOperationsForResource: function(resource) {
// Make sure the resource container is open..
Docs.expandEndpointListForResource(resource);
$('li#resource_' + resource + ' li.operation div.content').each(function() {
Docs.collapseOperation($(this));
});
},
expandOperation: function(elem) {
elem.slideDown();
},
collapseOperation: function(elem) {
elem.slideUp();
}
};

View File

@@ -0,0 +1,11 @@
<div class='container' id='resources_container'>
<ul id='resources'>
</ul>
<div class="footer">
<br>
<br>
<h4 style="color: #999">[<span style="font-variant: small-caps">base url</span>: {{basePath}}]</h4>
</div>
</div>

View File

@@ -0,0 +1,59 @@
<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">{{pathJson}}</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}}
<form accept-charset='UTF-8' action='#' class='sandbox' method='post'>
<div style='margin:0;padding:0;display:inline'></div>
<h4>Parameters</h4>
<table class='fullwidth'>
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
<th>Description</th>
</tr>
</thead>
<tbody class="operation-params">
</tbody>
</table>
{{#if isGetMethod}}
<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='http://swagger.wordnik.com/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>

View File

@@ -0,0 +1,6 @@
<td class='code'>{{name}}</td>
<td>
<input minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
</td>
<td width='500'>{{description}}</td>

View File

@@ -0,0 +1,21 @@
<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>
</td>
<td width='500'>{{description}}</td>

View File

@@ -0,0 +1,4 @@
<td class='code'>{{name}}</td>
<td>-</td>
<td width='500'>{{description}}</td>

View File

@@ -0,0 +1,4 @@
<td class='code required'>{{name}}</td>
<td>-</td>
<td width='500'>{{description}}</td>

View File

@@ -0,0 +1,7 @@
<td class='code required'>{{name}}</td>
<td>
<input class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/>
</td>
<td width='500'>
<strong>{{description}}</strong>
</td>

View File

@@ -0,0 +1,27 @@
<div class='heading'>
<h2>
<a href='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">/{{name}}</a>
</h2>
<ul class='options'>
<li>
<a href='#!/{{name}}' id='endpointListTogger_{{name}}'
onclick="Docs.toggleEndpointListForResource('{{name}}');">Show/Hide</a>
</li>
<li>
<a href='#' onclick="Docs.collapseOperationsForResource('{{name}}'); return false;">
List Operations
</a>
</li>
<li>
<a href='#' onclick="Docs.expandOperationsForResource('{{name}}'); return false;">
Expand Operations
</a>
</li>
<li>
<a href='{{url}}'>Raw</a>
</li>
</ul>
</div>
<ul class='endpoints' id='{{name}}_endpoint_list' style='display:none'>
</ul>