io.swagger.annotations.Tag Java Examples
The following examples show how to use
io.swagger.annotations.Tag.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwaggerDefinitionProcessorTest.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@Test public void testProcess() { Swagger swagger = SwaggerGenerator.generate(SwaggerTestTarget.class); assertEquals(1, swagger.getTags().size()); io.swagger.models.Tag tag = swagger.getTags().get(0); assertEquals("testTag", tag.getName()); assertEquals("desc", tag.getDescription()); assertEquals("testValue", tag.getExternalDocs().getDescription()); assertEquals("testUrl", tag.getExternalDocs().getUrl()); assertEquals("127.0.0.1", swagger.getHost()); assertThat(swagger.getSchemes(), contains(io.swagger.models.Scheme.HTTP, io.swagger.models.Scheme.HTTPS)); io.swagger.models.Info info = swagger.getInfo(); assertEquals("title", info.getTitle()); assertEquals("version", info.getVersion()); assertEquals("desc", info.getDescription()); assertEquals("contactName", info.getContact().getName()); assertEquals("licenseName", info.getLicense().getName()); assertThat(swagger.getConsumes(), Matchers.contains(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN)); assertThat(swagger.getProduces(), Matchers.contains(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)); }
Example #2
Source File: TestSwaggerDefinition.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Test public void testSwaggerDefinition() { Swagger swagger = SwaggerGenerator.generate(SwaggerAnnotation.class); Assert.assertEquals(SwaggerAnnotation.class.getName(), swagger.getInfo().getVendorExtensions().get(SwaggerConst.EXT_JAVA_INTF)); Assert.assertEquals("2.0", swagger.getSwagger()); Assert.assertEquals("/base", swagger.getBasePath()); Assert.assertEquals("host", swagger.getHost()); Assert.assertEquals(Arrays.asList("json", "xml"), swagger.getConsumes()); Assert.assertEquals(Arrays.asList("abc", "123"), swagger.getProduces()); Assert.assertEquals(1, swagger.getTags().size()); io.swagger.models.Tag tagA = swagger.getTags().get(0); Assert.assertEquals("tagA", tagA.getName()); Assert.assertEquals("desc of tagA", tagA.getDescription()); Assert.assertEquals("tagA ext docs", tagA.getExternalDocs().getDescription()); Assert.assertEquals("url of tagA ext docs", tagA.getExternalDocs().getUrl()); Assert.assertEquals(1, tagA.getVendorExtensions().size()); Map<String, Object> tagValue = (Map<String, Object>) tagA.getVendorExtensions().get("x-tagA"); Assert.assertEquals("value of tagAExt", tagValue.get("x-tagAExt")); io.swagger.models.Info info = swagger.getInfo(); Assert.assertEquals("title of SwaggerAnnotation", info.getTitle()); Assert.assertEquals("0.1", info.getVersion()); Assert.assertEquals("termsOfService", info.getTermsOfService()); Assert.assertEquals("description of info for SwaggerAnnotation", info.getDescription()); Assert.assertEquals("contact", info.getContact().getName()); Assert.assertEquals("[email protected]", info.getContact().getEmail()); Assert.assertEquals("http://contact", info.getContact().getUrl()); Assert.assertEquals("license ", info.getLicense().getName()); Assert.assertEquals("http://license", info.getLicense().getUrl()); Assert.assertEquals(2, info.getVendorExtensions().size()); Map<String, Object> infoValue = (Map<String, Object>) info.getVendorExtensions().get("x-info"); Assert.assertEquals("value of infoExt", infoValue.get("x-infoExt")); Assert.assertEquals("SwaggerAnnotation ext docs", swagger.getExternalDocs().getDescription()); Assert.assertEquals("url of SwaggerAnnotation ext docs", swagger.getExternalDocs().getUrl()); }