juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [juneau] branch master updated: Swagger UI updates.
Date Sun, 25 Mar 2018 19:20:42 GMT
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 ad8e540  Swagger UI updates.
ad8e540 is described below

commit ad8e54059d729070c7b25f75dc61eac5fc69d0ca
Author: JamesBognar <jamesbognar@apache.org>
AuthorDate: Sun Mar 25 15:20:21 2018 -0400

    Swagger UI updates.
---
 .../org/apache/juneau/dto/swagger/Contact.java     | 30 ++++++-
 .../juneau/dto/swagger/ExternalDocumentation.java  | 21 ++++-
 .../java/org/apache/juneau/dto/swagger/Info.java   | 38 +++++++++
 .../org/apache/juneau/dto/swagger/License.java     | 22 ++++-
 .../org/apache/juneau/dto/swagger/Operation.java   | 94 +++++++++++++---------
 .../apache/juneau/dto/swagger/ui/SwaggerUI.java    | 60 +++++++++++---
 .../org/apache/juneau/dto/swagger/ui/SwaggerUI.css | 34 ++++++++
 .../src/main/java/org/apache/juneau/ClassMeta.java | 18 ++++-
 .../examples/rest/petstore/PetStoreResource.java   | 57 +++++++++++--
 .../examples/rest/petstore/PetStoreResource.json   |  4 +-
 .../apache/juneau/rest/BasicRestInfoProvider.java  | 15 ++--
 .../org/apache/juneau/rest/BasicRestServlet.java   | 10 ++-
 .../org/apache/juneau/rest/styles/dark.css         |  4 +-
 .../org/apache/juneau/rest/styles/devops.css       |  5 +-
 .../org/apache/juneau/rest/styles/light.css        |  4 +-
 .../org/apache/juneau/rest/styles/original.css     |  2 +
 16 files changed, 345 insertions(+), 73 deletions(-)

diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Contact.java
b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Contact.java
index f1565d0..d6db1e3 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Contact.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Contact.java
@@ -13,6 +13,7 @@
 package org.apache.juneau.dto.swagger;
 
 import static org.apache.juneau.internal.BeanPropertyUtils.*;
+import static org.apache.juneau.internal.StringUtils.*;
 
 import java.net.*;
 import java.net.URI;
@@ -141,7 +142,7 @@ public class Contact extends SwaggerElement {
 	 * @return This object (for method chaining).
 	 */
 	public Contact url(Object value) {
-		return setUrl(toURI(value));
+		return setUrl(StringUtils.toURI(value));
 	}
 
 	/**
@@ -187,6 +188,33 @@ public class Contact extends SwaggerElement {
 		return setEmail(toStringVal(value));
 	}
 
+	/**
+	 * Returns <jk>true</jk> if the name property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the name property is not null or empty.
+	 */
+	public boolean hasName() {
+		return ! isEmpty(name);
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the URL property is not null.
+	 * 
+	 * @return <jk>true</jk> if the URL property is not null.
+	 */
+	public boolean hasUrl() {
+		return url != null;
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the email property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the email property is not null or empty.
+	 */
+	public boolean hasEmail() {
+		return ! isEmpty(email);
+	}
+
 	@Override /* SwaggerElement */
 	public <T> T get(String property, Class<T> type) {
 		if (property == null)
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java
b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java
index 3b2aeb3..b693f47 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java
@@ -13,6 +13,7 @@
 package org.apache.juneau.dto.swagger;
 
 import static org.apache.juneau.internal.BeanPropertyUtils.*;
+import static org.apache.juneau.internal.StringUtils.*;
 
 import java.net.*;
 import java.net.URI;
@@ -145,7 +146,25 @@ public class ExternalDocumentation extends SwaggerElement {
 	 * @return This object (for method chaining).
 	 */
 	public ExternalDocumentation url(Object value) {
-		return setUrl(toURI(value));
+		return setUrl(StringUtils.toURI(value));
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the url property is not null.
+	 * 
+	 * @return <jk>true</jk> if the url property is not null.
+	 */
+	public boolean hasUrl() {
+		return url != null;
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the description property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the description property is not null or empty.
+	 */
+	public boolean hasDescription() {
+		return ! isEmpty(description);
 	}
 
 	@Override /* SwaggerElement */
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Info.java
b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Info.java
index b77e490..5dfe36e 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Info.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Info.java
@@ -13,6 +13,7 @@
 package org.apache.juneau.dto.swagger;
 
 import static org.apache.juneau.internal.BeanPropertyUtils.*;
+import static org.apache.juneau.internal.StringUtils.*;
 
 import java.util.*;
 
@@ -342,6 +343,43 @@ public class Info extends SwaggerElement {
 		return setVersion(toStringVal(value));
 	}
 
+
+	/**
+	 * Returns <jk>true</jk> if the title property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the title property is not null or empty.
+	 */
+	public boolean hasTitle() {
+		return ! isEmpty(title);
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the description property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the description property is not null or empty.
+	 */
+	public boolean hasDescription() {
+		return ! isEmpty(description);
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the version property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the version property is not null or empty.
+	 */
+	public boolean hasVersion() {
+		return ! isEmpty(version);
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the termsOfService property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the termsOfService property is not null or empty.
+	 */
+	public boolean hasTermsOfService() {
+		return ! isEmpty(termsOfService);
+	}
+
 	@Override /* SwaggerElement */
 	public <T> T get(String property, Class<T> type) {
 		if (property == null)
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/License.java
b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/License.java
index 3ca8fb4..61ef053 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/License.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/License.java
@@ -13,6 +13,8 @@
 package org.apache.juneau.dto.swagger;
 
 import static org.apache.juneau.internal.BeanPropertyUtils.*;
+import static org.apache.juneau.internal.StringUtils.*;
+
 import java.net.*;
 import java.net.URI;
 import java.util.*;
@@ -142,7 +144,25 @@ public class License extends SwaggerElement {
 	 * @return This object (for method chaining).
 	 */
 	public License url(Object value) {
-		return setUrl(toURI(value));
+		return setUrl(StringUtils.toURI(value));
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the name property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the name property is not null or empty.
+	 */
+	public boolean hasName() {
+		return ! isEmpty(name);
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the url property is not null.
+	 * 
+	 * @return <jk>true</jk> if the url property is not null.
+	 */
+	public boolean hasUrl() {
+		return url != null;
 	}
 
 	@Override /* SwaggerElement */
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java
b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java
index e05da41..28e5de6 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java
@@ -13,6 +13,8 @@
 package org.apache.juneau.dto.swagger;
 
 import static org.apache.juneau.internal.BeanPropertyUtils.*;
+import static org.apache.juneau.internal.StringUtils.*;
+
 import java.util.*;
 
 import org.apache.juneau.annotation.*;
@@ -988,6 +990,61 @@ public class Operation extends SwaggerElement {
 		return this;
 	}
 
+	/**
+	 * Returns <jk>true</jk> if the summary property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the summary property is not null or empty.
+	 */
+	public boolean hasSummary() {
+		return ! isEmpty(summary);
+	}
+
+	/**
+	 * Returns <jk>true</jk> if the description property is not null or empty.
+	 * 
+	 * @return <jk>true</jk> if the description property is not null or empty.
+	 */
+	public boolean hasDescription() {
+		return ! isEmpty(description);
+	}
+
+	/**
+	 * Returns <jk>true</jk> if this operation has the specified tag associated
with it.
+	 * 
+	 * @param name The tag name.
+	 * @return <jk>true</jk> if this operation has the specified tag associated
with it.
+	 */
+	public boolean hasTag(String name) {
+		return tags != null && tags.contains(name);
+	}
+	
+	/**
+	 * Returns <jk>true</jk> if this operation has no tags associated with it.
+	 * 
+	 * @return <jk>true</jk> if this operation has no tags associated with it.
+	 */
+	public boolean hasNoTags() {
+		return tags == null || tags.isEmpty();
+	}
+
+	/**
+	 * Returns <jk>true</jk> if this operation has parameters associated with it.
+	 * 
+	 * @return <jk>true</jk> if this operation has parameters associated with it.
+	 */
+	public boolean hasParameters() {
+		return parameters != null && ! parameters.isEmpty();
+	}
+
+	/**
+	 * Returns <jk>true</jk> if this operation has responses associated with it.
+	 * 
+	 * @return <jk>true</jk> if this operation has responses associated with it.
+	 */
+	public boolean hasResponses() {
+		return responses != null && ! responses.isEmpty();
+	}
+
 	@Override /* SwaggerElement */
 	public <T> T get(String property, Class<T> type) {
 		if (property == null)
@@ -1049,41 +1106,4 @@ public class Operation extends SwaggerElement {
 			.appendIf(security != null, "security");
 		return new MultiSet<>(s, super.keySet());
 	}
-
-	/**
-	 * Returns <jk>true</jk> if this operation has the specified tag associated
with it.
-	 * 
-	 * @param name The tag name.
-	 * @return <jk>true</jk> if this operation has the specified tag associated
with it.
-	 */
-	public boolean hasTag(String name) {
-		return tags != null && tags.contains(name);
-	}
-	
-	/**
-	 * Returns <jk>true</jk> if this operation has no tags associated with it.
-	 * 
-	 * @return <jk>true</jk> if this operation has no tags associated with it.
-	 */
-	public boolean hasNoTags() {
-		return tags == null || tags.isEmpty();
-	}
-
-	/**
-	 * Returns <jk>true</jk> if this operation has parameters associated with it.
-	 * 
-	 * @return <jk>true</jk> if this operation has parameters associated with it.
-	 */
-	public boolean hasParameters() {
-		return parameters != null && ! parameters.isEmpty();
-	}
-
-	/**
-	 * Returns <jk>true</jk> if this operation has responses associated with it.
-	 * 
-	 * @return <jk>true</jk> if this operation has responses associated with it.
-	 */
-	public boolean hasResponses() {
-		return responses != null && ! responses.isEmpty();
-	}
 }
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 d720eea..2f86fde 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,7 +20,6 @@ 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.*;
 
@@ -40,8 +39,9 @@ public class SwaggerUI extends PojoSwap<Swagger,Div> {
 	public Div swap(BeanSession session, Swagger s) throws Exception {
 		Div outer = div(
 			style(RM.getString("SwaggerUI.css")),
-			script("text/javascript", RM.getString("SwaggerUI.js"))
-		);
+			script("text/javascript", RM.getString("SwaggerUI.js")),
+			header(s)
+		)._class("swagger-ui");
 		
 		// Operations without tags are rendered first.
 		outer.child(div()._class("tag-block tag-block-open").children(tagBlockContents(s, null)));
@@ -59,16 +59,57 @@ public class SwaggerUI extends PojoSwap<Swagger,Div> {
 		return outer;
 	}
 	
+	// Creates the informational summary before the ops.
+	private Table header(Swagger s) {
+		Table table = table()._class("header");
+		
+		Info info = s.getInfo();
+		if (info != null) {
+			
+			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()))));
+			
+			Contact c = info.getContact();
+			if (c != null) {
+				Table t2 = table();
+
+				if (c.hasName())
+					t2.child(tr(th("Name:"),td(c.getName())));
+				if (c.hasUrl())
+					t2.child(tr(th("URL:"),td(a(c.getUrl(), c.getUrl()))));
+				if (c.hasEmail())
+					t2.child(tr(th("Email:"),td(a("mailto:"+ c.getEmail(), c.getEmail()))));
+					
+				table.child(tr(th("Contact:"),td(t2)));
+			}
+			
+			License l = info.getLicense();
+			if (l != null) {
+				Object child = l.hasUrl() ? a(l.getUrl(), l.hasName() ? l.getName() : l.getUrl()) : l.getName();
+				table.child(tr(th("License:"),td(child)));
+			}
+			
+			ExternalDocumentation ed = s.getExternalDocs();
+			if (ed != null) {
+				Object child = ed.hasUrl() ? a(ed.getUrl(), ed.hasDescription() ? ed.getDescription()
: ed.getUrl()) : ed.getDescription();
+				table.child(tr(th("Docs:"),td(child)));
+			}
+		}
+		
+		return table;
+	}
+	
 	// Creates the "pet  Everything about your Pets  ext-link" header.
 	private HtmlElement tagBlockSummary(Tag t) {
 		ExternalDocumentation ed = t.getExternalDocs();
-		String edd = ed == null ? null : ed.getDescription();
-		Object extDocText = ed == null ? null : (edd != null ? edd : ed.getUrl());
 		
 		return div()._class("tag-block-summary").children(
 			span(t.getName())._class("name"),
 			span(t.getDescription())._class("description"),
-			ed == null ? null : span(a(ed.getUrl(), extDocText))._class("extdocs")
+			ed == null ? null : span(a(ed.getUrl(), ed.hasDescription() ? ed.getDescription() : ed.getUrl()))._class("extdocs")
 		).onclick("toggleTagBlock(this)");
 	}
 	
@@ -102,16 +143,15 @@ public class SwaggerUI extends PojoSwap<Swagger,Div> {
 		return div()._class("op-block-summary").children(
 			span(opName.toUpperCase())._class("method-button"),
 			span(path)._class("path"),
-			span(op.getSummary())._class("summary")
+			op.hasSummary() ? span(op.getSummary())._class("summary") : null
 		).onclick("toggleOpBlock(this)");
 	}
 
 	private Div tableContainer(Swagger s, Operation op) {
 		Div tableContainer = div()._class("table-container");
 		
-		String d = op.getDescription();
-		if (! StringUtils.isEmpty(d)) 
-			tableContainer.child(div(d)._class("op-block-description"));
+		if (op.hasDescription()) 
+			tableContainer.child(div(op.getDescription())._class("op-block-description"));
 			
 		if (op.hasParameters()) {
 			tableContainer.child(div(h4("Parameters")._class("title"))._class("op-block-section-header"));
diff --git a/juneau-core/juneau-dto/src/main/resources/org/apache/juneau/dto/swagger/ui/SwaggerUI.css
b/juneau-core/juneau-dto/src/main/resources/org/apache/juneau/dto/swagger/ui/SwaggerUI.css
index 315fd34..f2a16b3 100644
--- a/juneau-core/juneau-dto/src/main/resources/org/apache/juneau/dto/swagger/ui/SwaggerUI.css
+++ b/juneau-core/juneau-dto/src/main/resources/org/apache/juneau/dto/swagger/ui/SwaggerUI.css
@@ -13,6 +13,40 @@
  ***************************************************************************************************************************
 */
 
+.swagger-ui {	
+}
+
+/*-----------------------------------------------------------------------------------------------------------
+ - Header key-value pairs
+ ----------------------------------------------------------------------------------------------------------*/
+
+.swagger-ui table.header {
+    margin-bottom: 20px;
+	width: 95%;
+	border: none;
+}
+
+.swagger-ui table.header * {
+	font-size: 14px;
+	vertical-align: middle;
+}
+
+.swagger-ui table.header th {
+    font-weight: bold;
+    padding: 5px 10px;
+    text-align: left;
+    white-space: nowrap;
+	border: none;
+	border-radius: 3px;
+}
+
+.swagger-ui table.header td {
+	padding: 5px 10px;
+    text-align: left;
+    vertical-align: middle;
+	border: none;
+}
+
 /*-----------------------------------------------------------------------------------------------------------
  - Method buttons (e.g GET/PUT/... buttons)                                             
                  
  ----------------------------------------------------------------------------------------------------------*/
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
index 097021a..3e4e829 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
@@ -947,7 +947,23 @@ public final class ClassMeta<T> implements Type {
 				return (T)invokeMethodFuzzy(exampleMethod, null, session);
 			if (exampleField != null)
 				return (T)exampleField.get(null);
-			return example;
+			if (example != null)
+				return example;
+
+			if (isCollection()) {
+				Object element = getElementType().getExample(session);
+				if (element != null)
+					return (T)Collections.singleton(element);
+			} else if (isArray()) {
+				Object element = getElementType().getExample(session);
+				if (element != null) {
+					Object o = Array.newInstance(getElementType().innerClass, 1);
+					Array.set(o, 0, example);
+					return (T)o;
+				}
+			}
+		
+			return null;
 		} catch (Exception e) {
 			throw new ClassMetaRuntimeException(e);
 		}
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 de07c4f..1a385e1 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
@@ -16,6 +16,7 @@ import java.util.*;
 
 import org.apache.juneau.microservice.*;
 import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.labels.*;
 import org.apache.juneau.rest.widget.*;
 
 /**
@@ -24,7 +25,10 @@ import org.apache.juneau.rest.widget.*;
 @RestResource(
 	path="/petstore2",
 	title="Swagger Petstore",
-	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."
+		+ "<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.",
 	htmldoc=@HtmlDoc(
 		widgets={
 			ContentTypeMenuItem.class,
@@ -43,19 +47,62 @@ import org.apache.juneau.rest.widget.*;
 public class PetStoreResource extends BasicRestServletJena {
 	private static final long serialVersionUID = 1L;
 	
-	@RestMethod(name="GET", path="/*") 
-	public String doGet() {
-		return "Hello";
+	@RestMethod(
+		name="GET", 
+		path="/",
+		summary="Top-level page"
+	) 
+	public ResourceDescription[] getTopPage() {
+		return new ResourceDescription[] {
+			new ResourceDescription("pet", "All pets in the store"), 
+			new ResourceDescription("store", "Petstore orders"), 
+			new ResourceDescription("user", "Petstore users")
+		};
 	}
 	
 	@RestMethod(
+		name="GET",
+		path="/pet",
+		summary="All pets in the store",
+		swagger={
+			"tags:['pet']"
+		}
+	)
+	public Collection<Pet> getPets() {
+		return null;
+	}
+	
+	@RestMethod(
+		name="GET",
+		path="/store",
+		summary="Petstore orders",
+		swagger={
+			"tags:['store']"
+		}
+	)
+	public Collection<Order> getOrders() {
+		return null;
+	}
+
+	@RestMethod(
+		name="GET",
+		path="/user",
+		summary="Petstore users",
+		swagger={
+			"tags:['user']"
+		}
+	)
+	public Collection<Order> getUsers() {
+		return null;
+	}
+
+	@RestMethod(
 		name="POST", 
 		path="/pet",
 		summary="Add a new pet to the store",
 		swagger={
 			"tags:['pet'],",
 			"parameters:[",
-//				"{ in:'body', name:'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 138c141..f525b66 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
@@ -19,7 +19,9 @@
 		"title": "Swagger Petstore",
 		"termsOfService": "http://swagger.io/terms/",
 		"contact": {
-			"email": "apiteam@swagger.io"
+			"name": "John Smith",
+			"email": "johnsmith@swagger.io",
+			"url": "http://swagger.io"
 		},
 		"license": {
 			"name": "Apache 2.0",
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestInfoProvider.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestInfoProvider.java
index c729a8f..2eadfa8 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestInfoProvider.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestInfoProvider.java
@@ -389,19 +389,14 @@ public class BasicRestInfoProvider implements RestInfoProvider {
 			
 			ObjectMap okResponse = responses.getObjectMap("200");
 			
-			ClassMeta<?> cm = bs.getClassMeta(m.getReturnType());
+			ClassMeta<?> cm = bs.getClassMeta(m.getGenericReturnType());
 			
 			if ((cm.isMapOrBean() || cm.isCollectionOrArray()) && ! okResponse.containsKey("schema")
&& cm.getInnerClass() != Swagger.class) {
 				String name = cm.getSimpleName();
 				
 				if (! definitions.containsKey(name)) {
-					ObjectMap definition;
-					try {
-						definition = JsonSchemaUtils.getSchema(bs, cm);
-					} catch (Exception e1) {
-						System.err.println(cm);
-						throw e1;
-					}	
+					ObjectMap definition = JsonSchemaUtils.getSchema(bs, cm);
+					
 					Object example = cm.getExample(bs);
 					
 					if (example != null) {
@@ -709,7 +704,7 @@ public class BasicRestInfoProvider implements RestInfoProvider {
 		if (title != null)
 			return vr.resolve(title);
 		Swagger s = getSwagger(req);
-		if (s != null && s.getInfo() != null)
+		if (s != null && s.getInfo() != null && s.getInfo().hasTitle())
 			return s.getInfo().getTitle();
 		return null;
 	}
@@ -765,7 +760,7 @@ public class BasicRestInfoProvider implements RestInfoProvider {
 		if (description != null)
 			return vr.resolve(description);
 		Swagger s = getSwagger(req);
-		if (s != null && s.getInfo() != null)
+		if (s != null && s.getInfo() != null && s.getInfo().hasDescription())
 			return s.getInfo().getDescription();
 		return null;
 	}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestServlet.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestServlet.java
index 4079598..dceac46 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestServlet.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestServlet.java
@@ -184,15 +184,19 @@ public abstract class BasicRestServlet extends RestServlet implements
BasicRestC
 	 * @return A bean containing the contents for the OPTIONS page.
 	 */
 	@RestMethod(name=OPTIONS, path="/*",
+		summary="Swagger documentation",
+		description="Swagger documentation for this resource.",
 		htmldoc=@HtmlDoc(
+			header={
+				"<h1>$R{resourceTitle}</h1>",
+				"<h2>$R{resourceDescription}</h2>"
+			},
 			navlinks={
 				"back: servlet:/",
 				"json: servlet:/?method=OPTIONS&Accept=text/json&plainText=true"
 			},
 			aside="NONE"
-		),
-		summary="Swagger documentation",
-		description="Auto-generated swagger documentation for this resource"
+		)
 	)
 	public Swagger getOptions(RestRequest req) {
 		return req.getSwagger();
diff --git a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/dark.css
b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/dark.css
index b67e1f0..c81702d 100644
--- a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/dark.css
+++ b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/dark.css
@@ -280,4 +280,6 @@ footer {
 .table {display:table;}
 .row {display:table-row;}
 .cell {display:table-cell;}
-.monospace {font-family:monospace;}
\ No newline at end of file
+.monospace {font-family:monospace;}
+.link { color: #94A3AB; text-decoration: none; cursor: pointer;}
+.link:hover { text-decoration: underline; }
diff --git a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/devops.css
b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/devops.css
index 6d02195..ad7188a 100644
--- a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/devops.css
+++ b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/styles/devops.css
@@ -270,4 +270,7 @@ footer {
 .table {display:table;}
 .row {display:table-row;}
 .cell {display:table-cell;}
-.monospace {font-family:monospace;}
\ No newline at end of file
+.monospace {font-family:monospace;}
+.link { color: #94A3AB; text-decoration: none; cursor: pointer;}
+.link:hover { text-decoration: underline; }
+
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 6152780..d5a1e28 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
@@ -261,4 +261,6 @@ footer {
 .table {display:table;}
 .row {display:table-row;}
 .cell {display:table-cell;}
-.monospace {font-family:monospace;}
\ No newline at end of file
+.monospace {font-family:monospace;}
+.link { color: #94A3AB; text-decoration: none; cursor: pointer;}
+.link:hover { text-decoration: underline; }
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 e4f4c9d..bad8907 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
@@ -225,4 +225,6 @@ footer {
 .row {display:table-row;}
 .cell {display:table-cell;}
 .monospace {font-family:monospace;}
+.link { color: #94A3AB; text-decoration: none; cursor: pointer;}
+.link:hover { text-decoration: underline; }
 

-- 
To stop receiving notification emails like this one, please contact
jamesbognar@apache.org.

Mime
View raw message