You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2018/09/24 15:16:23 UTC

[juneau] branch master updated: Swagger UI tweaks.

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 c981bbe  Swagger UI tweaks.
c981bbe is described below

commit c981bbed0a4ec60c8b6480fb0a33509ed312b17a
Author: JamesBognar <ja...@apache.org>
AuthorDate: Mon Sep 24 11:16:10 2018 -0400

    Swagger UI tweaks.
---
 .../java/org/apache/juneau/dto/html5/HtmlBuilder.java  | 18 ++++++++++++++++--
 .../org/apache/juneau/dto/swagger/ui/SwaggerUI.java    | 12 +++++++++---
 .../org/apache/juneau/dto/swagger/ui/SwaggerUI.css     |  2 +-
 .../files/htdocs/styles/SwaggerUI.css                  |  2 +-
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlBuilder.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlBuilder.java
index d6319bb..0a2c9bb 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlBuilder.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlBuilder.java
@@ -12,6 +12,8 @@
 // ***************************************************************************************************************************
 package org.apache.juneau.dto.html5;
 
+import static org.apache.juneau.internal.StringUtils.*;
+
 /**
  * Various useful static methods for creating HTML elements.
  *
@@ -1586,8 +1588,8 @@ public class HtmlBuilder {
 	 * @param text The child text node.
 	 * @return The new element.
 	 */
-	public static final Script script(String type, String text) {
-		return script().type(type).text(text);
+	public static final Script script(String type, String...text) {
+		return script().type(type).text(joinnl(text));
 	}
 
 	/**
@@ -1727,6 +1729,18 @@ public class HtmlBuilder {
 	}
 
 	/**
+	 * Creates a {@link Style} element with the specified inner text.
+	 *
+	 * @param text
+	 * 	The contents of the style element.
+	 * 	<br>Values will be concatenated with newlines.
+	 * @return The new element.
+	 */
+	public static final Style style(String...text) {
+		return style().text(joinnl(text));
+	}
+
+	/**
 	 * Creates an empty {@link Sub} element.
 	 *
 	 * @return The new element.
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 bb2e335..cb3522c 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
@@ -368,14 +368,20 @@ public class SwaggerUI extends PojoSwap<Swagger,Div> {
 		if (m.isEmpty())
 			return null;
 
-		Select select = (Select)select().disabled(m.size() < 2).onchange("selectExample(this)")._class("example-select");
+		Select select = null;
+		if (m.size() > 1) {
+			select = (Select)select().onchange("selectExample(this)")._class("example-select");
+		}
+
 		Div div = div(select)._class("examples");
 
-		select.child(option("model","model"));
+		if (select != null)
+			select.child(option("model","model"));
 		div.child(div(m.remove("model"))._class("model active").attr("data-name", "model"));
 
 		for (Map.Entry<String,Object> e : m.entrySet()) {
-			select.child(option(e.getKey(), e.getKey()));
+			if (select != null)
+				select.child(option(e.getKey(), e.getKey()));
 			div.child(div(e.getValue().toString().replaceAll("\\n", "\n"))._class("example").attr("data-name", e.getKey()));
 		}
 
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 e1c8a21..b55ffc6 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
@@ -276,7 +276,7 @@ td.parameter-value, td.response-value {
     overflow-wrap: break-word;
     font-family: monospace;
     font-weight: 400;
-    color: #fff;
+    color: limegreen;
 	display: none;
 	max-width: 800px;
 	max-height: 800px;
diff --git a/juneau-examples/juneau-examples-rest/files/htdocs/styles/SwaggerUI.css b/juneau-examples/juneau-examples-rest/files/htdocs/styles/SwaggerUI.css
index e1c8a21..b55ffc6 100644
--- a/juneau-examples/juneau-examples-rest/files/htdocs/styles/SwaggerUI.css
+++ b/juneau-examples/juneau-examples-rest/files/htdocs/styles/SwaggerUI.css
@@ -276,7 +276,7 @@ td.parameter-value, td.response-value {
     overflow-wrap: break-word;
     font-family: monospace;
     font-weight: 400;
-    color: #fff;
+    color: limegreen;
 	display: none;
 	max-width: 800px;
 	max-height: 800px;