UI improvements for parameters (input and read-only) and model description.

Uses changes to swagger.js (swagger-client).
This commit is contained in:
Pepijn de Geus
2013-02-27 17:01:25 +01:00
parent 1a017d46a5
commit d205753044
8 changed files with 91 additions and 56 deletions

View File

@@ -133,9 +133,15 @@ div.heading_with_menu ul {
margin-top: 10px; margin-top: 10px;
} }
input.parameter {
width: 300px;
border: 1px solid #aaa;
}
.body-textarea { .body-textarea {
width: 300px; width: 300px;
height: 100px; height: 100px;
border: 1px solid #aaa;
} }
p { p {
@@ -1509,12 +1515,24 @@ body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operatio
font-size: 1em; font-size: 1em;
line-height: 1.5em; line-height: 1.5em;
} }
.model-signature .description span {
.model-signature .description div {
font-size: 0.9em; font-size: 0.9em;
line-height: 1.5em; line-height: 1.5em;
margin-left: 1em;
} }
.model-signature .description span:nth-child(odd) { color:#333; }
.model-signature .description span:nth-child(even) { color:#C5862B; } .model-signature .description .strong {
font-weight: bold;
color: #000;
font-size: .9em;
}
.model-signature .description .stronger {
font-weight: bold;
color: #000;
}
.model-signature .signature-nav a { .model-signature .signature-nav a {
text-decoration: none; text-decoration: none;
color: #AAA; color: #AAA;
@@ -1551,24 +1569,16 @@ body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operatio
} }
.model-signature ul.signature-nav { .model-signature ul.signature-nav {
float: none; display: block;
clear: both;
overflow: hidden;
margin: 0; margin: 0;
padding: 0; padding: 0;
display: block;
clear: none;
float: right;
margin-right: 5px;
margin-bottom: 5px;
} }
.model-signature ul.signature-nav li { .model-signature ul.signature-nav li {
float: left; float: left;
clear: none; margin: 0 5px 5px 0;
margin: 0; padding: 2px 5px 2px 0;
padding: 2px 10px; border-right: 1px solid #ddd;
border-right: 1px solid #dddddd;
} }
.model-signature ul.signature-nav li:last-child { .model-signature ul.signature-nav li:last-child {
@@ -1576,10 +1586,29 @@ body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operatio
border-right: none; border-right: none;
} }
.model-signature .propName {
font-weight: bold;
}
.model-signature .propType {
color: #5555aa;
}
.model-signature .propOptKey {
font-style: italic;
}
.model-signature .propOpt {
color: #555;
}
pre code { pre code {
background: none; background: none;
} }
.content pre {
font-size: 12px;
margin-top: 5px;
padding: 5px;
}
.content > .content-type > div > label { .content > .content-type > div > label {
clear: both; clear: both;
display: block; display: block;
@@ -1588,3 +1617,27 @@ pre code {
margin: 0; margin: 0;
padding: 15px 0 5px 0px; padding: 15px 0 5px 0px;
} }
.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;
}

View File

@@ -13,38 +13,12 @@
<script src='lib/underscore-min.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/backbone-min.js' type='text/javascript'></script>
<script src='lib/swagger.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='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script> <script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<style type="text/css"> <script type="text/javascript">
.swagger-ui-wrap { $(function () {
max-width: 960px; window.swaggerUi = new SwaggerUi({
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.swaggerUi = new SwaggerUi({
discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json", discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",
apiKey:"special-key", apiKey:"special-key",
dom_id:"swagger-ui-container", dom_id:"swagger-ui-container",

View File

@@ -47,7 +47,7 @@
{{/if}} {{/if}}
{{#if errorResponses}} {{#if errorResponses}}
<div style='margin:0;padding:0;display:inline'></div> <div style='margin:0;padding:0;display:inline'></div>
<h4>Status Codes</h4> <h4>Error Status Codes</h4>
<table class='fullwidth'> <table class='fullwidth'>
<thead> <thead>
<tr> <tr>

View File

@@ -15,9 +15,9 @@
{{/if}} {{/if}}
{{else}} {{else}}
{{#if defaultValue}} {{#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}} {{else}}
<input minlength='0' name='{{name}}' placeholder='' type='text' value=''/> <input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
{{/if}} {{/if}}
{{/if}} {{/if}}

View File

@@ -1,6 +1,6 @@
<td class='code'>{{name}}</td> <td class='code'>{{name}}</td>
<td> <td>
<select name='{{name}}'> <select class='parameter' name='{{name}}'>
{{#if required}} {{#if required}}
{{else}} {{else}}
{{#if defaultValue}} {{#if defaultValue}}

View File

@@ -3,7 +3,11 @@
{{#if isBody}} {{#if isBody}}
<textarea class='body-textarea' readonly='readonly' name='{{name}}'>{{defaultValue}}</textarea> <textarea class='body-textarea' readonly='readonly' name='{{name}}'>{{defaultValue}}</textarea>
{{else}} {{else}}
{{defaultValue}} {{#if defaultValue}}
{{defaultValue}}
{{else}}
(empty)
{{/if}}
{{/if}} {{/if}}
</td> </td>
<td>{{{description}}}</td> <td>{{{description}}}</td>

View File

@@ -3,7 +3,11 @@
{{#if isBody}} {{#if isBody}}
<textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='{{name}}'>{{defaultValue}}</textarea> <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='{{name}}'>{{defaultValue}}</textarea>
{{else}} {{else}}
{{defaultValue}} {{#if defaultValue}}
{{defaultValue}}
{{else}}
(empty)
{{/if}}
{{/if}} {{/if}}
</td> </td>
<td>{{{description}}}</td> <td>{{{description}}}</td>

View File

@@ -14,12 +14,12 @@
{{/if}} {{/if}}
{{else}} {{else}}
{{#if isFile}} {{#if isFile}}
<input class='required' type='file' name='{{name}}'/> <input class='parameter' class='required' type='file' name='{{name}}'/>
{{else}} {{else}}
{{#if defaultValue}} {{#if defaultValue}}
<input class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{defaultValue}}'/> <input class='parameter' class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{defaultValue}}'/>
{{else}} {{else}}
<input class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/> <input class='parameter' class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/>
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}