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/01/18 19:01:04 UTC

[08/10] juneau git commit: JUNEAU-78

http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/SwaggerTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/SwaggerTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/SwaggerTest.java
new file mode 100644
index 0000000..99aa176
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/SwaggerTest.java
@@ -0,0 +1,910 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
+// * with the License.  You may obtain a copy of the License at                                                              * 
+// *                                                                                                                         *
+// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
+// *                                                                                                                         *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
+// * specific language governing permissions and limitations under the License.                                              *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import java.util.*;
+
+import org.apache.juneau.http.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.utils.*;
+
+import static org.apache.juneau.dto.swagger.SwaggerBuilder.*;
+
+import org.junit.*;
+
+/**
+ * Testcase for {@link Swagger}.
+ */
+public class SwaggerTest {
+
+	/**
+	 * Test method for {@link Swagger#swagger(java.lang.Object)}.
+	 */
+	@Test
+	public void testSwagger() {
+		Swagger t = new Swagger();
+		
+		t.swagger("foo");
+		assertEquals("foo", t.getSwagger());
+		
+		t.swagger(new StringBuilder("foo"));
+		assertEquals("foo", t.getSwagger());
+		assertType(String.class, t.getSwagger());
+		
+		t.swagger(null);
+		assertNull(t.getSwagger());
+	}
+
+	/**
+	 * Test method for {@link Swagger#info(java.lang.Object)}.
+	 */
+	@Test
+	public void testInfo() {
+		Swagger t = new Swagger();
+		
+		t.info(info("foo", "bar"));
+		assertObjectEquals("{title:'foo',version:'bar'}", t.getInfo());
+		
+		t.info("{title:'foo',version:'bar'}");
+		assertObjectEquals("{title:'foo',version:'bar'}", t.getInfo());
+		assertType(Info.class, t.getInfo());
+
+		t.info(null);
+		assertNull(t.getInfo());
+	}
+
+	/**
+	 * Test method for {@link Swagger#host(java.lang.Object)}.
+	 */
+	@Test
+	public void testHost() {
+		Swagger t = new Swagger();
+		
+		t.host("foo");
+		assertEquals("foo", t.getHost());
+		
+		t.host(new StringBuilder("foo"));
+		assertEquals("foo", t.getHost());
+		assertType(String.class, t.getHost());
+		
+		t.host(null);
+		assertNull(t.getHost());
+	}
+
+	/**
+	 * Test method for {@link Swagger#basePath(java.lang.Object)}.
+	 */
+	@Test
+	public void testBasePath() {
+		Swagger t = new Swagger();
+		
+		t.basePath("foo");
+		assertEquals("foo", t.getBasePath());
+		
+		t.basePath(new StringBuilder("foo"));
+		assertEquals("foo", t.getBasePath());
+		assertType(String.class, t.getBasePath());
+		
+		t.basePath(null);
+		assertNull(t.getBasePath());
+	}
+
+	/**
+	 * Test method for {@link Swagger#setSchemes(java.util.Collection)}.
+	 */
+	@Test
+	public void testSetSchemes() {
+		Swagger t = new Swagger();
+		
+		t.setSchemes(new ASet<String>().appendAll("foo","bar"));
+		assertObjectEquals("['foo','bar']", t.getSchemes());
+		assertType(List.class, t.getSchemes());
+		
+		t.setSchemes(new ASet<String>());
+		assertObjectEquals("[]", t.getSchemes());
+		assertType(List.class, t.getSchemes());
+
+		t.setSchemes(null);
+		assertNull(t.getSchemes());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addSchemes(java.util.Collection)}.
+	 */
+	@Test
+	public void testAddSchemes() {
+		Swagger t = new Swagger();
+		
+		t.addSchemes(new ASet<String>().appendAll("foo","bar"));
+		assertObjectEquals("['foo','bar']", t.getSchemes());
+		assertType(List.class, t.getSchemes());
+		
+		t.addSchemes(new ASet<String>());
+		assertObjectEquals("['foo','bar']", t.getSchemes());
+		assertType(List.class, t.getSchemes());
+
+		t.addSchemes(null);
+		assertObjectEquals("['foo','bar']", t.getSchemes());
+		assertType(List.class, t.getSchemes());
+	}
+
+	/**
+	 * Test method for {@link Swagger#schemes(java.lang.Object[])}.
+	 */
+	@Test
+	public void testSchemes() {
+		Swagger t = new Swagger();
+		
+		t.schemes(new ASet<String>().appendAll("foo"));
+		t.schemes(new ASet<Object>().appendAll(new StringBuilder("bar")));
+		t.schemes((Object)new String[] {"baz"});
+		t.schemes("['qux']");
+		t.schemes("quux");
+		t.schemes("[]");
+		t.schemes((Object)null);
+		
+		assertObjectEquals("['foo','bar','baz','qux','quux']", t.getSchemes());
+	}
+
+	/**
+	 * Test method for {@link Swagger#setConsumes(java.util.Collection)}.
+	 */
+	@Test
+	public void testSetConsumes() {
+		Swagger t = new Swagger();
+		
+		t.setConsumes(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+		assertObjectEquals("['text/foo']", t.getConsumes());
+		assertType(List.class, t.getConsumes());
+		
+		t.setConsumes(new ASet<MediaType>());
+		assertObjectEquals("[]", t.getConsumes());
+		assertType(List.class, t.getConsumes());
+
+		t.setConsumes(null);
+		assertNull(t.getConsumes());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addConsumes(java.util.Collection)}.
+	 */
+	@Test
+	public void testAddConsumes() {
+		Swagger t = new Swagger();
+		
+		t.addConsumes(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+		assertObjectEquals("['text/foo']", t.getConsumes());
+		assertType(List.class, t.getConsumes());
+		
+		t.addConsumes(new ASet<MediaType>());
+		assertObjectEquals("['text/foo']", t.getConsumes());
+		assertType(List.class, t.getConsumes());
+
+		t.addConsumes(null);
+		assertObjectEquals("['text/foo']", t.getConsumes());
+		assertType(List.class, t.getConsumes());
+	}
+
+	/**
+	 * Test method for {@link Swagger#consumes(java.lang.Object[])}.
+	 */
+	@Test
+	public void testConsumes() {
+		Swagger t = new Swagger();
+		
+		t.consumes(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+		t.consumes(MediaType.forString("text/bar"));
+		t.consumes("text/baz");
+		t.consumes(new StringBuilder("text/qux"));
+		t.consumes((Object)new String[]{"text/quux"});
+		t.consumes((Object)new ASet<String>().append("text/quuux"));
+		t.consumes("['text/quuuux']");
+		t.consumes("[]");
+		t.consumes((Object)null);
+		assertObjectEquals("['text/foo','text/bar','text/baz','text/qux','text/quux','text/quuux','text/quuuux']", t.getConsumes());
+		assertType(List.class, t.getConsumes());
+		for (MediaType mt : t.getConsumes())
+			assertType(MediaType.class, mt);
+	}
+
+	/**
+	 * Test method for {@link Swagger#setProduces(java.util.Collection)}.
+	 */
+	@Test
+	public void testSetProduces() {
+		Swagger t = new Swagger();
+		
+		t.setProduces(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+		assertObjectEquals("['text/foo']", t.getProduces());
+		assertType(List.class, t.getProduces());
+		
+		t.setProduces(new ASet<MediaType>());
+		assertObjectEquals("[]", t.getProduces());
+		assertType(List.class, t.getProduces());
+
+		t.setProduces(null);
+		assertNull(t.getProduces());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addProduces(java.util.Collection)}.
+	 */
+	@Test
+	public void testAddProduces() {
+		Swagger t = new Swagger();
+		
+		t.addProduces(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+		assertObjectEquals("['text/foo']", t.getProduces());
+		assertType(List.class, t.getProduces());
+		
+		t.addProduces(new ASet<MediaType>());
+		assertObjectEquals("['text/foo']", t.getProduces());
+		assertType(List.class, t.getProduces());
+
+		t.addProduces(null);
+		assertObjectEquals("['text/foo']", t.getProduces());
+		assertType(List.class, t.getProduces());
+	}
+
+	/**
+	 * Test method for {@link Swagger#produces(java.lang.Object[])}.
+	 */
+	@Test
+	public void testProduces() {
+		Swagger t = new Swagger();
+
+		t.produces(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+		t.produces(MediaType.forString("text/bar"));
+		t.produces("text/baz");
+		t.produces(new StringBuilder("text/qux"));
+		t.produces((Object)new String[]{"text/quux"});
+		t.produces((Object)new ASet<String>().append("text/quuux"));
+		t.produces("['text/quuuux']");
+		t.produces("[]");
+		t.produces((Object)null);
+		assertObjectEquals("['text/foo','text/bar','text/baz','text/qux','text/quux','text/quuux','text/quuuux']", t.getProduces());
+		assertType(List.class, t.getProduces());
+		for (MediaType mt : t.getProduces())
+			assertType(MediaType.class, mt);
+	}
+
+	/**
+	 * Test method for {@link Swagger#setPaths(java.util.Map)}.
+	 */
+	@Test
+	public void testSetPaths() {
+		Swagger t = new Swagger();
+		
+		t.setPaths(new AMap<String,Map<String,Operation>>().append("foo", new AMap<String,Operation>().append("bar",operation().summary("baz"))));
+		assertObjectEquals("{foo:{bar:{summary:'baz'}}}", t.getPaths());
+		assertType(Map.class, t.getPaths());
+		
+		t.setPaths(new AMap<String,Map<String,Operation>>());
+		assertObjectEquals("{}", t.getPaths());
+		assertType(Map.class, t.getPaths());
+
+		t.setPaths(null);
+		assertNull(t.getPaths());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addPaths(java.util.Map)}.
+	 */
+	@Test
+	public void testAddPaths() {
+		Swagger t = new Swagger();
+		
+		t.addPaths(new AMap<String,Map<String,Operation>>().append("foo", new AMap<String,Operation>().append("bar",operation().summary("baz"))));
+		assertObjectEquals("{foo:{bar:{summary:'baz'}}}", t.getPaths());
+		assertType(Map.class, t.getPaths());
+		
+		t.addPaths(new AMap<String,Map<String,Operation>>());
+		assertObjectEquals("{foo:{bar:{summary:'baz'}}}", t.getPaths());
+		assertType(Map.class, t.getPaths());
+
+		t.addPaths(null);
+		assertObjectEquals("{foo:{bar:{summary:'baz'}}}", t.getPaths());
+		assertType(Map.class, t.getPaths());
+	}
+
+	/**
+	 * Test method for {@link Swagger#path(java.lang.String, java.lang.String, org.apache.juneau.dto.swagger.Operation)}.
+	 */
+	@Test
+	public void testPath() {
+		Swagger t = new Swagger();
+		
+		t.path("a", "a1", operation().description("a2"));
+		t.path("b", null, null);
+		t.path(null, "c1", operation().description("c2"));
+		
+		assertObjectEquals("{a:{a1:{description:'a2'}},b:{null:null},null:{c1:{description:'c2'}}}", t.getPaths());
+	}
+
+	/**
+	 * Test method for {@link Swagger#paths(java.lang.Object[])}.
+	 */
+	@Test
+	public void testPaths() {
+		Swagger t = new Swagger();
+		
+		t.paths(new AMap<String,Map<String,Operation>>().append("a", new AMap<String,Operation>().append("a1", operation().operationId("a2"))));
+		t.paths(new AMap<String,Map<String,String>>().append("b", new AMap<String,String>().append("b1", "{operationId:'b2'}")));
+		t.paths(new AMap<String,String>().append("c", "{c1:{operationId:'c2'}}"));
+		t.paths("{d:{d1:{operationId:'d2'}}}");
+		t.paths("{}");
+		t.paths((Object[])null);
+		
+		assertObjectEquals("{a:{a1:{operationId:'a2'}},b:{b1:{operationId:'b2'}},c:{c1:{operationId:'c2'}},d:{d1:{operationId:'d2'}}}", t.getPaths());
+		for (Map<String,Operation> m : t.getPaths().values()) {
+			for (Operation o : m.values()) {
+				assertType(Operation.class, o);
+			}
+		}
+	}
+
+	/**
+	 * Test method for {@link Swagger#setDefinitions(java.util.Map)}.
+	 */
+	@Test
+	public void testSetDefinitions() {
+		Swagger t = new Swagger();
+		
+		t.setDefinitions(new AMap<String,SchemaInfo>().append("foo",schemaInfo().title("bar")));
+		assertObjectEquals("{foo:{title:'bar'}}", t.getDefinitions());
+		assertType(Map.class, t.getDefinitions());
+		
+		t.setDefinitions(new AMap<String,SchemaInfo>());
+		assertObjectEquals("{}", t.getDefinitions());
+		assertType(Map.class, t.getDefinitions());
+
+		t.setDefinitions(null);
+		assertNull(t.getDefinitions());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addDefinitions(java.util.Map)}.
+	 */
+	@Test
+	public void testAddDefinitions() {
+		Swagger t = new Swagger();
+		
+		t.addDefinitions(new AMap<String,SchemaInfo>().append("foo",schemaInfo().title("bar")));
+		assertObjectEquals("{foo:{title:'bar'}}", t.getDefinitions());
+		assertType(Map.class, t.getDefinitions());
+		
+		t.addDefinitions(new AMap<String,SchemaInfo>());
+		assertObjectEquals("{foo:{title:'bar'}}", t.getDefinitions());
+		assertType(Map.class, t.getDefinitions());
+
+		t.addDefinitions(null);
+		assertObjectEquals("{foo:{title:'bar'}}", t.getDefinitions());
+		assertType(Map.class, t.getDefinitions());
+	}
+
+	/**
+	 * Test method for {@link Swagger#definition(java.lang.String, org.apache.juneau.dto.swagger.SchemaInfo)}.
+	 */
+	@Test
+	public void testDefinition() {
+		Swagger t = new Swagger();
+
+		t.definition("a", schemaInfo().title("a1"));
+		t.definition("b", null);
+		t.definition(null, schemaInfo().title("c1"));
+		
+		assertObjectEquals("{a:{title:'a1'},b:null,null:{title:'c1'}}", t.getDefinitions());
+	}
+
+	/**
+	 * Test method for {@link Swagger#definitions(java.lang.Object[])}.
+	 */
+	@Test
+	public void testDefinitions() {
+		Swagger t = new Swagger();
+		
+		t.definitions(new AMap<String,SchemaInfo>().append("a", schemaInfo().type("a1")));
+		t.definitions(new AMap<String,String>().append("b", "{type:'b1'}"));
+		t.definitions("{c:{type:'c1'}}");
+		t.definitions("{}");
+		t.definitions((Object[])null);
+		
+		assertObjectEquals("{a:{type:'a1'},b:{type:'b1'},c:{type:'c1'}}", t.getDefinitions());
+	}
+
+	/**
+	 * Test method for {@link Swagger#setParameters(java.util.Map)}.
+	 */
+	@Test
+	public void testSetParameters() {
+		Swagger t = new Swagger();
+		
+		t.setParameters(new AMap<String,ParameterInfo>().append("foo",parameterInfo().name("bar")));
+		assertObjectEquals("{foo:{name:'bar'}}", t.getParameters());
+		assertType(Map.class, t.getParameters());
+		
+		t.setParameters(new AMap<String,ParameterInfo>());
+		assertObjectEquals("{}", t.getParameters());
+		assertType(Map.class, t.getParameters());
+
+		t.setParameters(null);
+		assertNull(t.getParameters());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addParameters(java.util.Map)}.
+	 */
+	@Test
+	public void testAddParameters() {
+		Swagger t = new Swagger();
+		
+		t.addParameters(new AMap<String,ParameterInfo>().append("foo",parameterInfo().name("bar")));
+		assertObjectEquals("{foo:{name:'bar'}}", t.getParameters());
+		assertType(Map.class, t.getParameters());
+		
+		t.addParameters(new AMap<String,ParameterInfo>());
+		assertObjectEquals("{foo:{name:'bar'}}", t.getParameters());
+		assertType(Map.class, t.getParameters());
+
+		t.addParameters(null);
+		assertObjectEquals("{foo:{name:'bar'}}", t.getParameters());
+		assertType(Map.class, t.getParameters());
+	}
+
+	/**
+	 * Test method for {@link Swagger#parameter(java.lang.String, org.apache.juneau.dto.swagger.ParameterInfo)}.
+	 */
+	@Test
+	public void testParameter() {
+		Swagger t = new Swagger();
+		
+		t.parameter("a", parameterInfo().in("a1"));
+		t.parameter("b", null);
+		t.parameter(null, parameterInfo().in("c1"));
+
+		assertObjectEquals("{a:{'in':'a1'},b:null,null:{'in':'c1'}}", t.getParameters());
+	}
+
+	/**
+	 * Test method for {@link Swagger#parameters(java.lang.Object[])}.
+	 */
+	@Test
+	public void testParameters() {
+		Swagger t = new Swagger();
+		
+		t.parameters(new AMap<String,ParameterInfo>().append("a", parameterInfo("a1", "a2")));
+		t.parameters(new AMap<String,String>().append("b", "{in:'b1',name:'b2'}"));
+		t.parameters("{c:{in:'c1',name:'c2'}}");
+		t.parameters("{}");
+		t.parameters((Object[])null);
+		
+		assertObjectEquals("{a:{'in':'a1',name:'a2'},b:{'in':'b1',name:'b2'},c:{'in':'c1',name:'c2'}}", t.getParameters());
+	}
+
+	/**
+	 * Test method for {@link Swagger#setResponses(java.util.Map)}.
+	 */
+	@Test
+	public void testSetResponses() {
+		Swagger t = new Swagger();
+		
+		t.setResponses(new AMap<String,ResponseInfo>().append("123",responseInfo("bar")));
+		assertObjectEquals("{'123':{description:'bar'}}", t.getResponses());
+		assertType(Map.class, t.getResponses());
+		
+		t.setResponses(new AMap<String,ResponseInfo>());
+		assertObjectEquals("{}", t.getResponses());
+		assertType(Map.class, t.getResponses());
+
+		t.setResponses(null);
+		assertNull(t.getResponses());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addResponses(java.util.Map)}.
+	 */
+	@Test
+	public void testAddResponses() {
+		Swagger t = new Swagger();
+		
+		t.addResponses(new AMap<String,ResponseInfo>().append("123",responseInfo("bar")));
+		assertObjectEquals("{'123':{description:'bar'}}", t.getResponses());
+		assertType(Map.class, t.getResponses());
+		
+		t.addResponses(new AMap<String,ResponseInfo>());
+		assertObjectEquals("{'123':{description:'bar'}}", t.getResponses());
+		assertType(Map.class, t.getResponses());
+
+		t.addResponses(null);
+		assertObjectEquals("{'123':{description:'bar'}}", t.getResponses());
+		assertType(Map.class, t.getResponses());
+	}
+
+	/**
+	 * Test method for {@link Swagger#response(java.lang.String, org.apache.juneau.dto.swagger.ResponseInfo)}.
+	 */
+	@Test
+	public void testResponse() {
+		Swagger t = new Swagger();
+		
+		t.response("a", responseInfo("a1"));
+		t.response(null, responseInfo("b1"));
+		t.response("c", null);
+
+		assertObjectEquals("{a:{description:'a1'},null:{description:'b1'},c:null}", t.getResponses());
+	}
+
+	/**
+	 * Test method for {@link Swagger#responses(java.lang.Object[])}.
+	 */
+	@Test
+	public void testResponses() {
+		Swagger t = new Swagger();
+		
+		t.responses(new AMap<String,ResponseInfo>().append("a", responseInfo("a1")));
+		t.responses(new AMap<String,String>().append("b", "{description:'b1'}"));
+		t.responses("{c:{description:'c1'}}");
+		t.responses("{}");
+		t.responses((Object[])null);
+		
+		assertObjectEquals("{a:{description:'a1'},b:{description:'b1'},c:{description:'c1'}}", t.getResponses());
+		for (ResponseInfo ri : t.getResponses().values())
+			assertType(ResponseInfo.class, ri);
+	}
+
+	/**
+	 * Test method for {@link Swagger#setSecurityDefinitions(java.util.Map)}.
+	 */
+	@Test
+	public void testSetSecurityDefinitions() {
+		Swagger t = new Swagger();
+		
+		t.setSecurityDefinitions(new AMap<String,SecurityScheme>().append("foo",securityScheme("bar")));
+		assertObjectEquals("{foo:{type:'bar'}}", t.getSecurityDefinitions());
+		assertType(Map.class, t.getSecurityDefinitions());
+		
+		t.setSecurityDefinitions(new AMap<String,SecurityScheme>());
+		assertObjectEquals("{}", t.getSecurityDefinitions());
+		assertType(Map.class, t.getSecurityDefinitions());
+
+		t.setSecurityDefinitions(null);
+		assertNull(t.getSecurityDefinitions());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addSecurityDefinitions(java.util.Map)}.
+	 */
+	@Test
+	public void testAddSecurityDefinitions() {
+		Swagger t = new Swagger();
+		
+		t.addSecurityDefinitions(new AMap<String,SecurityScheme>().append("foo",securityScheme("bar")));
+		assertObjectEquals("{foo:{type:'bar'}}", t.getSecurityDefinitions());
+		assertType(Map.class, t.getSecurityDefinitions());
+		
+		t.addSecurityDefinitions(new AMap<String,SecurityScheme>());
+		assertObjectEquals("{foo:{type:'bar'}}", t.getSecurityDefinitions());
+		assertType(Map.class, t.getSecurityDefinitions());
+
+		t.addSecurityDefinitions(null);
+		assertObjectEquals("{foo:{type:'bar'}}", t.getSecurityDefinitions());
+		assertType(Map.class, t.getSecurityDefinitions());
+	}
+
+	/**
+	 * Test method for {@link Swagger#securityDefinition(java.lang.String, org.apache.juneau.dto.swagger.SecurityScheme)}.
+	 */
+	@Test
+	public void testSecurityDefinition() {
+		Swagger t = new Swagger();
+		
+		t.securityDefinition("a", securityScheme("a1"));
+		t.securityDefinition("b", null);
+		t.securityDefinition(null, securityScheme("c1"));
+
+		assertObjectEquals("{a:{type:'a1'},b:null,null:{type:'c1'}}", t.getSecurityDefinitions());
+	}
+
+	/**
+	 * Test method for {@link Swagger#securityDefinitions(java.lang.Object[])}.
+	 */
+	@Test
+	public void testSecurityDefinitions() {
+		Swagger t = new Swagger();
+		
+		t.securityDefinitions(new AMap<String,SecurityScheme>().append("a", securityScheme("a1")));
+		t.securityDefinitions(new AMap<String,String>().append("b", "{type:'b1'}"));
+		t.securityDefinitions("{c:{type:'c1'}}");
+		t.securityDefinitions("{}");
+		t.securityDefinitions((Object[])null);
+		
+		assertObjectEquals("{a:{type:'a1'},b:{type:'b1'},c:{type:'c1'}}", t.getSecurityDefinitions());
+		for (SecurityScheme ss : t.getSecurityDefinitions().values())
+			assertType(SecurityScheme.class, ss);
+	}
+
+	/**
+	 * Test method for {@link Swagger#setSecurity(java.util.Collection)}.
+	 */
+	@Test
+	public void testSetSecurity() {
+		Swagger t = new Swagger();
+		
+		t.setSecurity(new ASet<Map<String,List<String>>>().append(new AMap<String,List<String>>().append("foo",new AList<String>().append("bar"))));
+		assertObjectEquals("[{foo:['bar']}]", t.getSecurity());
+		assertType(List.class, t.getSecurity());
+		
+		t.setSecurity(new ASet<Map<String,List<String>>>());
+		assertObjectEquals("[]", t.getSecurity());
+		assertType(List.class, t.getSecurity());
+
+		t.setSecurity(null);
+		assertNull(t.getSecurity());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addSecurity(java.util.Collection)}.
+	 */
+	@Test
+	public void testAddSecurity() {
+		Swagger t = new Swagger();
+		
+		t.addSecurity(new ASet<Map<String,List<String>>>().append(new AMap<String,List<String>>().append("foo",new AList<String>().append("bar"))));
+		assertObjectEquals("[{foo:['bar']}]", t.getSecurity());
+		assertType(List.class, t.getSecurity());
+		
+		t.addSecurity(new ASet<Map<String,List<String>>>());
+		assertObjectEquals("[{foo:['bar']}]", t.getSecurity());
+		assertType(List.class, t.getSecurity());
+
+		t.addSecurity(null);
+		assertObjectEquals("[{foo:['bar']}]", t.getSecurity());
+		assertType(List.class, t.getSecurity());
+	}
+
+	/**
+	 * Test method for {@link Swagger#security(java.lang.String, java.lang.String[])}.
+	 */
+	@Test
+	public void testSecurity() {
+		Swagger t = new Swagger();
+		
+		t.security("a", "a1", "a2");
+		t.security("b", (String)null);
+		t.security("c");
+		t.security(null, "d1", "d2");
+
+		assertObjectEquals("[{a:['a1','a2']},{b:[null]},{c:[]},{null:['d1','d2']}]", t.getSecurity());
+	}
+
+	/**
+	 * Test method for {@link Swagger#securities(java.lang.Object[])}.
+	 */
+	@Test
+	public void testSecurities() {
+		Swagger t = new Swagger();
+		//Collection<Map<String,List<String>>>	
+		t.securities(new ASet<Map<String,List<String>>>().append(new AMap<String,List<String>>().append("a1",new AList<String>().append("a2"))));
+		t.securities(new AMap<String,List<String>>().append("b1",new AList<String>().append("b2")));
+		t.securities("{c1:['c2']}");
+		t.securities(new StringBuilder("{d1:['d2']}"));
+		t.securities((Object)new String[]{"{e1:['e2']}"});
+		t.securities((Object)new ASet<String>().append("{f1:['f2']}"));
+		t.securities("[{g1:['g2']}]");
+		t.securities("[]");
+		t.securities((Object)null);
+		assertObjectEquals("[{a1:['a2']},{b1:['b2']},{c1:['c2']},{d1:['d2']},{e1:['e2']},{f1:['f2']},{g1:['g2']}]", t.getSecurity());
+		assertType(List.class, t.getSecurity());
+	}
+
+	/**
+	 * Test method for {@link Swagger#setTags(java.util.Collection)}.
+	 */
+	@Test
+	public void testSetTags() {
+		Swagger t = new Swagger();
+		
+		t.setTags(new ASet<Tag>().appendAll(tag("foo")));
+		assertObjectEquals("[{name:'foo'}]", t.getTags());
+		assertType(List.class, t.getTags());
+		
+		t.setTags(new ASet<Tag>());
+		assertObjectEquals("[]", t.getTags());
+		assertType(List.class, t.getTags());
+
+		t.setTags(null);
+		assertNull(t.getTags());
+	}
+
+	/**
+	 * Test method for {@link Swagger#addTags(java.util.Collection)}.
+	 */
+	@Test
+	public void testAddTags() {
+		Swagger t = new Swagger();
+		
+		t.addTags(new ASet<Tag>().appendAll(tag("foo")));
+		assertObjectEquals("[{name:'foo'}]", t.getTags());
+		assertType(List.class, t.getTags());
+		
+		t.addTags(new ASet<Tag>());
+		assertObjectEquals("[{name:'foo'}]", t.getTags());
+		assertType(List.class, t.getTags());
+
+		t.addTags(null);
+		assertObjectEquals("[{name:'foo'}]", t.getTags());
+		assertType(List.class, t.getTags());
+	}
+
+	/**
+	 * Test method for {@link Swagger#tags(java.lang.Object[])}.
+	 */
+	@Test
+	public void testTags() {
+		Swagger t = new Swagger();
+		
+		t.tags(new ASet<Tag>().appendAll(tag("a")));
+		t.tags(new ASet<String>().appendAll("{name:'b'}"));
+		t.tags((Object)new Tag[] {tag("c")});
+		t.tags((Object)new String[] {"{name:'d'}"});
+		t.tags("{name:'e'}");
+		t.tags(new StringBuilder("{name:'f'}"));
+		t.tags("[{name:'g'}]");
+		t.tags("[]");
+		t.tags((Object)null);
+		assertObjectEquals("[{name:'a'},{name:'b'},{name:'c'},{name:'d'},{name:'e'},{name:'f'},{name:'g'}]", t.getTags());
+		assertType(List.class, t.getTags());
+		for (Tag tag : t.getTags())
+			assertType(Tag.class, tag);
+	}
+
+	/**
+	 * Test method for {@link Swagger#externalDocs(java.lang.Object)}.
+	 */
+	@Test
+	public void testExternalDocs() {
+		Swagger t = new Swagger();
+		
+		t.externalDocs(externalDocumentation("foo"));
+		assertObjectEquals("{url:'foo'}", t.getExternalDocs());
+		
+		t.externalDocs("{url:'foo'}");
+		assertObjectEquals("{url:'foo'}", t.getExternalDocs());
+		assertType(ExternalDocumentation.class, t.getExternalDocs());
+
+		t.externalDocs(null);
+		assertNull(t.getExternalDocs());
+	}
+
+	/**
+	 * Test method for {@link Swagger#set(java.lang.String, java.lang.Object)}.
+	 */
+	@Test
+	public void testSet() throws Exception {
+		Swagger t = new Swagger();
+		
+		t
+			.set("basePath", "a")
+			.set("consumes", new ASet<MediaType>().appendAll(MediaType.forString("text/b")))
+			.set("definitions", new AMap<String,SchemaInfo>().append("c", schemaInfo().type("c1")))
+			.set("externalDocs", externalDocumentation("d"))
+			.set("host", "e")
+			.set("info", info("f1", "f2"))
+			.set("parameters", new AMap<String,ParameterInfo>().append("g", parameterInfo("g1", "g2")))
+			.set("paths", new AMap<String,Map<String,Operation>>().append("h", new AMap<String,Operation>().append("h1", operation().operationId("h2"))))
+			.set("produces", new ASet<MediaType>().appendAll(MediaType.forString("text/i")))
+			.set("responses", new AMap<String,ResponseInfo>().append("j", responseInfo("j1")))
+			.set("schemes", new ASet<String>().appendAll("k1"))
+			.set("security", new ASet<Map<String,List<String>>>().append(new AMap<String,List<String>>().append("l1",new AList<String>().append("l2"))))
+			.set("securityDefinitions", new AMap<String,SecurityScheme>().append("m", securityScheme("m1")))
+			.set("swagger", "n")
+			.set("tags", new ASet<Tag>().appendAll(tag("o")))
+			.set("$ref", "ref");
+	
+		assertObjectEquals("{swagger:'n',info:{title:'f1',version:'f2'},tags:[{name:'o'}],externalDocs:{url:'d'},basePath:'a',schemes:['k1'],consumes:['text/b'],produces:['text/i'],paths:{h:{h1:{operationId:'h2'}}},definitions:{c:{type:'c1'}},parameters:{g:{'in':'g1',name:'g2'}},responses:{j:{description:'j1'}},securityDefinitions:{m:{type:'m1'}},security:[{l1:['l2']}],'$ref':'ref'}", t);
+		
+		t
+			.set("basePath", "a")
+			.set("consumes", "['text/b']")
+			.set("definitions", "{c:{type:'c1'}}")
+			.set("externalDocs", "{url:'d'}")
+			.set("host", "e")
+			.set("info", "{title:'f1',version:'f2'}")
+			.set("parameters", "{g:{'in':'g1',name:'g2'}}")
+			.set("paths", "{h:{h1:{operationId:'h2'}}}")
+			.set("produces", "['text/i']")
+			.set("responses", "{j:{description:'j1'}}")
+			.set("schemes", "['k1']")
+			.set("security", "[{l1:['l2']}]")
+			.set("securityDefinitions", "{m:{type:'m1'}}")
+			.set("swagger", "n")
+			.set("tags", "[{name:'o'}]")
+			.set("$ref", "ref");
+	
+		assertObjectEquals("{swagger:'n',info:{title:'f1',version:'f2'},tags:[{name:'o'}],externalDocs:{url:'d'},basePath:'a',schemes:['k1'],consumes:['text/b'],produces:['text/i'],paths:{h:{h1:{operationId:'h2'}}},definitions:{c:{type:'c1'}},parameters:{g:{'in':'g1',name:'g2'}},responses:{j:{description:'j1'}},securityDefinitions:{m:{type:'m1'}},security:[{l1:['l2']}],'$ref':'ref'}", t);
+		
+		t
+			.set("basePath", new StringBuilder("a"))
+			.set("consumes", new StringBuilder("['text/b']"))
+			.set("definitions", new StringBuilder("{c:{type:'c1'}}"))
+			.set("externalDocs", new StringBuilder("{url:'d'}"))
+			.set("host", new StringBuilder("e"))
+			.set("info", new StringBuilder("{title:'f1',version:'f2'}"))
+			.set("parameters", new StringBuilder("{g:{'in':'g1',name:'g2'}}"))
+			.set("paths", new StringBuilder("{h:{h1:{operationId:'h2'}}}"))
+			.set("produces", new StringBuilder("['text/i']"))
+			.set("responses", new StringBuilder("{j:{description:'j1'}}"))
+			.set("schemes", new StringBuilder("['k1']"))
+			.set("security", new StringBuilder("[{l1:['l2']}]"))
+			.set("securityDefinitions", new StringBuilder("{m:{type:'m1'}}"))
+			.set("swagger", new StringBuilder("n"))
+			.set("tags", new StringBuilder("[{name:'o'}]"))
+			.set("$ref", new StringBuilder("ref"));
+	
+		assertObjectEquals("{swagger:'n',info:{title:'f1',version:'f2'},tags:[{name:'o'}],externalDocs:{url:'d'},basePath:'a',schemes:['k1'],consumes:['text/b'],produces:['text/i'],paths:{h:{h1:{operationId:'h2'}}},definitions:{c:{type:'c1'}},parameters:{g:{'in':'g1',name:'g2'}},responses:{j:{description:'j1'}},securityDefinitions:{m:{type:'m1'}},security:[{l1:['l2']}],'$ref':'ref'}", t);
+
+		assertEquals("a", t.get("basePath", String.class));
+		assertEquals("['text/b']", t.get("consumes", String.class));
+		assertEquals("{c:{type:'c1'}}", t.get("definitions", String.class));
+		assertEquals("{url:'d'}", t.get("externalDocs", String.class));
+		assertEquals("e", t.get("host", String.class));
+		assertEquals("{title:'f1',version:'f2'}", t.get("info", String.class));
+		assertEquals("{g:{'in':'g1',name:'g2'}}", t.get("parameters", String.class));
+		assertEquals("{h:{h1:{operationId:'h2'}}}", t.get("paths", String.class));
+		assertEquals("['text/i']", t.get("produces", String.class));
+		assertEquals("{j:{description:'j1'}}", t.get("responses", String.class));
+		assertEquals("['k1']", t.get("schemes", String.class));
+		assertEquals("[{l1:['l2']}]", t.get("security", String.class));
+		assertEquals("{m:{type:'m1'}}", t.get("securityDefinitions", String.class));
+		assertEquals("n", t.get("swagger", String.class));
+		assertEquals("[{name:'o'}]", t.get("tags", String.class));
+		assertEquals("ref", t.get("$ref", String.class));
+	
+		assertType(String.class, t.get("basePath", Object.class));
+		assertType(List.class, t.get("consumes", Object.class));
+		assertType(MediaType.class, t.get("consumes", List.class).get(0));
+		assertType(Map.class, t.get("definitions", Object.class));
+		assertType(SchemaInfo.class, t.get("definitions", Map.class).values().iterator().next());
+		assertType(ExternalDocumentation.class, t.get("externalDocs", Object.class));
+		assertType(String.class, t.get("host", Object.class));
+		assertType(Info.class, t.get("info", Object.class));
+		assertType(Map.class, t.get("parameters", Object.class));
+		assertType(ParameterInfo.class, t.get("parameters", Map.class).values().iterator().next());
+		assertType(Map.class, t.get("paths", Object.class));
+		assertType(List.class, t.get("produces", Object.class));
+		assertType(MediaType.class, t.get("consumes", List.class).get(0));
+		assertType(Map.class, t.get("responses", Object.class));
+		assertType(ResponseInfo.class, t.get("responses", Map.class).values().iterator().next());
+		assertType(List.class, t.get("schemes", Object.class));
+		assertType(List.class, t.get("security", Object.class));
+		assertType(Map.class, t.get("securityDefinitions", Object.class));
+		assertType(SecurityScheme.class, t.get("securityDefinitions", Map.class).values().iterator().next());
+		assertType(String.class, t.get("swagger", Object.class));
+		assertType(List.class, t.get("tags", Object.class));
+		assertType(Tag.class, t.get("tags", List.class).get(0));
+		assertType(StringBuilder.class, t.get("$ref", Object.class));
+	
+		t.set("null", null).set(null, "null");
+		assertNull(t.get("null", Object.class));
+		assertNull(t.get(null, Object.class));
+		assertNull(t.get("foo", Object.class));
+		
+		String s = "{swagger:'n',info:{title:'f1',version:'f2'},tags:[{name:'o'}],externalDocs:{url:'d'},basePath:'a',schemes:['k1'],consumes:['text/b'],produces:['text/i'],paths:{h:{h1:{operationId:'h2'}}},definitions:{c:{type:'c1'}},parameters:{g:{'in':'g1',name:'g2'}},responses:{j:{description:'j1'}},securityDefinitions:{m:{type:'m1'}},security:[{l1:['l2']}],'$ref':'ref'}";
+		assertObjectEquals(s, JsonParser.DEFAULT.parse(s, Swagger.class));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/TagTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/TagTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/TagTest.java
new file mode 100644
index 0000000..537301c
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/TagTest.java
@@ -0,0 +1,133 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
+// * with the License.  You may obtain a copy of the License at                                                              * 
+// *                                                                                                                         *
+// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
+// *                                                                                                                         *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
+// * specific language governing permissions and limitations under the License.                                              *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.juneau.json.*;
+
+import static org.apache.juneau.dto.swagger.SwaggerBuilder.*;
+
+import org.junit.*;
+
+/**
+ * Testcase for {@link Tag}.
+ */
+public class TagTest {
+
+	/**
+	 * Test method for {@link Tag#name(java.lang.Object)}.
+	 */
+	@Test
+	public void testName() {
+		Tag t = new Tag();
+		
+		t.name("foo");
+		assertEquals("foo", t.getName());
+		
+		t.name(new StringBuilder("foo"));
+		assertEquals("foo", t.getName());
+		assertType(String.class, t.getName());
+		
+		t.name(null);
+		assertNull(t.getName());
+	}
+
+	/**
+	 * Test method for {@link Tag#description(java.lang.Object)}.
+	 */
+	@Test
+	public void testDescription() {
+		Tag t = new Tag();
+		
+		t.description("foo");
+		assertEquals("foo", t.getDescription());
+		
+		t.description(new StringBuilder("foo"));
+		assertEquals("foo", t.getDescription());
+		assertType(String.class, t.getDescription());
+		
+		t.description(null);
+		assertNull(t.getDescription());
+	}
+
+	/**
+	 * Test method for {@link Tag#externalDocs(java.lang.Object)}.
+	 */
+	@Test
+	public void testExternalDocs() {
+		Tag t = new Tag();
+		
+		t.externalDocs(externalDocumentation("foo"));
+		assertObjectEquals("{url:'foo'}", t.getExternalDocs());
+		
+		t.externalDocs("{url:'foo'}");
+		assertObjectEquals("{url:'foo'}", t.getExternalDocs());
+		assertType(ExternalDocumentation.class, t.getExternalDocs());
+
+		t.externalDocs(null);
+		assertNull(t.getExternalDocs());
+	}
+
+	/**
+	 * Test method for {@link Tag#set(java.lang.String, java.lang.Object)}.
+	 */
+	@Test
+	public void testSet() throws Exception {
+		Tag t = new Tag();
+		
+		t
+			.set("description", "a")
+			.set("externalDocs", externalDocumentation("b"))
+			.set("name", "c")
+			.set("$ref", "ref");
+	
+		assertObjectEquals("{name:'c',description:'a',externalDocs:{url:'b'},'$ref':'ref'}", t);
+		
+		t
+			.set("description", "a")
+			.set("externalDocs", "{url:'b'}")
+			.set("name", "c")
+			.set("$ref", "ref");
+		
+		assertObjectEquals("{name:'c',description:'a',externalDocs:{url:'b'},'$ref':'ref'}", t);
+		
+		t
+			.set("description", new StringBuilder("a"))
+			.set("externalDocs", new StringBuilder("{url:'b'}"))
+			.set("name", new StringBuilder("c"))
+			.set("$ref", new StringBuilder("ref"));
+		
+		assertObjectEquals("{name:'c',description:'a',externalDocs:{url:'b'},'$ref':'ref'}", t);
+	
+		assertEquals("a", t.get("description", String.class));
+		assertEquals("{url:'b'}", t.get("externalDocs", String.class));
+		assertEquals("c", t.get("name", String.class));
+		assertEquals("ref", t.get("$ref", String.class));
+	
+		assertType(String.class, t.get("description", Object.class));
+		assertType(ExternalDocumentation.class, t.get("externalDocs", Object.class));
+		assertType(String.class, t.get("name", Object.class));
+		assertType(StringBuilder.class, t.get("$ref", Object.class));
+	
+		t.set("null", null).set(null, "null");
+		assertNull(t.get("null", Object.class));
+		assertNull(t.get(null, Object.class));
+		assertNull(t.get("foo", Object.class));
+		
+		String s = "{name:'c',description:'a',externalDocs:{url:'b'},'$ref':'ref'}";
+		assertObjectEquals(s, JsonParser.DEFAULT.parse(s, Tag.class));
+	}
+}

http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/XmlTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/XmlTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/XmlTest.java
new file mode 100644
index 0000000..695c1ce
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/XmlTest.java
@@ -0,0 +1,186 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
+// * with the License.  You may obtain a copy of the License at                                                              * 
+// *                                                                                                                         *
+// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
+// *                                                                                                                         *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
+// * specific language governing permissions and limitations under the License.                                              *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+/**
+ * Testcase for {@link Xml}.
+ */
+public class XmlTest {
+
+	/**
+	 * Test method for {@link Xml#name(java.lang.Object)}.
+	 */
+	@Test
+	public void testName() {
+		Xml t = new Xml();
+		
+		t.name("foo");
+		assertEquals("foo", t.getName());
+		
+		t.name(new StringBuilder("foo"));
+		assertEquals("foo", t.getName());
+		assertType(String.class, t.getName());
+		
+		t.name(null);
+		assertNull(t.getName());
+	}
+
+	/**
+	 * Test method for {@link Xml#namespace(java.lang.Object)}.
+	 */
+	@Test
+	public void testNamespace() {
+		Xml t = new Xml();
+		
+		t.namespace("foo");
+		assertEquals("foo", t.getNamespace());
+		
+		t.namespace(new StringBuilder("foo"));
+		assertEquals("foo", t.getNamespace());
+		assertType(String.class, t.getNamespace());
+		
+		t.namespace(null);
+		assertNull(t.getNamespace());
+	}
+
+	/**
+	 * Test method for {@link Xml#prefix(java.lang.Object)}.
+	 */
+	@Test
+	public void testPrefix() {
+		Xml t = new Xml();
+		
+		t.prefix("foo");
+		assertEquals("foo", t.getPrefix());
+		
+		t.prefix(new StringBuilder("foo"));
+		assertEquals("foo", t.getPrefix());
+		assertType(String.class, t.getPrefix());
+		
+		t.prefix(null);
+		assertNull(t.getPrefix());
+	}
+
+	/**
+	 * Test method for {@link Xml#attribute(java.lang.Object)}.
+	 */
+	@Test
+	public void testAttribute() {
+		Xml t = new Xml();
+		
+		t.attribute(true);
+		assertEquals(true, t.getAttribute());
+		assertType(Boolean.class, t.getAttribute());
+		
+		t.attribute("true");
+		assertEquals(true, t.getAttribute());
+		assertType(Boolean.class, t.getAttribute());
+
+		t.attribute(new StringBuilder("true"));
+		assertEquals(true, t.getAttribute());
+		assertType(Boolean.class, t.getAttribute());
+		
+		t.attribute(null);
+		assertNull(t.getAttribute());
+	}
+
+	/**
+	 * Test method for {@link Xml#wrapped(java.lang.Object)}.
+	 */
+	@Test
+	public void testWrapped() {
+		Xml t = new Xml();
+		
+		t.wrapped(true);
+		assertEquals(true, t.getWrapped());
+		assertType(Boolean.class, t.getWrapped());
+		
+		t.wrapped("true");
+		assertEquals(true, t.getWrapped());
+		assertType(Boolean.class, t.getWrapped());
+
+		t.wrapped(new StringBuilder("true"));
+		assertEquals(true, t.getWrapped());
+		assertType(Boolean.class, t.getWrapped());
+		
+		t.wrapped(null);
+		assertNull(t.getWrapped());
+	}
+
+	/**
+	 * Test method for {@link Xml#set(java.lang.String, java.lang.Object)}.
+	 */
+	@Test
+	public void testSet() throws Exception {
+		Xml t = new Xml();
+		
+		t
+			.set("attribute", true)
+			.set("name", "a")
+			.set("namespace", "b")
+			.set("prefix", "c")
+			.set("wrapped", true)
+			.set("$ref", "ref");
+	
+		assertObjectEquals("{name:'a',namespace:'b',prefix:'c',attribute:true,wrapped:true,'$ref':'ref'}", t);
+		
+		t
+			.set("attribute", "true")
+			.set("name", "a")
+			.set("namespace", "b")
+			.set("prefix", "c")
+			.set("wrapped", "true")
+			.set("$ref", "ref");
+	
+		assertObjectEquals("{name:'a',namespace:'b',prefix:'c',attribute:true,wrapped:true,'$ref':'ref'}", t);
+
+		t
+			.set("attribute", new StringBuilder("true"))
+			.set("name", new StringBuilder("a"))
+			.set("namespace", new StringBuilder("b"))
+			.set("prefix", new StringBuilder("c"))
+			.set("wrapped", new StringBuilder("true"))
+			.set("$ref", new StringBuilder("ref"));
+	
+		assertObjectEquals("{name:'a',namespace:'b',prefix:'c',attribute:true,wrapped:true,'$ref':'ref'}", t);
+		
+		assertEquals("true", t.get("attribute", String.class));
+		assertEquals("a", t.get("name", String.class));
+		assertEquals("b", t.get("namespace", String.class));
+		assertEquals("c", t.get("prefix", String.class));
+		assertEquals("true", t.get("wrapped", String.class));
+		assertEquals("ref", t.get("$ref", String.class));
+	
+		assertType(Boolean.class, t.get("attribute", Object.class));
+		assertType(String.class, t.get("name", Object.class));
+		assertType(String.class, t.get("namespace", Object.class));
+		assertType(String.class, t.get("prefix", Object.class));
+		assertType(Boolean.class, t.get("wrapped", Object.class));
+		assertType(StringBuilder.class, t.get("$ref", Object.class));
+	
+		t.set("null", null).set(null, "null");
+		assertNull(t.get("null", Object.class));
+		assertNull(t.get(null, Object.class));
+		assertNull(t.get("foo", Object.class));
+		
+		String s = "{name:'a',namespace:'b',prefix:'c',attribute:true,wrapped:true,'$ref':'ref'}";
+		assertObjectEquals(s, JsonParser.DEFAULT.parse(s, Xml.class));
+	}
+}

http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java
index 1ce5ccd..c7047c5 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java
@@ -137,7 +137,7 @@ public abstract class HtmlElement {
 	 * @return The attribute value, or <jk>null</jk> if the named attribute does not exist.
 	 */
 	public <T> T getAttr(Class<T> type, String key) {
-		return attrs == null ? null : ObjectUtils.convertToType(attrs.get(key), type);
+		return attrs == null ? null : ObjectUtils.toType(attrs.get(key), type);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementContainer.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementContainer.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementContainer.java
index bae530d..a0a3b48 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementContainer.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementContainer.java
@@ -113,7 +113,7 @@ public class HtmlElementContainer extends HtmlElement {
 	public <T> T getChild(Class<T> type, int index) {
 		return (children == null || children.size() <= index || index < 0
 			? null
-			: ObjectUtils.convertToType(children.get(index), type)
+			: ObjectUtils.toType(children.get(index), type)
 		);
 	}
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementMixed.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementMixed.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementMixed.java
index d717973..0255253 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementMixed.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlElementMixed.java
@@ -114,7 +114,7 @@ public class HtmlElementMixed extends HtmlElement {
 		return (
 			children == null || children.size() <= index || index < 0
 			? null
-			: ObjectUtils.convertToType(children.get(index), type)
+			: ObjectUtils.toType(children.get(index), type)
 		);
 	}
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Contact.java
----------------------------------------------------------------------
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 e5fbc5b..4587f36 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
@@ -12,7 +12,7 @@
 // ***************************************************************************************************************************
 package org.apache.juneau.dto.swagger;
 
-import static org.apache.juneau.internal.StringUtils.*;
+import static org.apache.juneau.internal.BeanPropertyUtils.*;
 
 import java.net.*;
 import java.net.URI;
@@ -25,6 +25,17 @@ import org.apache.juneau.annotation.*;
  * 
  * <h5 class='section'>Example:</h5>
  * <p class='bcode'>
+ * 	<jc>// Construct using SwaggerBuilder.</jc>
+ * 	Contact x = <jsm>contact</jsm>(<js>"API Support"</js>, <js>"http://www.swagger.io/support"</js>, <js>"support@swagger.io"</js>);
+ * 
+ * 	<jc>// Serialize using JsonSerializer.</jc>
+ * 	String json = JsonSerializer.<jsf>DEFAULT</jsf>.toString(x);
+ * 
+ * 	<jc>// Or just use toString() which does the same as above.</jc>
+ * 	String json = x.toString();
+ * </p>
+ * <p class='bcode'>
+ * 	<jc>// Output</jc>
  * 	{
  * 		<js>"name"</js>: <js>"API Support"</js>,
  * 		<js>"url"</js>: <js>"http://www.swagger.io/support"</js>,
@@ -34,20 +45,10 @@ import org.apache.juneau.annotation.*;
  * 
  * <h6 class='topic'>Additional Information</h6>
  * <ul class='doctree'>
- * 	<li class='link'>
- * 		<a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects
- * 		(org.apache.juneau.dto)</a>
- * 		<ul>
- * 			<li class='sublink'>
- * 				<a class='doclink' href='../../../../../overview-summary.html#DTOs.Swagger'>Swagger</a>
- * 		</ul>
- * 	</li>
- * 	<li class='jp'>
- * 		<a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.swagger</a>
- * 	</li>
+ * 	<li class='link'><a class='doclink' href='../../../../../overview-summary.html#juneau-dto.Swagger'>Overview > juneau-dto > Swagger</a>
  * </ul>
  */
-@Bean(properties="name,url,email")
+@Bean(properties="name,url,email,*")
 public class Contact extends SwaggerElement {
 
 	private String name;
@@ -60,7 +61,7 @@ public class Contact extends SwaggerElement {
 	 * <p>
 	 * The identifying name of the contact person/organization.
 	 * 
-	 * @return The value of the <property>name</property> property on this bean, or <jk>null</jk> if it is not set.
+	 * @return The property value, or <jk>null</jk> if it is not set.
 	 */
 	public String getName() {
 		return name;
@@ -72,31 +73,36 @@ public class Contact extends SwaggerElement {
 	 * <p>
 	 * The identifying name of the contact person/organization.
 	 * 
-	 * @param name The new value for the <property>name</property> property on this bean.
+	 * @param value 
+	 * 	The new value for this property.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public Contact setName(String name) {
-		this.name = name;
+	public Contact setName(String value) {
+		name = value;
 		return this;
 	}
 
 	/**
-	 * Synonym for {@link #setName(String)}.
+	 * Same as {@link #setName(String)}.
 	 * 
-	 * @param name The new value for the <property>name</property> property on this bean.
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Non-String values will be converted to String using <code>toString()</code>.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public Contact name(String name) {
-		return setName(name);
+	public Contact name(Object value) {
+		return setName(toStringVal(value));
 	}
 
 	/**
 	 * Bean property getter:  <property>url</property>.
 	 * 
 	 * <p>
-	 * The URL pointing to the contact information. MUST be in the format of a URL.
+	 * The URL pointing to the contact information. 
 	 * 
-	 * @return The value of the <property>url</property> property on this bean, or <jk>null</jk> if it is not set.
+	 * @return The property value, or <jk>null</jk> if it is not set.
 	 */
 	public URI getUrl() {
 		return url;
@@ -107,36 +113,41 @@ public class Contact extends SwaggerElement {
 	 * 
 	 * <p>
 	 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
-	 * Strings must be valid URIs.
+	 * <br>Strings must be valid URIs.
 	 * 
 	 * <p>
 	 * URIs defined by {@link UriResolver} can be used for values.
 	 * 
-	 * @param url The new value for the <property>url</property> property on this bean.
+	 * @param value 
+	 * 	The new value for this property.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public Contact setUrl(Object url) {
-		this.url = toURI(url);
+	public Contact setUrl(URI value) {
+		url = value;
 		return this;
 	}
 
 	/**
-	 * Synonym for {@link #setUrl(Object)}.
+	 * Same as {@link #setUrl(URI)}.
 	 * 
-	 * @param url The new value for the <property>url</property> property on this bean.
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Non-URI values will be converted to URI using <code><jk>new</jk> URI(value.toString())</code>.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public Contact url(Object url) {
-		return setUrl(url);
+	public Contact url(Object value) {
+		return setUrl(toURI(value));
 	}
 
 	/**
 	 * Bean property getter:  <property>email</property>.
 	 * 
 	 * <p>
-	 * The email address of the contact person/organization. MUST be in the format of an email address.
+	 * The email address of the contact person/organization. 
 	 * 
-	 * @return The value of the <property>email</property> property on this bean, or <jk>null</jk> if it is not set.
+	 * @return The property value, or <jk>null</jk> if it is not set.
 	 */
 	public String getEmail() {
 		return email;
@@ -146,23 +157,56 @@ public class Contact extends SwaggerElement {
 	 * Bean property setter:  <property>email</property>.
 	 * 
 	 * <p>
-	 * The email address of the contact person/organization. MUST be in the format of an email address.
+	 * The email address of the contact person/organization. 
 	 * 
-	 * @param email The new value for the <property>email</property> property on this bean.
+	 * @param value 
+	 * 	The new value for this property.
+	 * 	<br>MUST be in the format of an email address.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public Contact setEmail(String email) {
-		this.email = email;
+	public Contact setEmail(String value) {
+		email = value;
 		return this;
 	}
 
 	/**
-	 * Synonym for {@link #setEmail(String)}.
+	 * Same as {@link #setEmail(String)}.
 	 * 
-	 * @param email The new value for the <property>email</property> property on this bean.
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Non-String values will be converted to String using <code>toString()</code>.
+	 * 	<br>MUST be in the format of an email address.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public Contact email(String email) {
-		return setEmail(email);
+	public Contact email(Object value) {
+		return setEmail(toStringVal(value));
+	}
+
+	@Override /* SwaggerElement */
+	public <T> T get(String property, Class<T> type) {
+		if (property == null)
+			return null;
+		switch (property) {
+			case "name": return toType(getName(), type);
+			case "url": return toType(getUrl(), type);
+			case "email": return toType(getEmail(), type);
+			default: return super.get(property, type);
+		}
+	}
+
+	@Override /* SwaggerElement */
+	public Contact set(String property, Object value) {
+		if (property == null)
+			return this;
+		switch (property) {
+			case "name": return name(value);
+			case "url": return url(value);
+			case "email": return email(value);
+			default: 
+				super.set(property, value);
+				return this;
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java
----------------------------------------------------------------------
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 f780486..3b9e02b 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
@@ -12,7 +12,7 @@
 // ***************************************************************************************************************************
 package org.apache.juneau.dto.swagger;
 
-import static org.apache.juneau.internal.StringUtils.*;
+import static org.apache.juneau.internal.BeanPropertyUtils.*;
 
 import java.net.*;
 import java.net.URI;
@@ -25,6 +25,17 @@ import org.apache.juneau.annotation.*;
  * 
  * <h5 class='section'>Example:</h5>
  * <p class='bcode'>
+ * 	<jc>// Construct using SwaggerBuilder.</jc>
+ * 	ExternalDocumentation x = <jsm>externalDocumentation</jsm>(<js>"https://swagger.io"</js>, <js>"Find more info here"</js>);
+ * 
+ * 	<jc>// Serialize using JsonSerializer.</jc>
+ * 	String json = JsonSerializer.<jsf>DEFAULT</jsf>.toString(x);
+ * 
+ * 	<jc>// Or just use toString() which does the same as above.</jc>
+ * 	String json = x.toString();
+ * </p>
+ * <p class='bcode'>
+ * 	<jc>// Output</jc>
  * 	{
  * 		<js>"description"</js>: <js>"Find more info here"</js>,
  * 		<js>"url"</js>: <js>"https://swagger.io"</js>
@@ -33,20 +44,10 @@ import org.apache.juneau.annotation.*;
  * 
  * <h6 class='topic'>Additional Information</h6>
  * <ul class='doctree'>
- * 	<li class='link'>
- * 		<a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects
- * 		(org.apache.juneau.dto)</a>
- * 		<ul>
- * 			<li class='sublink'>
- * 				<a class='doclink' href='../../../../../overview-summary.html#DTOs.Swagger'>Swagger</a>
- * 		</ul>
- * 	</li>
- * 	<li class='jp'>
- * 		<a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.swagger</a>
- * 	</li>
+ * 	<li class='link'><a class='doclink' href='../../../../../overview-summary.html#juneau-dto.Swagger'>Overview > juneau-dto > Swagger</a>
  * </ul>
  */
-@Bean(properties="description,url")
+@Bean(properties="description,url,*")
 public class ExternalDocumentation extends SwaggerElement {
 
 	private String description;
@@ -56,10 +57,9 @@ public class ExternalDocumentation extends SwaggerElement {
 	 * Bean property getter:  <property>description</property>.
 	 * 
 	 * <p>
-	 * A short description of the target documentation. GFM syntax can be used for rich text representation.
+	 * A short description of the target documentation. 
 	 * 
-	 * @return
-	 * 	The value of the <property>description</property> property on this bean, or <jk>null</jk> if it is not set.
+	 * @return The property value, or <jk>null</jk> if it is not set.
 	 */
 	public String getDescription() {
 		return description;
@@ -69,40 +69,39 @@ public class ExternalDocumentation extends SwaggerElement {
 	 * Bean property setter:  <property>description</property>.
 	 * 
 	 * <p>
-	 * A short description of the target documentation. GFM syntax can be used for rich text representation.
+	 * A short description of the target documentation. 
 	 * 
-	 * @param description The new value for the <property>description</property> property on this bean.
+	 * @param value 
+	 * 	The new value for this property.
+	 * 	<br><a class="doclink" href="https://help.github.com/articles/github-flavored-markdown">GFM syntax</a> can be used for rich text representation.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public ExternalDocumentation setDescription(String description) {
-		this.description = description;
+	public ExternalDocumentation setDescription(String value) {
+		description = value;
 		return this;
 	}
 
 	/**
-	 * Synonym for {@link #setDescription(String)}.
+	 * Same as {@link #setDescription(String)}.
 	 * 
-	 * @param description The new value for the <property>description</property> property on this bean.
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Non-String values will be converted to String using <code>toString()</code>.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public ExternalDocumentation description(String description) {
-		return setDescription(description);
+	public ExternalDocumentation description(Object value) {
+		return setDescription(toStringVal(value));
 	}
 
 	/**
 	 * Bean property getter:  <property>url</property>.
 	 * 
 	 * <p>
-	 * Required. The URL for the target documentation.
-	 * 
-	 * <p>
-	 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
-	 * Strings must be valid URIs.
-	 * 
-	 * <p>
-	 * URIs defined by {@link UriResolver} can be used for values.
+	 * The URL for the target documentation.
 	 * 
-	 * @return The value of the <property>url</property> property on this bean, or <jk>null</jk> if it is not set.
+	 * @return The property value, or <jk>null</jk> if it is not set.
 	 */
 	public URI getUrl() {
 		return url;
@@ -112,27 +111,61 @@ public class ExternalDocumentation extends SwaggerElement {
 	 * Bean property setter:  <property>url</property>.
 	 * 
 	 * <p>
-	 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
-	 * Strings must be valid URIs.
-	 * 
-	 * <p>
-	 * URIs defined by {@link UriResolver} can be used for values.
+	 * The URL for the target documentation.
 	 * 
-	 * @param url The new value for the <property>url</property> property on this bean.
+	 * @param value 
+	 * 	The new value for this property.
+	 * 	<br>Property value is required.
+	 * 	<br>URIs defined by {@link UriResolver} can be used for values.
 	 * @return This object (for method chaining).
 	 */
-	public ExternalDocumentation setUrl(Object url) {
-		this.url = toURI(url);
+	public ExternalDocumentation setUrl(URI value) {
+		url = value;
 		return this;
 	}
 
 	/**
-	 * Synonym for {@link #setUrl(Object)}.
+	 * Same as {@link #setUrl(URI)}.
 	 * 
-	 * @param url The new value for the <property>url</property> property on this bean.
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>URIs defined by {@link UriResolver} can be used for values.
+	 * 	<br>Valid types:
+	 * 	<ul>
+	 * 		<li>{@link URI}
+	 * 		<li>{@link URL}
+	 * 		<li>{@link String} 
+	 * 			<br>Converted to URI using <code><jk>new</jk> URI(value.toString())</code>.
+	 * 		<li>
+	 * 	</ul>
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public ExternalDocumentation url(Object url) {
-		return setUrl(url);
+	public ExternalDocumentation url(Object value) {
+		return setUrl(toURI(value));
+	}
+
+	@Override /* SwaggerElement */
+	public <T> T get(String property, Class<T> type) {
+		if (property == null)
+			return null;
+		switch (property) {
+			case "description": return toType(getDescription(), type);
+			case "url": return toType(getUrl(), type);
+			default: return super.get(property, type);
+		}
+	}
+
+	@Override /* SwaggerElement */
+	public ExternalDocumentation set(String property, Object value) {
+		if (property == null)
+			return this;
+		switch (property) {
+			case "description": return description(value);
+			case "url": return url(value);
+			default: 
+				super.set(property, value);
+				return this;
+		}
 	}
 }