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


Java Operation.addResponse方法代碼示例

本文整理匯總了Java中io.swagger.models.Operation.addResponse方法的典型用法代碼示例。如果您正苦於以下問題:Java Operation.addResponse方法的具體用法?Java Operation.addResponse怎麽用?Java Operation.addResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.swagger.models.Operation的用法示例。


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

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

示例2: correctResponses

import io.swagger.models.Operation; //導入方法依賴的package包/類
public static void correctResponses(Operation operation) {
  int okCode = Status.OK.getStatusCode();
  String strOkCode = String.valueOf(okCode);
  Response okResponse = null;

  for (Entry<String, Response> responseEntry : operation.getResponses().entrySet()) {
    Response response = responseEntry.getValue();
    if (StringUtils.isEmpty(response.getDescription())) {
      response.setDescription("response of " + responseEntry.getKey());
    }

    if (operation.getResponses().get(strOkCode) != null) {
      continue;
    }

    int statusCode = NumberUtils.toInt(responseEntry.getKey());
    if ("default".equals(responseEntry.getKey())) {
      statusCode = okCode;
    }
    if (Family.SUCCESSFUL.equals(Family.familyOf(statusCode))) {
      okResponse = response;
    }
  }

  if (okResponse != null) {
    operation.addResponse(strOkCode, okResponse);
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:29,代碼來源:SwaggerUtils.java

示例3: correctResponsesOperationFixEmptyDescription

import io.swagger.models.Operation; //導入方法依賴的package包/類
@Test
public void correctResponsesOperationFixEmptyDescription() {
  Response response = new Response();

  Operation operation = new Operation();
  operation.addResponse("200", response);

  SwaggerUtils.correctResponses(operation);
  Assert.assertEquals("response of 200", response.getDescription());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:11,代碼來源:TestSwaggerUtils.java

示例4: correctResponsesOperationNotChangeExistDescription

import io.swagger.models.Operation; //導入方法依賴的package包/類
@Test
public void correctResponsesOperationNotChangeExistDescription() {
  Response response = new Response();
  response.setDescription("description");

  Operation operation = new Operation();
  operation.addResponse("200", response);

  SwaggerUtils.correctResponses(operation);
  Assert.assertEquals("description", response.getDescription());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:12,代碼來源:TestSwaggerUtils.java

示例5: correctResponsesOperationDefaultTo200

import io.swagger.models.Operation; //導入方法依賴的package包/類
@Test
public void correctResponsesOperationDefaultTo200() {
  Response response = new Response();

  Operation operation = new Operation();
  operation.addResponse("default", response);

  SwaggerUtils.correctResponses(operation);
  Assert.assertSame(response, operation.getResponses().get("200"));
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:11,代碼來源:TestSwaggerUtils.java

示例6: correctResponsesOperation2xxTo200

import io.swagger.models.Operation; //導入方法依賴的package包/類
@Test
public void correctResponsesOperation2xxTo200() {
  Response response = new Response();

  Operation operation = new Operation();
  operation.addResponse("default", new Response());
  operation.addResponse("201", response);
  operation.addResponse("301", new Response());

  SwaggerUtils.correctResponses(operation);
  Assert.assertSame(response, operation.getResponses().get("200"));
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:13,代碼來源:TestSwaggerUtils.java

示例7: buildSwaggerApiBodyParam

import io.swagger.models.Operation; //導入方法依賴的package包/類
public void buildSwaggerApiBodyParam(Operation operation) {
    io.swagger.models.Response response = new io.swagger.models.Response();
    ParameterInterfaceImpl param = new ParameterInterfaceImpl();

    param.setName("Body");
    param.setIn("body");
    param.setRequired(true);
    // TODO review
    param.setDescription("Expected object in lyre file by the endpoint");

    response.setDescription(Response.Status.NOT_ACCEPTABLE.toString());

    operation.addParameter(param);
    operation.addResponse(String.valueOf(Response.Status.NOT_ACCEPTABLE.getStatusCode()), response);
}
 
開發者ID:groovylabs,項目名稱:lyre,代碼行數:16,代碼來源:SwaggerHelper.java

示例8: buildBundleServices

import io.swagger.models.Operation; //導入方法依賴的package包/類
private void buildBundleServices(Swagger swagger) {

        // GET
        Operation get = new Operation();
        get.addResponse("200", resp().description("Bundle of endpoints"));
        get.addResponse("204", resp().description("Empty bundle"));
        get.tag("2 : Bundle Management");

        // DELETE
        Operation delete = new Operation();
        delete.addResponse("200", resp().description("Attempting to delete bundle"));
        delete.tag("5 : Danger Zone");

        // POST
        Operation post = new Operation();
        post.addResponse("200", resp().description("Add new endpoints or update them"));
        post.addResponse("400", resp().description("Malformed bundle entity"));
        post.tag("2 : Bundle Management");

        // PUT
        Operation put = new Operation();
        put.addResponse("200", resp().description("Add a new bundle, will override previous bundle."));
        put.addResponse("400", resp().description("Malformed bundle entity"));
        put.tag("5 : Danger Zone");

        swagger.path("/bundle", new Path()
            .set("delete", delete)
            .set("get", get)
            .set("post", post)
            .set("put", put));

    }
 
開發者ID:groovylabs,項目名稱:lyre,代碼行數:33,代碼來源:SwaggerHelper.java

示例9: buildSwaggerApiPath

import io.swagger.models.Operation; //導入方法依賴的package包/類
public void buildSwaggerApiPath(Swagger swagger, Endpoint endpoint) {

        Operation operation = new Operation();
        operation.tag("API");
        operation.consumes(endpoint.getConsumes());
        io.swagger.models.Response response = new io.swagger.models.Response();

        if (!StringUtils.isEmpty(endpoint.getData()))
            buildSwaggerApiBodyParam(operation);

        response.setDescription(endpoint.getResponse().getStatus().getReasonPhrase());

        operation.addResponse(endpoint.getResponse().getStatus().toString(), response);

        swagger.path(endpoint.getPath(), new Path().set(endpoint.getMethod().toString().toLowerCase(), operation));

    }
 
開發者ID:groovylabs,項目名稱:lyre,代碼行數:18,代碼來源:SwaggerHelper.java

示例10: buildEndpointServices

import io.swagger.models.Operation; //導入方法依賴的package包/類
private void buildEndpointServices(Swagger swagger) {

        BodyParameter bodyParameter = new BodyParameter().name("Body").description("Endpoint entity");
        bodyParameter.setRequired(true);

        // GET
        Operation get = new Operation();
        get.addParameter(new QueryParameter().name("method").required(true).description("Endpoint method").type("string"));
        get.addParameter(new QueryParameter().name("path").required(true).description("Endpoint path").type("string"));
        get.addResponse("200", resp().description("Requested endpoint"));
        get.addResponse("400", resp().description("Malformed parameters"));
        get.addResponse("404", resp().description("Bundle is empty"));
        get.addResponse("404", resp().description("Endpoint does not exist"));

        get.tag("1 : Endpoint Management");

        //DELETE
        Operation delete = new Operation();
        delete.addParameter(new QueryParameter().name("method").required(true).description("Endpoint method").type("string"));
        delete.addParameter(new QueryParameter().name("path").required(true).description("Endpoint path").type("string"));
        delete.addResponse("200", resp().description("Attempting to delete endpoint"));
        delete.addResponse("400", resp().description("Malformed parameters"));
        delete.tag("5 : Danger Zone");

        //POST
        Operation post = new Operation();
        post.addParameter(bodyParameter);
        post.addResponse("200", resp().description("Update a existing endpoint"));
        post.addResponse("400", resp().description("Malformed endpoint entity"));
        post.addResponse("404", resp().description("Endpoint does not exist"));
        post.tag("1 : Endpoint Management");

        //PUT
        Operation put = new Operation();
        put.addParameter(bodyParameter);
        put.addResponse("200", resp().description("Add new endpoint or update it"));
        put.addResponse("400", resp().description("Malformed endpoint entity"));
        put.tag("1 : Endpoint Management");

        swagger.path("/endpoint", new Path()
            .set("delete", delete)
            .set("get", get)
            .set("post", post)
            .set("put", put));

    }
 
開發者ID:groovylabs,項目名稱:lyre,代碼行數:47,代碼來源:SwaggerHelper.java


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