Skip to content

Commit

Permalink
Fix sourcey#37 display example with type in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
auscaster committed Mar 1, 2017
1 parent a032239 commit c716b47
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
11 changes: 8 additions & 3 deletions app/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ var common = {
Object.keys(cloned).forEach(function(propName) {
var prop = cloned[propName];
if (prop.type) {
cloned[propName] = prop.type;
if (prop.format) {
cloned[propName] += ('(' + prop.format + ')');
if (prop.example) {
cloned[propName] = prop.example;
}
else {
cloned[propName] = prop.type;
if (prop.format) {
cloned[propName] += ('(' + prop.format + ')');
}
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spectacle-docs",
"version": "0.7.0",
"version": "0.7.2",
"description": "Generate beautiful static API documentation from OpenAPI/Swagger 2.0 specifications",
"preferGlobal": true,
"bin": {
Expand Down
14 changes: 7 additions & 7 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ <h5>Request Example</h5>
<span class="hljs-attr">&quot;$ref&quot;</span>: <span class="hljs-string"><a href="#definition-Category">&quot;#/definitions/Category&quot;</a></span>
},
<span class="hljs-attr">&quot;id&quot;</span>: <span class="hljs-string">&quot;integer(int64)&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;Gorgonzola&quot;</span>,
<span class="hljs-attr">&quot;photoUrls&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>,
<span class="hljs-attr">&quot;status&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;tags&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>
Expand Down Expand Up @@ -294,7 +294,7 @@ <h5>Response Example
<span class="hljs-attr">&quot;$ref&quot;</span>: <span class="hljs-string"><a href="#definition-Category">&quot;#/definitions/Category&quot;</a></span>
},
<span class="hljs-attr">&quot;id&quot;</span>: <span class="hljs-string">&quot;integer(int64)&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;Gorgonzola&quot;</span>,
<span class="hljs-attr">&quot;photoUrls&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>,
<span class="hljs-attr">&quot;status&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;tags&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>
Expand Down Expand Up @@ -373,7 +373,7 @@ <h5>Request Example</h5>
<span class="hljs-attr">&quot;$ref&quot;</span>: <span class="hljs-string"><a href="#definition-Category">&quot;#/definitions/Category&quot;</a></span>
},
<span class="hljs-attr">&quot;id&quot;</span>: <span class="hljs-string">&quot;integer(int64)&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;Gorgonzola&quot;</span>,
<span class="hljs-attr">&quot;photoUrls&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>,
<span class="hljs-attr">&quot;status&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;tags&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>
Expand Down Expand Up @@ -532,7 +532,7 @@ <h5>Response Example
<span class="hljs-attr">&quot;$ref&quot;</span>: <span class="hljs-string"><a href="#definition-Category">&quot;#/definitions/Category&quot;</a></span>
},
<span class="hljs-attr">&quot;id&quot;</span>: <span class="hljs-string">&quot;integer(int64)&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;Gorgonzola&quot;</span>,
<span class="hljs-attr">&quot;photoUrls&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>,
<span class="hljs-attr">&quot;status&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;tags&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>
Expand Down Expand Up @@ -677,7 +677,7 @@ <h5>Response Example
<span class="hljs-attr">&quot;$ref&quot;</span>: <span class="hljs-string"><a href="#definition-Category">&quot;#/definitions/Category&quot;</a></span>
},
<span class="hljs-attr">&quot;id&quot;</span>: <span class="hljs-string">&quot;integer(int64)&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;Gorgonzola&quot;</span>,
<span class="hljs-attr">&quot;photoUrls&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>,
<span class="hljs-attr">&quot;status&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;tags&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>
Expand Down Expand Up @@ -1112,7 +1112,7 @@ <h5>Response Example
<span class="hljs-attr">&quot;$ref&quot;</span>: <span class="hljs-string"><a href="#definition-Category">&quot;#/definitions/Category&quot;</a></span>
},
<span class="hljs-attr">&quot;id&quot;</span>: <span class="hljs-string">&quot;integer(int64)&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;Gorgonzola&quot;</span>,
<span class="hljs-attr">&quot;photoUrls&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>,
<span class="hljs-attr">&quot;status&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;tags&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>
Expand Down Expand Up @@ -1271,7 +1271,7 @@ <h5>Response Example
<span class="hljs-attr">&quot;$ref&quot;</span>: <span class="hljs-string"><a href="#definition-Category">&quot;#/definitions/Category&quot;</a></span>
},
<span class="hljs-attr">&quot;id&quot;</span>: <span class="hljs-string">&quot;integer(int64)&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;Gorgonzola&quot;</span>,
<span class="hljs-attr">&quot;photoUrls&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>,
<span class="hljs-attr">&quot;status&quot;</span>: <span class="hljs-string">&quot;string&quot;</span>,
<span class="hljs-attr">&quot;tags&quot;</span>: <span class="hljs-string">&quot;array&quot;</span>
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/cheese.json
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@
},
"name": {
"type": "string",
"example": "doggie"
"example": "Gorgonzola"
},
"photoUrls": {
"type": "array",
Expand Down

0 comments on commit c716b47

Please sign in to comment.