本文整理匯總了Java中io.swagger.models.Operation.response方法的典型用法代碼示例。如果您正苦於以下問題:Java Operation.response方法的具體用法?Java Operation.response怎麽用?Java Operation.response使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.swagger.models.Operation
的用法示例。
在下文中一共展示了Operation.response方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: map_BodyParameter
import io.swagger.models.Operation; //導入方法依賴的package包/類
@Test
public void map_BodyParameter() throws IOException {
// Arrange
Property property = mock(Property.class);
List<Parameter> parameters = createBodyParameter("object");
Operation newOp = new Operation();
newOp.setParameters(parameters);
newOp.vendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.INFORMATION_PRODUCT,
DBEERPEDIA.BREWERIES.stringValue()));
newOp.response(200, new Response().schema(property));
mockDefinition().host(DBEERPEDIA.OPENAPI_HOST).produces(MediaType.APPLICATION_JSON).path(
"/breweries", new Path().get(newOp));
// Act
requestMapper.map(httpConfigurationMock);
// Assert
verify(httpConfigurationMock).registerResources(resourceCaptor.capture());
Resource resource = resourceCaptor.getValue();
assertThat(resource.getPath(), equalTo("/" + DBEERPEDIA.OPENAPI_HOST + "/breweries"));
}
示例2: map_BodyParameterWithRefObject
import io.swagger.models.Operation; //導入方法依賴的package包/類
@Test
public void map_BodyParameterWithRefObject() throws IOException {
// Arrange
Property property = mock(Property.class);
List<Parameter> parameters = createBodyRefParameter();
Operation newOp = new Operation();
newOp.setParameters(parameters);
newOp.vendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.INFORMATION_PRODUCT,
DBEERPEDIA.BREWERIES.stringValue()));
newOp.response(200, new Response().schema(property));
mockDefinition().host(DBEERPEDIA.OPENAPI_HOST).produces(MediaType.APPLICATION_JSON).path(
"/breweries", new Path().post(newOp));
// Assert
thrown.expect(ConfigurationException.class);
thrown.expectMessage(String.format("No object property in body parameter"));
// Act
requestMapper.map(httpConfigurationMock);
}
示例3: map_BodyParameterNoObject
import io.swagger.models.Operation; //導入方法依賴的package包/類
@Test
public void map_BodyParameterNoObject() throws IOException {
// Arrange
Property property = mock(Property.class);
List<Parameter> parameters = createBodyParameter("object2");
Operation newOp = new Operation();
newOp.setParameters(parameters);
newOp.vendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.INFORMATION_PRODUCT,
DBEERPEDIA.BREWERIES.stringValue()));
newOp.response(200, new Response().schema(property));
mockDefinition().host(DBEERPEDIA.OPENAPI_HOST).produces(MediaType.APPLICATION_JSON).path(
"/breweries", new Path().get(newOp));
// Assert
thrown.expect(ConfigurationException.class);
thrown.expectMessage(String.format("No object property in body parameter"));
// Act
requestMapper.map(httpConfigurationMock);
}
示例4: buildOperation
import io.swagger.models.Operation; //導入方法依賴的package包/類
private Operation buildOperation(ExecutableElement executableElement) {
Operation operation = new Operation();
String operationId = ofNullable(executableElement.getAnnotation(ApiOperation.class))
.map(ApiOperation::nickname)
.filter(StringUtils::isNotBlank)
.orElse(executableElement.getSimpleName().toString());
operation.setOperationId(operationId);
Element controller = executableElement.getEnclosingElement();
Optional<Api> apiAnnotation = ofNullable(controller.getAnnotation(Api.class));
apiAnnotation.ifPresent(annotation -> Stream.of(annotation.tags())
.filter(StringUtils::isNotBlank)
.forEach(operation::addTag));
executableElement.getParameters()
.stream()
.map(this::buildParameter)
.filter(Optional::isPresent)
.map(Optional::get)
.forEach(operation::addParameter);
Response okResponse = new Response();
Property returnProperty = ofNullable(executableElement.getAnnotation(ApiOperation.class))
.map(apiOperation -> annotationUtils.extractType(apiOperation, ApiOperation::response))
.filter(returnType -> returnType.getKind() != TypeKind.VOID)
.map(propertyUtils::toProperty)
.orElseGet(() -> propertyUtils.toProperty(executableElement.getReturnType()));
okResponse.schema(returnProperty);
operation.response(200, okResponse);
return operation;
}
示例5: addResponse
import io.swagger.models.Operation; //導入方法依賴的package包/類
public static void addResponse(Swagger swagger, Operation operation, ApiOperation apiOperation) {
ResponseConfig responseConfig = convert(apiOperation);
generateResponse(swagger, responseConfig);
operation.response(responseConfig.getCode(), responseConfig.getResponse());
}