本文整理匯總了Java中io.swagger.models.Operation類的典型用法代碼示例。如果您正苦於以下問題:Java Operation類的具體用法?Java Operation怎麽用?Java Operation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Operation類屬於io.swagger.models包,在下文中一共展示了Operation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: process
import io.swagger.models.Operation; //導入依賴的package包/類
@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
GetMapping mappingAnnotation = (GetMapping) annotation;
Operation operation = operationGenerator.getOperation();
// path/value是等同的
this.processPath(mappingAnnotation.path(), operationGenerator);
this.processPath(mappingAnnotation.value(), operationGenerator);
this.processMethod(RequestMethod.GET, operationGenerator);
this.processConsumes(mappingAnnotation.consumes(), operation);
this.processProduces(mappingAnnotation.produces(), operation);
if (StringUtils.isEmpty(operationGenerator.getHttpMethod())
&& StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) {
throw new Error("HttpMethod must not both be empty in class and method");
}
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:18,代碼來源:GetMappingMethodAnnotationProcessor.java
示例2: map_ReturnsCorrectParameterName_ForQueryParameter
import io.swagger.models.Operation; //導入依賴的package包/類
@Test
public void map_ReturnsCorrectParameterName_ForQueryParameter() {
// Arrange
QueryParameter queryParameter = new QueryParameter();
queryParameter.setName("param1");
queryParameter.setIn("query");
queryParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
parameter.getIdentifier().stringValue());
Operation operation = new Operation();
operation.addParameter(queryParameter);
MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();
queryParameters.put(queryParameter.getName(), ImmutableList.of("value", "valueB"));
// Act
Map<String, String> result = mapper.map(operation, product, requestParameters);
// Assert
assertThat(result.size(), is(1));
assertThat(result, hasEntry(parameter.getName(), "value"));
}
示例3: testTransform
import io.swagger.models.Operation; //導入依賴的package包/類
@Test
public void testTransform() {
Operation operation = new Operation();
Swagger swagger = createSwagger(operation);
SwaggerModelTransformation transformation = mock(SwaggerModelTransformation.class);
SwaggerModelTransformer transformer = SwaggerModelTransformer.builder()
.addTransformation(transformation)
.build();
transformer.transform(swagger);
InOrder inOrder = inOrder(transformation);
inOrder.verify(transformation, times(1)).beforeHook(swagger);
inOrder.verify(transformation, times(3)).transformOperation(swagger, operation);
inOrder.verify(transformation, times(1)).afterHook(swagger);
}
示例4: getOperation
import io.swagger.models.Operation; //導入依賴的package包/類
public Optional<Operation> getOperation(Path path, HttpMethod verb) {
switch (verb) {
case DELETE:
return Optional.fromNullable(path.getDelete());
case GET:
return Optional.fromNullable(path.getGet());
case HEAD:
return Optional.fromNullable(path.getHead());
case OPTIONS:
return Optional.fromNullable(path.getOptions());
case PATCH:
return Optional.fromNullable(path.getPatch());
case POST:
return Optional.fromNullable(path.getPost());
case PUT:
return Optional.fromNullable(path.getPut());
default:
return Optional.absent();
}
}
示例5: process
import io.swagger.models.Operation; //導入依賴的package包/類
@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
DeleteMapping mappingAnnotation = (DeleteMapping) annotation;
Operation operation = operationGenerator.getOperation();
// path/value是等同的
this.processPath(mappingAnnotation.path(), operationGenerator);
this.processPath(mappingAnnotation.value(), operationGenerator);
this.processMethod(RequestMethod.DELETE, operationGenerator);
this.processConsumes(mappingAnnotation.consumes(), operation);
this.processProduces(mappingAnnotation.produces(), operation);
if (StringUtils.isEmpty(operationGenerator.getHttpMethod())
&& StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) {
throw new Error("HttpMethod must not both be empty in class and method");
}
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:18,代碼來源:DeleteMappingMethodAnnotationProcessor.java
示例6: process
import io.swagger.models.Operation; //導入依賴的package包/類
@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
PutMapping mappingAnnotation = (PutMapping) annotation;
Operation operation = operationGenerator.getOperation();
// path/value是等同的
this.processPath(mappingAnnotation.path(), operationGenerator);
this.processPath(mappingAnnotation.value(), operationGenerator);
this.processMethod(RequestMethod.PUT, operationGenerator);
this.processConsumes(mappingAnnotation.consumes(), operation);
this.processProduces(mappingAnnotation.produces(), operation);
if (StringUtils.isEmpty(operationGenerator.getHttpMethod())
&& StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) {
throw new Error("HttpMethod must not both be empty in class and method");
}
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:18,代碼來源:PutMappingMethodAnnotationProcessor.java
示例7: process
import io.swagger.models.Operation; //導入依賴的package包/類
@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
RequestMapping requestMapping = (RequestMapping) annotation;
Operation operation = operationGenerator.getOperation();
// path/value是等同的
this.processPath(requestMapping.path(), operationGenerator);
this.processPath(requestMapping.value(), operationGenerator);
this.processMethod(requestMapping.method(), operationGenerator);
this.processConsumes(requestMapping.consumes(), operation);
this.processProduces(requestMapping.produces(), operation);
if (StringUtils.isEmpty(operationGenerator.getHttpMethod())
&& StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) {
throw new Error("HttpMethod must not both be empty in class and method");
}
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:19,代碼來源:RequestMappingMethodAnnotationProcessor.java
示例8: build
import io.swagger.models.Operation; //導入依賴的package包/類
public Operation build() {
Operation operation = new Operation();
if (!tags.isEmpty()) {
operation.setTags(newArrayList(tags));
}
for(ParameterBuilder builder: parameters){
operation.addParameter(builder.build());
}
for(Consumer<Operation> consumer: responses){
consumer.accept(operation);
}
operation.setDescription(description);
operation.setSummary(summary);
operation.setProduces(produces);
return operation;
}
示例9: map_ReturnsCorrectParameterName_ForHeaderParameter
import io.swagger.models.Operation; //導入依賴的package包/類
@Test
public void map_ReturnsCorrectParameterName_ForHeaderParameter() {
// Arrange
HeaderParameter headerParameter = new HeaderParameter();
headerParameter.setName("param1");
headerParameter.setIn("header");
headerParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
parameter.getIdentifier().stringValue());
Operation operation = new Operation();
operation.addParameter(headerParameter);
MultivaluedMap<String, String> headerParameters = new MultivaluedHashMap<>();
headerParameters.put(headerParameter.getName(), ImmutableList.of("value", "valueB"));
// Act
Map<String, String> result = mapper.map(operation, product, requestParameters);
// Assert
assertThat(result.size(), is(1));
assertThat(result, hasEntry(parameter.getName(), "value"));
}
示例10: correctResponsesHavePaths
import io.swagger.models.Operation; //導入依賴的package包/類
@Test
public void correctResponsesHavePaths() {
Response response = new Response();
Operation operation = new Operation();
operation.addResponse("200", response);
Path path = new Path();
path.set("get", operation);
Swagger swagger = new Swagger();
swagger.path("/base", path);
SwaggerUtils.correctResponses(swagger);
Assert.assertEquals("response of 200", response.getDescription());
}
示例11: test
import io.swagger.models.Operation; //導入依賴的package包/類
@Test
public void test() {
SwaggerGenerator generator = UnitTestSwaggerUtils.generateSwagger(ResponseMetaImpl.class);
Swagger swagger = generator.getSwagger();
Operation operation = swagger.getPath("/add").getPost();
ResponsesMeta meta = new ResponsesMeta();
meta.init(null, "gen", swagger, operation, int.class);
ResponseMeta resp = meta.findResponseMeta(200);
Assert.assertEquals(int.class, resp.getJavaType().getRawClass());
resp = meta.findResponseMeta(201);
Assert.assertEquals(int.class, resp.getJavaType().getRawClass());
resp = meta.findResponseMeta(400);
Assert.assertEquals(String.class, resp.getJavaType().getRawClass());
resp = meta.findResponseMeta(401);
Assert.assertEquals(Long.class, resp.getJavaType().getRawClass());
Assert.assertEquals(Integer.class, resp.getHeaders().get("h1").getRawClass());
resp = meta.findResponseMeta(500);
Assert.assertEquals(CommonExceptionData.class, resp.getJavaType().getRawClass());
}
示例12: init
import io.swagger.models.Operation; //導入依賴的package包/類
public void init(SchemaMeta schemaMeta, Method method, String operationPath, String httpMethod,
Operation swaggerOperation) {
this.schemaMeta = schemaMeta;
schemaQualifiedName = schemaMeta.getSchemaId() + "." + method.getName();
microserviceQualifiedName = schemaMeta.getMicroserviceName() + "." + schemaQualifiedName;
this.operationPath = operationPath;
this.method = method;
this.httpMethod = httpMethod.toUpperCase(Locale.US);
this.swaggerOperation = swaggerOperation;
executor = ExecutorManager.findExecutor(this);
responsesMeta.init(schemaMeta.getMicroserviceMeta().getClassLoader(),
schemaMeta.getPackageName(),
schemaMeta.getSwagger(),
swaggerOperation,
method.getGenericReturnType());
}
示例13: getOperation
import io.swagger.models.Operation; //導入依賴的package包/類
public Operation getOperation() {
Path p = swagger.getPath(path.toString());
if (p != null) {
switch (method) {
case GET:
return p.getGet();
case POST:
return p.getPost();
case PUT:
return p.getPut();
case DELETE:
return p.getDelete();
case PATCH:
return p.getPatch();
default:
return null;
}
}
return null;
}
示例14: map_ReturnsEmptyMap_WhenParameterHasNoParameterInputVendorExtension
import io.swagger.models.Operation; //導入依賴的package包/類
@Test
public void map_ReturnsEmptyMap_WhenParameterHasNoParameterInputVendorExtension() {
// Arrange
Operation operation = new Operation();
PathParameter pathParameter = new PathParameter();
pathParameter.setVendorExtension("x-dotwebstack-another-vendor-extension",
parameter.getIdentifier().stringValue());
operation.setParameters(ImmutableList.of(pathParameter));
// Act
Map<String, String> result = mapper.map(operation, product, requestParameters);
// Assert
assertThat(result.isEmpty(), is(true));
}
示例15: applyConsumes
import io.swagger.models.Operation; //導入依賴的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);
}
}