@Test public void testTagsComponent() throws URISyntaxException { List<Tag> tags = new ArrayList<>(); tags.add(new Tag().name("Tag1").description("description")); tags.add(new Tag().name("Tag2")); Swagger2MarkupConverter.Context context = createContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); markupDocBuilder = new TagsComponent(context).apply(markupDocBuilder, TagsComponent.parameters(tags, OverviewDocument.SECTION_TITLE_LEVEL)); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); } }
Optional.ofNullable(swagger.getTag(value)) .orElseGet(() -> { Tag tag = new Tag().name(value); swagger.addTag(tag); return tag;
@Override protected void setup(Binder binder) { Multibinder<Tag> tags = Multibinder.newSetBinder(binder, Tag.class); tags.addBinding().toInstance(new Tag().name("collect").description("Collect data").externalDocs(MetadataConfig.centralDocs)); Multibinder<HttpService> httpServices = Multibinder.newSetBinder(binder, HttpService.class); httpServices.addBinding().to(EventCollectionHttpService.class); Multibinder.newSetBinder(binder, EventMapper.class); httpServices.addBinding().to(AdminHttpService.class); httpServices.addBinding().to(ProjectHttpService.class); } }
@Override protected void setup(Binder binder) { Multibinder<HttpService> httpServices = Multibinder.newSetBinder(binder, HttpService.class); httpServices.addBinding().to(RetentionAnalyzerHttpService.class); Multibinder<Tag> tags = Multibinder.newSetBinder(binder, Tag.class); tags.addBinding().toInstance(new Tag().name("retention") .description("Retention Analyzer module").externalDocs(MetadataConfig.centralDocs)); // binder.bind(RetentionAnalyzerListener.class).asEagerSingleton(); }
@Override protected void setup(Binder binder) { Multibinder<HttpService> httpServices = Multibinder.newSetBinder(binder, HttpService.class); httpServices.addBinding().to(EventExplorerHttpService.class); Multibinder<EventMapper> timeMapper = Multibinder.newSetBinder(binder, EventMapper.class); timeMapper.permitDuplicates().addBinding().to(TimestampEventMapper.class).in(Scopes.SINGLETON); Multibinder<Tag> tags = Multibinder.newSetBinder(binder, Tag.class); tags.addBinding().toInstance(new Tag().name("event-explorer").description("Event Explorer").externalDocs(MetadataConfig.centralDocs)); binder.bind(EventExplorerListener.class).asEagerSingleton(); }
@Override protected void setup(Binder binder) { Multibinder<HttpService> httpServices = Multibinder.newSetBinder(binder, HttpService.class); httpServices.addBinding().to(ABTestingHttpService.class); Multibinder<Tag> tags = Multibinder.newSetBinder(binder, Tag.class); tags.addBinding().toInstance(new Tag().name("ab-testing").description("A/B Testing Module").externalDocs(MetadataConfig.centralDocs)); }
@Override protected void setup(Binder binder) { Multibinder<HttpService> httpServices = Multibinder.newSetBinder(binder, HttpService.class); httpServices.addBinding().to(EventStreamHttpService.class); Multibinder<Tag> tags = Multibinder.newSetBinder(binder, Tag.class); tags.addBinding().toInstance(new Tag().name("event-stream").description("Event Stream Module").externalDocs(MetadataConfig.centralDocs)); }
@Override protected void setup(Binder binder) { Multibinder<HttpService> httpServices = Multibinder.newSetBinder(binder, HttpService.class); httpServices.addBinding().to(FunnelAnalyzerHttpService.class); Multibinder<Tag> tags = Multibinder.newSetBinder(binder, Tag.class); tags.addBinding().toInstance(new Tag().name("funnel").description("Funnel Analyzer").externalDocs(MetadataConfig.centralDocs)); }
@Override protected void setup(Binder binder) { bindConfig(binder).to(RealTimeConfig.class); Multibinder<HttpService> multiBinder = Multibinder.newSetBinder(binder, HttpService.class); multiBinder.addBinding().to(RealTimeHttpService.class); Multibinder<EventMapper> mappers = Multibinder.newSetBinder(binder, EventMapper.class); mappers.permitDuplicates().addBinding().to(TimestampEventMapper.class); mappers.addBinding().to(RealtimeEventProcessor.class).in(Scopes.SINGLETON); Multibinder.newSetBinder(binder, Tag.class).addBinding() .toInstance(new Tag().name("realtime").description("Realtime") .externalDocs(MetadataConfig.centralDocs)); }
private Map<String, Tag> scanClasspathForTags() { Map<String, Tag> tags = new HashMap<>(); for (Class<?> aClass: new Reflections("").getTypesAnnotatedWith(SwaggerDefinition.class)) { SwaggerDefinition swaggerDefinition = AnnotationUtils.findAnnotation(aClass, SwaggerDefinition.class); for (io.swagger.annotations.Tag tag : swaggerDefinition.tags()) { String tagName = tag.name(); if (!tagName.isEmpty()) { tags.put(tag.name(), new Tag().name(tag.name()).description(tag.description())); } } } return tags; }
protected Set<Tag> extractTags(Api api) { Set<Tag> output = new LinkedHashSet<>(); if(api == null) { return output; } boolean hasExplicitTags = false; for (String tag : api.tags()) { if (!tag.isEmpty()) { hasExplicitTags = true; output.add(new Tag().name(tag)); } } if (!hasExplicitTags) { // derive tag from api path + description String tagString = api.value().replace("/", ""); if (!tagString.isEmpty()) { Tag tag = new Tag().name(tagString); if (!api.description().isEmpty()) { tag.description(api.description()); } output.add(tag); } } return output; }
protected void updateTagsForOperation(Operation operation, ApiOperation apiOperation) { if (apiOperation == null) { return; } for (String tag : apiOperation.tags()) { if (!tag.isEmpty()) { operation.tag(tag); swagger.tag(new Tag().name(tag)); } } }
.toInstance(new Tag().name("recipe").description("Recipe") .externalDocs(MetadataConfig.centralDocs));
tags.addBinding().toInstance(new Tag().name("admin").description("System related actions").externalDocs(MetadataConfig.centralDocs)); tags.addBinding().toInstance(new Tag().name("query").description("Analyze data").externalDocs(MetadataConfig.centralDocs)); tags.addBinding().toInstance(new Tag().name("materialized-view").description("Materialized view").externalDocs(MetadataConfig.centralDocs));
public static Tag tag(String name) { return new Tag().name(name); } public static Contact contact() {
/** * Return a list of {@link Tag} objects created from the {@link Api#tags()} property. * * @param clazz The annotated service class * @return A list of {@link Tag} objects */ public static List<Tag> getApiTagsAsList(Class<?> clazz) { return Arrays.asList(clazz.getAnnotation(Api.class).tags()) .stream() .map(tag -> new Tag().name(tag)) .collect(Collectors.toList()); }
private Tag buildTag(final Class<?> serviceClass) { final Api annotation = serviceClass.getAnnotation(Api.class); final String name = (annotation != null) ? annotation.value() : serviceClass.getSimpleName(); final String description = (annotation != null) ? annotation.description() : serviceClass.getCanonicalName(); return new Tag().name(name).description(description); }
private Tag buildTag(final Class<?> serviceClass) { final Api annotation = serviceClass.getAnnotation(Api.class); final String name = (annotation != null) ? annotation.value() : serviceClass.getSimpleName(); final String description = (annotation != null) ? annotation.description() : serviceClass.getCanonicalName(); return new Tag().name(name).description(description); }
@Test public void testGetApiTagsAsList() { List<Tag> actualTags = SwaggerDocumentationUtils.getApiTagsAsList(AnnotatedServiceMock.class); List<Tag> expectedTags = new ArrayList<>(); expectedTags.add(new Tag().name(API_TAG)); Assert.assertEquals(expectedTags, actualTags); }