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


Java Operation.response方法代碼示例

本文整理匯總了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"));

}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:23,代碼來源:OpenApiRequestMapperTest.java

示例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);

}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:22,代碼來源:OpenApiRequestMapperTest.java

示例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);

}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:22,代碼來源:OpenApiRequestMapperTest.java

示例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;
}
 
開發者ID:Cosium,項目名稱:openapi-annotation-processor,代碼行數:33,代碼來源:SpringParser.java

示例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());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:6,代碼來源:AnnotationUtils.java


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