當前位置: 首頁>>代碼示例>>Java>>正文


Java Api類代碼示例

本文整理匯總了Java中io.swagger.annotations.Api的典型用法代碼示例。如果您正苦於以下問題:Java Api類的具體用法?Java Api怎麽用?Java Api使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Api類屬於io.swagger.annotations包,在下文中一共展示了Api類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: api

import io.swagger.annotations.Api; //導入依賴的package包/類
@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(new ApiInfo(
                    "Smarti",
                    "the smart in assistify",
                    apiVersion,
                    null,
                    new Contact(
                            apiContactName,
                            apiContactUrl,
                            "[email protected]"
                    ),
                    "Apache 2.0",
                    "https://www.apache.org/licenses/LICENSE-2.0",
                    Collections.emptyList()
            ))
            .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                .paths(PathSelectors.any())
                .build()
            .securitySchemes(Arrays.asList(authToken(), basicAuth()))
            .securityContexts(Arrays.asList(publicContext(), defaultContext()))
            .ignoredParameterTypes(AuthContext.class)
            .directModelSubstitute(ObjectId.class, String.class);
}
 
開發者ID:redlink-gmbh,項目名稱:smarti,代碼行數:27,代碼來源:SwaggerConfiguration.java

示例2: applyConsumes

import io.swagger.annotations.Api; //導入依賴的package包/類
@Override
public void applyConsumes(ReaderContext context, Operation operation, Method method) {
	final List<String> consumes = new ArrayList<String>();
	final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);

	if (apiOperation != null) {
		consumes.addAll(parseStringValues(apiOperation.consumes()));
	}

	if (consumes.isEmpty()) {
		final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
		if (apiAnnotation != null) {
			consumes.addAll(parseStringValues(apiAnnotation.consumes()));
		}
		consumes.addAll(context.getParentConsumes());
	}

	for (String consume : consumes) {
		operation.consumes(consume);
	}

}
 
開發者ID:Sayi,項目名稱:swagger-dubbo,代碼行數:23,代碼來源:DubboReaderExtension.java

示例3: applyProduces

import io.swagger.annotations.Api; //導入依賴的package包/類
@Override
public void applyProduces(ReaderContext context, Operation operation, Method method) {
	final List<String> produces = new ArrayList<String>();
	final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);

	if (apiOperation != null) {
		produces.addAll(parseStringValues(apiOperation.produces()));
	}

	if (produces.isEmpty()) {
		final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
		if (apiAnnotation != null) {
			produces.addAll(parseStringValues(apiAnnotation.produces()));
		}
		produces.addAll(context.getParentProduces());
	}

	for (String produce : produces) {
		operation.produces(produce);
	}

}
 
開發者ID:Sayi,項目名稱:swagger-dubbo,代碼行數:23,代碼來源:DubboReaderExtension.java

示例4: applySchemes

import io.swagger.annotations.Api; //導入依賴的package包/類
@Override
public void applySchemes(ReaderContext context, Operation operation, Method method) {
	final List<Scheme> schemes = new ArrayList<Scheme>();
	final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
	final Api apiAnnotation = context.getCls().getAnnotation(Api.class);

	if (apiOperation != null) {
		schemes.addAll(parseSchemes(apiOperation.protocols()));
	}

	if (schemes.isEmpty() && apiAnnotation != null) {
		schemes.addAll(parseSchemes(apiAnnotation.protocols()));
	}

	for (Scheme scheme : schemes) {
		operation.scheme(scheme);
	}

}
 
開發者ID:Sayi,項目名稱:swagger-dubbo,代碼行數:20,代碼來源:DubboReaderExtension.java

示例5: process

import io.swagger.annotations.Api; //導入依賴的package包/類
@Override
public void process(final CtInterface<?> restServiceInterface) {

  final CtAnnotation<Annotation> annotation = getFactory().Code().createAnnotation(getFactory().Code().createCtTypeReference(Api.class));
  final String classFqn = restServiceInterface.getQualifiedName();
  final RestService restService = context.getServiceDocumentation().get(classFqn);

  if (restService != null) {
    annotation.addValue("tags", restService.getTags());
    restServiceInterface.addAnnotation(annotation);

    // Add path annotation if missing
    final Path pathAnnotation = restServiceInterface.getAnnotation(Path.class);
    if (pathAnnotation == null) {
      final CtAnnotation<Path> path = getFactory().Code().createAnnotation(getFactory().Code().createCtTypeReference(Path.class));
      path.addValue("value", restService.getPath());
      restServiceInterface.addAnnotation(path);
    }

    log.debug("Added @Api to {} [{}]", restServiceInterface.getQualifiedName(), classFqn);
  } else {
    log.error("No documentation found for {} [{}]", restServiceInterface.getQualifiedName(), classFqn);
  }
}
 
開發者ID:camunda,項目名稱:camunda-bpm-swagger,代碼行數:25,代碼來源:RestServiceProcessor.java

示例6: process

import io.swagger.annotations.Api; //導入依賴的package包/類
@Override
public void process(final CtInterface<?> resourceInterface) {
  final CtAnnotation<Annotation> annotation = getFactory().Code().createAnnotation(getFactory().Code().createCtTypeReference(Api.class));
  final RestService restService = context.getServiceDocumentation().get(resourceInterface.getQualifiedName());
  if (restService != null) {
    String[] tags;
    if (restService.getTags().contains(",")) {
      tags = restService.getTags().split(",");
    } else {
      tags = new String[]{ restService.getTags() };
    }

  annotation
    // .addValue("tags", tags)
    .addValue("hidden", true);
  resourceInterface.addAnnotation(annotation);
} else {
    log.error("No documentation for resource {} found.", resourceInterface.getQualifiedName());
  }
}
 
開發者ID:camunda,項目名稱:camunda-bpm-swagger,代碼行數:21,代碼來源:RestResourceProcessor.java

示例7: customDocket

import io.swagger.annotations.Api; //導入依賴的package包/類
@Bean
public Docket customDocket() {
    ApiInfo apiInfo = new ApiInfo(
            "TODO Query Service",
            "REST service implementation for querying TODO items",
            "1.0.0",
            null,
            new Contact(
                    "Elder Developers",
                    "https://www.github.com/elder-oss",
                    "[email protected]"),
            null,
            null);

    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
            .build()
            .apiInfo(apiInfo);
}
 
開發者ID:elder-oss,項目名稱:sourcerer-samples,代碼行數:21,代碼來源:Application.java

示例8: customDocket

import io.swagger.annotations.Api; //導入依賴的package包/類
@Bean
public Docket customDocket() {
    ApiInfo apiInfo = new ApiInfo(
            "TODO Command Service",
            "REST service implementation for creating and modifying TODO items",
            "1.0.0",
            null,
            new Contact(
                    "Elder Developers",
                    "https://www.github.com/elder-oss",
                    "[email protected]"),
            null,
            null);

    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
            .build()
            .apiInfo(apiInfo);
}
 
開發者ID:elder-oss,項目名稱:sourcerer-samples,代碼行數:21,代碼來源:Application.java

示例9: getEvents

import io.swagger.annotations.Api; //導入依賴的package包/類
@Path("/events")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Permissions({
        @Permission(value = RolePermission.API_AUDIT, acls = RolePermissionAction.READ)
})
public Response getEvents() {
    List<Audit.AuditEvent> events = new ArrayList<>();
    events.addAll(Arrays.asList(io.gravitee.repository.management.model.Api.AuditEvent.values()));
    events.addAll(Arrays.asList(ApiKey.AuditEvent.values()));
    events.addAll(Arrays.asList(Membership.AuditEvent.values()));
    events.addAll(Arrays.asList(Metadata.AuditEvent.values()));
    events.addAll(Arrays.asList(io.gravitee.repository.management.model.Page.AuditEvent.values()));
    events.addAll(Arrays.asList(Plan.AuditEvent.values()));
    events.addAll(Arrays.asList(Subscription.AuditEvent.values()));

    events.sort(Comparator.comparing(Audit.AuditEvent::name));
    return Response.ok(events).build();
}
 
開發者ID:gravitee-io,項目名稱:gravitee-management-rest-api,代碼行數:20,代碼來源:ApiAuditResource.java

示例10: getEvents

import io.swagger.annotations.Api; //導入依賴的package包/類
@Path("/events")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Permissions({
        @Permission(value = RolePermission.MANAGEMENT_AUDIT, acls = RolePermissionAction.READ)
})
public Response getEvents() {
    List<Audit.AuditEvent> events = new ArrayList<>();
    events.addAll(Arrays.asList(io.gravitee.repository.management.model.Api.AuditEvent.values()));
    events.addAll(Arrays.asList(ApiKey.AuditEvent.values()));
    events.addAll(Arrays.asList(Application.AuditEvent.values()));
    events.addAll(Arrays.asList(Group.AuditEvent.values()));
    events.addAll(Arrays.asList(Membership.AuditEvent.values()));
    events.addAll(Arrays.asList(Metadata.AuditEvent.values()));
    events.addAll(Arrays.asList(io.gravitee.repository.management.model.Page.AuditEvent.values()));
    events.addAll(Arrays.asList(Plan.AuditEvent.values()));
    events.addAll(Arrays.asList(Role.AuditEvent.values()));
    events.addAll(Arrays.asList(Subscription.AuditEvent.values()));
    events.addAll(Arrays.asList(Tag.AuditEvent.values()));
    events.addAll(Arrays.asList(Tenant.AuditEvent.values()));
    events.addAll(Arrays.asList(User.AuditEvent.values()));
    events.addAll(Arrays.asList(View.AuditEvent.values()));

    events.sort(Comparator.comparing(Audit.AuditEvent::name));
    return Response.ok(events).build();
}
 
開發者ID:gravitee-io,項目名稱:gravitee-management-rest-api,代碼行數:27,代碼來源:AuditResource.java

示例11: getSubResource

import io.swagger.annotations.Api; //導入依賴的package包/類
protected Class<?> getSubResource(Method method) {
    final Class<?> rawType = method.getReturnType();
    final Class<?> type;
    if (Class.class.equals(rawType)) {
        type = getClassArgument(method.getGenericReturnType());
        if (type == null) {
            return null;
        }
    } else {
        type = rawType;
    }

    if (type.getAnnotation(Api.class) != null) {
        return type;
    }

    // For sub-resources that are not annotated with  @Api, look for any HttpMethods.
    for (Method m : type.getMethods()) {
        if (extractOperationMethod(null, m, null) != null) {
            return type;
        }
    }

    return null;
}
 
開發者ID:wso2,項目名稱:msf4j,代碼行數:26,代碼來源:ExtendedSwaggerReader.java

示例12: extractTags

import io.swagger.annotations.Api; //導入依賴的package包/類
protected Set<String> extractTags(Api api) {
    Set<String> output = new LinkedHashSet<>();

    boolean hasExplicitTags = false;
    for (String tag : api.tags()) {
        if (!"".equals(tag)) {
            hasExplicitTags = true;
            output.add(tag);
        }
    }
    if (!hasExplicitTags) {
        // derive tag from api path + description
        String tagString = api.value().replace("/", "");
        if (!"".equals(tagString)) {
            output.add(tagString);
        }
    }
    return output;
}
 
開發者ID:wso2,項目名稱:msf4j,代碼行數:20,代碼來源:ExtendedSwaggerReader.java

示例13: extractTags

import io.swagger.annotations.Api; //導入依賴的package包/類
protected Set<String> extractTags(Api api) {
    Set<String> output = new LinkedHashSet<String>();

    boolean hasExplicitTags = false;
    for (String tag : api.tags()) {
        if (!"".equals(tag)) {
            hasExplicitTags = true;
            output.add(tag);
        }
    }
    if (!hasExplicitTags) {
        // derive tag from api path + description
        String tagString = api.value().replace("/", "");
        if (!"".equals(tagString)) {
            output.add(tagString);
        }
    }
    return output;
}
 
開發者ID:abhishekShukla,項目名稱:swagger-play,代碼行數:20,代碼來源:PlayReader.java

示例14: testNamespacingByAnnotation

import io.swagger.annotations.Api; //導入依賴的package包/類
@Test
public void testNamespacingByAnnotation() {
    final Settings settings = TestUtils.settings();
    settings.outputFileType = TypeScriptFileType.implementationFile;
    settings.generateJaxrsApplicationInterface = true;
    settings.generateJaxrsApplicationClient = true;
    settings.jaxrsNamespacing = JaxrsNamespacing.byAnnotation;
    settings.jaxrsNamespacingAnnotation = Api.class;
    final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(OrganizationApplication.class));
    final String errorMessage = "Unexpected output: " + output;
    Assert.assertTrue(errorMessage, output.contains("class OrgApiClient implements OrgApi "));
    Assert.assertTrue(errorMessage, output.contains("class OrganizationApplicationClient implements OrganizationApplication "));
    Assert.assertTrue(errorMessage, !output.contains("class OrganizationsResourceClient"));
    Assert.assertTrue(errorMessage, !output.contains("class OrganizationResourceClient"));
    Assert.assertTrue(errorMessage, !output.contains("class PersonResourceClient"));
}
 
開發者ID:vojtechhabarta,項目名稱:typescript-generator,代碼行數:17,代碼來源:JaxrsApplicationTest.java

示例15: execute

import io.swagger.annotations.Api; //導入依賴的package包/類
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
	checkState(!packageNames.isEmpty(), "Must specify package names");

	ClassLoader classLoader = getProjectClassLoader();

	ApiBuilder builder = ApiRoot.builder().version(apiVersion).basePath(apiBasePath);

	ClassCollector collector = new ClassCollector();
	for (String packageName : packageNames) {
		collector.addClasses(classLoader, packageName, Api.class);
		if (!excludeUnannotatedApi) {
			collector.addClasses(classLoader, packageName, Path.class);
		}
	}
	for (Class<?> apiClass : collector.getClasses()) {
		getLog().info("API class: " + apiClass.getName());
		builder.service(apiClass);
	}
	ApiRoot apiRoot = builder.create();
	output(apiRoot);
}
 
開發者ID:greensopinion,項目名稱:swagger-jaxrs-maven,代碼行數:23,代碼來源:SwaggerJaxrsGeneratorMojo.java


注:本文中的io.swagger.annotations.Api類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。