mirror of https://github.com/lukechilds/docs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
357 lines
15 KiB
357 lines
15 KiB
mixin TryMe(action)
|
|
//- Give a "try-me" link for the public api endpoint
|
|
- var myUri = action.uriTemplate
|
|
- action.parameters.forEach( function (x) { myUri = myUri.replace( "{" + x.name + "}", x.example) } )
|
|
.title
|
|
strong
|
|
h4
|
|
div
|
|
div
|
|
span.method(class="badge get",style="float:left")
|
|
a.method(href=myUri, style="color:rgb(51, 122, 183);font-size:12pt")
|
|
= "Try It!"
|
|
|
|
|
p
|
|
div
|
|
|
|
|
|
|
mixin Badge(method)
|
|
//- Draw a badge for a given HTTP method
|
|
case method
|
|
when 'GET'
|
|
span.badge.get: i.fa.fa-arrow-down
|
|
when 'HEAD'
|
|
span.badge.head: i.fa.fa-info-circle
|
|
when 'OPTIONS'
|
|
span.badge.options: i.fa.fa-dot-circle-o
|
|
when 'POST'
|
|
span.badge.post: i.fa.fa-plus
|
|
when 'PUT'
|
|
span.badge.put: i.fa.fa-pencil
|
|
when 'PATCH'
|
|
span.badge.patch: i.fa.fa-pencil
|
|
when 'DELETE'
|
|
span.badge.delete: i.fa.fa-times
|
|
default
|
|
span.badge: i.fa.fa-dot-circle-o
|
|
|
|
mixin Nav(onlyPublic)
|
|
//- Draw a navigation bar, which includes links to individual
|
|
//- resources and actions.
|
|
nav
|
|
if self.api.navItems && self.api.navItems.length
|
|
.resource-group
|
|
.heading
|
|
.chevron
|
|
i.open.fa.fa-angle-down
|
|
a(href='#top') Overview
|
|
.collapse-content
|
|
ul: each item in self.api.navItems
|
|
li
|
|
a(href=item[1])!= item[0]
|
|
- if (onlyPublic){
|
|
- myGroups = self.api.resourceGroups.filter( filter_public_resourcegroups )
|
|
- }else{
|
|
- myGroups = self.api.resourceGroups.filter( filter_core_resourcegroups )
|
|
- }
|
|
each resourceGroup in myGroups || []
|
|
.resource-group
|
|
.heading
|
|
.chevron
|
|
i.open.fa.fa-angle-down
|
|
a(href=resourceGroup.elementLink)!= resourceGroup.name || 'Resource Group'
|
|
.collapse-content
|
|
ul
|
|
each item in resourceGroup.navItems || []
|
|
li
|
|
a(href=item[1])!= item[0]
|
|
- if (onlyPublic){
|
|
- myResources = resourceGroup.resources.filter( filter_public_resources )
|
|
- }else{
|
|
- myResources = resourceGroup.resources.filter( filter_core_resources )
|
|
- }
|
|
each resource in myResources || []
|
|
li
|
|
- if (onlyPublic){
|
|
- myActions = resource.actions.filter( filter_public_actions )
|
|
- }else{
|
|
- myActions = resource.actions.filter( filter_core_actions )
|
|
- }
|
|
if !self.condenseNav || (myActions.length != 1)
|
|
a(href=resource.elementLink)!= resource.name || 'Resource'
|
|
ul: each action in myActions || []
|
|
li: a(href=resource.elementLink)
|
|
+Badge(action.method)
|
|
!= action.name || action.method + ' ' + (action.attributes && action.attributes.uriTemplate || resource.uriTemplate)
|
|
else
|
|
- var action = myActions[0]
|
|
a(href=resource.elementLink)
|
|
+Badge(action.method)
|
|
!= action.name || resource.name || action.method + ' ' + (action.attributes && action.attributes.uriTemplate || resource.uriTemplate)
|
|
//- Link to the API hostname, e.g. api.yourcompany.com
|
|
each meta in self.api.metadata || {}
|
|
if meta.name == 'HOST'
|
|
p(style="text-align: center; word-wrap: break-word;")
|
|
a(href=meta.value)= meta.value
|
|
|
|
mixin Parameters(params)
|
|
//- Draw a definition list of parameter names, types, defaults,
|
|
//- examples and descriptions.
|
|
.title
|
|
strong URI Parameters
|
|
.collapse-button.show
|
|
span.close Hide
|
|
span.open Show
|
|
.collapse-content
|
|
dl.inner: each param in params || []
|
|
dt= self.urldec(param.name)
|
|
dd
|
|
code= param.type || 'string'
|
|
|
|
|
if param.required
|
|
span.required (required)
|
|
else
|
|
span (optional)
|
|
|
|
|
if param.default
|
|
span.text-info.default
|
|
strong Default:
|
|
span= param.default
|
|
|
|
|
if param.example
|
|
span.text-muted.example
|
|
strong Example:
|
|
span= param.example
|
|
!= self.markdown(param.description)
|
|
if param.values.length
|
|
p.choices
|
|
strong Choices:
|
|
each value in param.values
|
|
code= self.urldec(value.value)
|
|
= ' '
|
|
|
|
mixin RequestResponse(title, request, collapse)
|
|
.title
|
|
strong
|
|
= title
|
|
if request.name
|
|
|
|
|
code= request.name
|
|
if collapse && request.hasContent
|
|
.collapse-button
|
|
span.close Hide
|
|
span.open Show
|
|
+RequestResponseBody(request, collapse)
|
|
|
|
mixin RequestResponseBody(request, collapse, showBlank)
|
|
if request.hasContent || showBlank
|
|
div(class=collapse ? 'collapse-content' : ''): .inner
|
|
if request.description
|
|
.description!= self.markdown(request.description)
|
|
|
|
if Object.keys(request.headers).length
|
|
h5 Headers
|
|
pre: code
|
|
each item, index in request.headers
|
|
!= self.highlight(item.name + ': ' + item.value, 'http')
|
|
if index < request.headers.length - 1
|
|
br
|
|
div(style="height: 1px;")
|
|
if request.body
|
|
h5 Body
|
|
pre: code
|
|
!= self.highlight(request.body, null, ['json', 'yaml', 'xml', 'javascript'])
|
|
div(style="height: 1px;")
|
|
if request.schema
|
|
h5 Schema
|
|
pre: code
|
|
!= self.highlight(request.schema, null, ['json', 'yaml', 'xml'])
|
|
div(style="height: 1px;")
|
|
if !request.hasContent
|
|
.description.text-muted This response has no content.
|
|
div(style="height: 1px;")
|
|
|
|
mixin Examples(resourceGroup, resource, action)
|
|
each example in action.examples
|
|
each request in example.requests
|
|
+RequestResponse('Request', request, true)
|
|
each response in example.responses
|
|
+RequestResponse('Response', response, true)
|
|
|
|
mixin Content()
|
|
//- Page header and API description
|
|
header
|
|
h1#top!= self.api.name || 'API Documentation'
|
|
|
|
if self.api.descriptionHtml
|
|
!= self.api.descriptionHtml
|
|
|
|
//- Loop through and display information about all the resource
|
|
//- groups, resources, and actions.
|
|
each resourceGroup in self.api.resourceGroups || []
|
|
section.resource-group(id=resourceGroup.elementId)
|
|
h2.group-heading
|
|
!= resourceGroup.name || 'Resource Group'
|
|
= " "
|
|
a.permalink(href=resourceGroup.elementLink) ¶
|
|
if resourceGroup.descriptionHtml
|
|
!= resourceGroup.descriptionHtml
|
|
|
|
each resource in resourceGroup.resources || []
|
|
.resource(id=resource.elementId)
|
|
h3.resource-heading
|
|
!= resource.name || ((resource.actions[0] != null) && resource.actions[0].name) || 'Resource'
|
|
= " "
|
|
a.permalink(href=resource.elementLink) ¶
|
|
if resource.description
|
|
!= self.markdown(resource.description)
|
|
|
|
each action in resource.actions || []
|
|
.action(class=action.methodLower, id=action.elementId)
|
|
h4.action-heading
|
|
.name!= action.name
|
|
a.method(class=action.methodLower, href=action.elementLink)
|
|
= action.method
|
|
code.uri= self.urldec(action.uriTemplate)
|
|
if action.description
|
|
!= self.markdown(action.description)
|
|
|
|
h4 Example URI
|
|
.definition
|
|
span.method(class=action.methodLower)= action.method
|
|
|
|
|
span.uri
|
|
span.hostname= self.api.host
|
|
!= action.colorizedUriTemplate
|
|
|
|
//- A list of sub-sections for parameters, requests
|
|
//- and responses.
|
|
if action.parameters.length
|
|
+Parameters(action.parameters)
|
|
if action.examples
|
|
+Examples(resourceGroup, resource, action)
|
|
|
|
- function filter_public_actions(x){
|
|
- return (x.description.includes('+ Public Endpoint') || x.description.includes('+ Public Only Endpoint'))
|
|
- }
|
|
- function filter_public_resources(x){
|
|
- return (x.actions.filter( filter_public_actions ).length > 0)
|
|
- }
|
|
- function filter_public_resourcegroups(x){
|
|
- return (x.resources.filter( filter_public_resources ).length > 0)
|
|
- }
|
|
- function filter_core_actions(x){
|
|
- return !(x.description.includes('+ Public Only Endpoint'))
|
|
- }
|
|
- function filter_core_resources(x){
|
|
- return (x.actions.filter( filter_core_actions ).length > 0)
|
|
- }
|
|
- function filter_core_resourcegroups(x){
|
|
- return (x.resources.filter( filter_core_resources ).length > 0)
|
|
- }
|
|
|
|
mixin ContentTriple(onlyPublic, descriptionHtml)
|
|
|
|
.right
|
|
h5 API Endpoint
|
|
a(href=self.api.host)= self.api.host
|
|
.middle
|
|
if descriptionHtml
|
|
!= descriptionHtml
|
|
|
|
//- Loop through and display information about all the resource
|
|
//- groups, resources, and actions.
|
|
- if (onlyPublic){
|
|
- myGroups = self.api.resourceGroups.filter( filter_public_resourcegroups )
|
|
- }else{
|
|
- myGroups = self.api.resourceGroups.filter( filter_core_resourcegroups )
|
|
- }
|
|
each resourceGroup in myGroups || []
|
|
.middle
|
|
section.resource-group(id=resourceGroup.elementId)
|
|
h2.group-heading
|
|
!= resourceGroup.name || 'Resource Group'
|
|
= " "
|
|
a.permalink(href=resourceGroup.elementLink) ¶
|
|
if resourceGroup.descriptionHtml
|
|
!= resourceGroup.descriptionHtml
|
|
|
|
- if (onlyPublic){
|
|
- myResources = resourceGroup.resources.filter( filter_public_resources )
|
|
- }else{
|
|
- myResources = resourceGroup.resources.filter( filter_core_resources )
|
|
- }
|
|
each resource in myResources || []
|
|
if resource.public != null
|
|
.middle
|
|
.resource(id=resource.elementId)
|
|
a.permalink(href=resource.elementLink)
|
|
h3.resource-heading
|
|
!= resource.name || ((resource.actions[0] != null) && resource.actions[0].name) || 'Resource'
|
|
= " "
|
|
¶
|
|
if resource.description
|
|
!= self.markdown(resource.description)
|
|
|
|
- if (onlyPublic){
|
|
- myActions = resource.actions.filter( filter_public_actions )
|
|
- }else{
|
|
- myActions = resource.actions.filter( filter_core_actions )
|
|
- }
|
|
each action in myActions || []
|
|
if action.examples
|
|
.right
|
|
.definition
|
|
span.method(class=action.methodLower)= action.method
|
|
|
|
|
span.uri
|
|
span.hostname= self.api.host
|
|
!= action.colorizedUriTemplate
|
|
.tabs
|
|
if action.hasRequest
|
|
.example-names
|
|
span Requests
|
|
- var requestCount = 0
|
|
each example in action.examples
|
|
each request in example.requests
|
|
- requestCount++
|
|
span.tab-button= request.name || 'example ' + requestCount
|
|
each example in action.examples
|
|
each request in example.requests
|
|
.tab
|
|
+RequestResponseBody(request, false, true)
|
|
.tabs
|
|
.example-names
|
|
span Responses
|
|
each response in example.responses
|
|
span.tab-button= response.name
|
|
each response in example.responses
|
|
.tab
|
|
+RequestResponseBody(response, false, true)
|
|
else
|
|
each example in action.examples
|
|
.tabs
|
|
.example-names
|
|
span Responses
|
|
each response in example.responses
|
|
span.tab-button= response.name
|
|
each response in example.responses
|
|
.tab
|
|
+RequestResponseBody(response, false, true)
|
|
.middle
|
|
.action(class=action.methodLower, id=action.elementId)
|
|
h4.action-heading
|
|
.name!= action.name
|
|
a.method(class=action.methodLower, href=action.elementLink)
|
|
= action.method
|
|
code.uri= self.urldec(action.uriTemplate)
|
|
if action.description
|
|
!= self.markdown(action.description)
|
|
|
|
//- A list of sub-sections for parameters, requests
|
|
//- and responses.
|
|
if action.parameters.length
|
|
+Parameters(action.parameters)
|
|
if onlyPublic
|
|
+TryMe(action)
|
|
hr.split
|
|
|