This is an automated email from the ASF dual-hosted git repository. jamesbognar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push: new 69f4dd1 Swagger UI enhancements. 69f4dd1 is described below commit 69f4dd14f3a764c0f6b8180b3e3e47ffd1dab460 Author: JamesBognar <jamesbog...@apache.org> AuthorDate: Sun Mar 25 17:26:08 2018 -0400 Swagger UI enhancements. --- .../apache/juneau/dto/swagger/ui/SwaggerUI.java | 8 +- .../examples/rest/petstore/PetStoreResource.java | 8 +- .../examples/rest/petstore/PetStoreResource.json | 113 ++------------------- .../juneau/examples/rest/RootContentTest.java | 4 +- .../apache/juneau/rest/widget/MenuItemWidget.java | 2 +- .../org/apache/juneau/rest/styles/light.css | 7 ++ .../org/apache/juneau/rest/styles/original.css | 7 ++ 7 files changed, 37 insertions(+), 112 deletions(-) diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ui/SwaggerUI.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ui/SwaggerUI.java index 2f86fde..8e93cf3 100644 --- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ui/SwaggerUI.java +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ui/SwaggerUI.java @@ -20,6 +20,7 @@ import org.apache.juneau.*; import org.apache.juneau.dto.html5.*; import org.apache.juneau.dto.swagger.*; import org.apache.juneau.http.*; +import org.apache.juneau.internal.*; import org.apache.juneau.transform.*; import org.apache.juneau.utils.*; @@ -69,8 +70,11 @@ public class SwaggerUI extends PojoSwap<Swagger,Div> { if (info.hasVersion()) table.child(tr(th("Version:"),td(info.getVersion()))); - if (info.hasTermsOfService()) - table.child(tr(th("Terms of Service:"),td(a(info.getTermsOfService(), info.getTermsOfService())))); + if (info.hasTermsOfService()) { + String tos = info.getTermsOfService(); + Object child = StringUtils.isUri(tos) ? a(tos, tos) : tos; + table.child(tr(th("Terms of Service:"),td(child))); + } Contact c = info.getContact(); if (c != null) { diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java index 1a385e1..8e595f4 100644 --- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java +++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java @@ -26,9 +26,8 @@ import org.apache.juneau.rest.widget.*; path="/petstore2", title="Swagger Petstore", description= - "This is a sample server Petstore server." - + "<br>You can find out more about Swagger at <a class='link' href='http://swagger.io'>http://swagger.io</a> or on <a class='link' href='http://swagger.io/irc'>irc.freenode.net#swagger</a>." - + "<br>For this sample, you can use the api key `special-key` to test the authorization filters.", + "This is a sample server Petstore server based on the Petstore sample at Swagger.io." + + "<br>You can find out more about Swagger at <a class='link' href='http://swagger.io'>http://swagger.io</a>.", htmldoc=@HtmlDoc( widgets={ ContentTypeMenuItem.class, @@ -50,7 +49,7 @@ public class PetStoreResource extends BasicRestServletJena { @RestMethod( name="GET", path="/", - summary="Top-level page" + summary="Navigation page" ) public ResourceDescription[] getTopPage() { return new ResourceDescription[] { @@ -123,7 +122,6 @@ public class PetStoreResource extends BasicRestServletJena { swagger={ "tags:['pet'],", "parameters:[", -// "{ in:'body', description:'Pet object that needs to be added to the store', required:true, schema:{ $ref:'#/definitions/Pet'} }", "{ in:'body', description:'Pet object that needs to be added to the store', required:true }", "],", "responses:{", diff --git a/juneau-examples/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/petstore/PetStoreResource.json b/juneau-examples/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/petstore/PetStoreResource.json index f525b66..abf4395 100644 --- a/juneau-examples/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/petstore/PetStoreResource.json +++ b/juneau-examples/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/petstore/PetStoreResource.json @@ -14,29 +14,31 @@ { "swagger": "2.0", "info": { - "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io).", "version": "1.0.0", "title": "Swagger Petstore", - "termsOfService": "http://swagger.io/terms/", + "termsOfService": "You are on your own.", "contact": { - "name": "John Smith", - "email": "johnsm...@swagger.io", - "url": "http://swagger.io" + "name": "Juneau Development Team", + "email": "d...@juneau.apache.org", + "url": "http://juneau.apache.org" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, - "host": "petstore.swagger.io", - "basePath": "/v2", + "externalDocs": { + "description": "Find out more about Juneau", + "url": "http://juneau.apache.org" + }, "tags": [ { "name": "pet", "description": "Everything about your Pets", "externalDocs": { "description": "Find out more", - "url": "http://swagger.io" + "url": "http://juneau.apache.org" } }, { @@ -48,7 +50,7 @@ "description": "Operations about user", "externalDocs": { "description": "Find out more about our store", - "url": "http://swagger.io" + "url": "http://juneau.apache.org" } } ], @@ -107,12 +109,6 @@ }, "xml": { "name": "Order" - }, - "x-examples": { - "application/json": "{\n\tfoo: 'bar',\n\tbaz: 123\n}", - "text/xml": "<foo>bar</foo>", - "text/html": "<table>foo</table>", - "octal-messagepack": "12 34 56 AB CD EF" } }, "User": { @@ -148,12 +144,6 @@ }, "xml": { "name": "User" - }, - "x-examples": { - "application/json": "{\n\tfoo: 'bar',\n\tbaz: 123\n}", - "text/xml": "<foo>bar</foo>", - "text/html": "<table>foo</table>", - "octal-messagepack": "12 34 56 AB CD EF" } }, "Category": { @@ -169,12 +159,6 @@ }, "xml": { "name": "Category" - }, - "x-examples": { - "application/json": "{\n\tfoo: 'bar',\n\tbaz: 123,\n\tflags:[\n\t\t'f1',\n\t\t'f1',\n\t\t'f3'\n\t]\n}", - "text/xml": "<foo>bar</foo>", - "text/html": "<table>foo</table>", - "octal-messagepack": "12 34 56 AB CD EF" } }, "Tag": { @@ -190,73 +174,8 @@ }, "xml": { "name": "Tag" - }, - "x-examples": { - "application/json": "{\n\tfoo: 'bar',\n\tbaz: 123\n}", - "text/xml": "<foo>bar</foo>", - "text/html": "<table>foo</table>", - "octal-messagepack": "12 34 56 AB CD EF" } }, -/* "Pet": { - "type": "object", - "required": [ - "name", - "photoUrls" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "category": { - "$ref": "#/definitions/Category" - }, - "name": { - "type": "string", - "example": "doggie" - }, - "photoUrls": { - "type": "array", - "xml": { - "name": "photoUrl", - "wrapped": true - }, - "items": { - "type": "string" - } - }, - "tags": { - "type": "array", - "xml": { - "name": "tag", - "wrapped": true - }, - "items": { - "$ref": "#/definitions/Tag" - } - }, - "status": { - "type": "string", - "description": "pet status in the store", - "enum": [ - "available", - "pending", - "sold" - ] - } - }, - "xml": { - "name": "Pet" - }, - "x-examples": { - "application/json": "{\n\tfoo: 'bar',\n\tbaz: 123,\n\tflags:[\n\t\t'f1',\n\t\t'f1',\n\t\t'f3'\n\t]\n}", - "text/xml": "<foo>bar</foo>", - "text/html": "<table>foo</table>", - "octal-messagepack": "12 34 56 AB CD EF" - } - }, -*/ "ApiResponse": { "type": "object", "properties": { @@ -270,17 +189,7 @@ "message": { "type": "string" } - }, - "x-examples": { - "application/json": "{\n\tfoo: 'bar',\n\tbaz: 123\n}", - "text/xml": "<foo>bar</foo>", - "text/html": "<table>foo</table>", - "octal-messagepack": "12 34 56 AB CD EF" } } - }, - "externalDocs": { - "description": "Find out more about Swagger", - "url": "http://swagger.io" } } \ No newline at end of file diff --git a/juneau-examples/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/RootContentTest.java b/juneau-examples/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/RootContentTest.java index c8dd710..bfc173c 100644 --- a/juneau-examples/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/RootContentTest.java +++ b/juneau-examples/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/RootContentTest.java @@ -47,8 +47,8 @@ public class RootContentTest extends ContentComboTestBase { new ComboInput("HTML-nav", "/", MediaType.HTML, "<nav>", "<a href='/?method=OPTIONS'>options</a>", - "<a class='link' onclick='menuClick(this)'>content-type</a>", - "<a class='link' onclick='menuClick(this)'>styles</a>", + "<a onclick='menuClick(this)'>content-type</a>", + "<a onclick='menuClick(this)'>styles</a>", "<a href='https://github.com/apache/juneau/blob/master/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java'>source</a>" ) }, diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java index 01e6e80..344b256 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java @@ -84,7 +84,7 @@ public abstract class MenuItemWidget extends Widget { StringBuilder sb = new StringBuilder(); sb.append("" + "<div class='menu-item'>" - + "\n\t<a class='link' onclick='menuClick(this)'>"+getLabel(req)+"</a>" + + "\n\t<a onclick='menuClick(this)'>"+getLabel(req)+"</a>" + "\n\t<div class='popup-content'>\n" ); Object o = getContent(req); diff --git a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/light.css b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/light.css index d5a1e28..aa91f98 100644 --- a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/light.css +++ b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/light.css @@ -128,6 +128,13 @@ article * { font-size: 9pt; } +article div.data { + padding: 0px; + margin: 0px; + display: inline-block; + font-family: sans-serif; +} + article table { border: none; width: 100%; diff --git a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/original.css b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/original.css index bad8907..2052281 100644 --- a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/original.css +++ b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/original.css @@ -112,6 +112,13 @@ aside { padding: 20px 20px; } +article div.data { + padding: 0px; + margin: 0px; + display: inline-block; + font-family: sans-serif; +} + article table { border:1px solid #CCCC99; border-collapse: collapse; -- To stop receiving notification emails like this one, please contact jamesbog...@apache.org.