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


Java Operation.addParameter方法代碼示例

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


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

示例1: 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"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:24,代碼來源:RequestParameterMapperTest.java

示例2: 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"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:24,代碼來源:RequestParameterMapperTest.java

示例3: decorateOperation

import io.swagger.models.Operation; //導入方法依賴的package包/類
public void decorateOperation(Operation operation, Method method, Iterator<SwaggerExtension> chain) {
    boolean requireAppToken = isAppTokenDefaultRequired;
    AppTokenRequired methodAnnotation = method.getAnnotation(AppTokenRequired.class);
    AppTokenRequired classAnnotation = method.getDeclaringClass().getAnnotation(AppTokenRequired.class);
    if (methodAnnotation != null) {
        requireAppToken = methodAnnotation.value();
    } else if (classAnnotation != null) {
        requireAppToken = classAnnotation.value();
    }
    if (requireAppToken) {
        HeaderParameter headerParameter = new HeaderParameter();
        headerParameter.setName(Constants.APPTOKENID_HEADER);
        headerParameter.setType("string");
        headerParameter.setAllowEmptyValue(false);
        headerParameter.required(true);
        headerParameter.setDescription("Application token id");
        operation.addParameter(headerParameter);
    }
    super.decorateOperation(operation, method, chain);
}
 
開發者ID:code-obos,項目名稱:servicebuilder,代碼行數:21,代碼來源:SwaggerImplicitAppTokenHeader.java

示例4: decorateOperation

import io.swagger.models.Operation; //導入方法依賴的package包/類
public void decorateOperation(Operation operation, Method method, Iterator<SwaggerExtension> chain) {
    boolean requireUserToken = isUserTokenDefaultRequired;
    UserTokenRequired annotation = AnnotationUtil.getAnnotation(UserTokenRequired.class, method);
    if (annotation != null) {
        requireUserToken = annotation.value();
    }
    if (requireUserToken) {
        HeaderParameter headerParameter = new HeaderParameter();
        headerParameter.setName(Constants.USERTOKENID_HEADER);
        headerParameter.setType("string");
        headerParameter.setAllowEmptyValue(false);
        headerParameter.required(true);
        headerParameter.setDescription("User token id");
        operation.addParameter(headerParameter);
    }
    super.decorateOperation(operation, method, chain);
}
 
開發者ID:code-obos,項目名稱:servicebuilder,代碼行數:18,代碼來源:SwaggerImplicitUserTokenHeader.java

示例5: 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;
}
 
開發者ID:pegasystems,項目名稱:api2swagger,代碼行數:21,代碼來源:OperationBuilder.java

示例6: map_ReturnsCorrectParameterName_ForPathParameters

import io.swagger.models.Operation; //導入方法依賴的package包/類
@Test
public void map_ReturnsCorrectParameterName_ForPathParameters() {
  // Arrange
  PathParameter pathParameter = new PathParameter();

  pathParameter.setName("param1");
  pathParameter.setIn("path");

  // Note this parameter has multiple vendor extensions
  pathParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
      parameter.getIdentifier().stringValue());
  pathParameter.setVendorExtension("x-dotwebstack-another-vendor-extension", "foo");

  // Note this operation has multiple parameters
  Operation operation = new Operation();
  operation.addParameter(pathParameter);

  PathParameter pathParameter2 = new PathParameter();

  pathParameter2.setName("param2");
  pathParameter2.setIn("path");
  pathParameter2.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
      parameter2.getIdentifier().stringValue());

  operation.addParameter(pathParameter2);

  MultivaluedMap<String, String> pathParameters = new MultivaluedHashMap<>();

  // Note there are multiple values for this parameter, to test that the first value is used only
  pathParameters.put(pathParameter.getName(), ImmutableList.of("value", "valueB"));
  pathParameters.put(pathParameter2.getName(), ImmutableList.of("value2"));

  // Act
  Map<String, String> result = mapper.map(operation, product, requestParameters);

  // Assert
  assertThat(result.size(), is(2));
  assertThat(result, hasEntry(parameter.getName(), "value"));
  assertThat(result, hasEntry(parameter2.getName(), "value2"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:41,代碼來源:RequestParameterMapperTest.java

示例7: decorateOperation

import io.swagger.models.Operation; //導入方法依賴的package包/類
public void decorateOperation(Operation operation, Method method, Iterator<SwaggerExtension> chain) {
    HeaderParameter headerParameter = new HeaderParameter();
    headerParameter.setName(Constants.CLIENT_APPNAME_HEADER);
    headerParameter.setType("String");
    headerParameter.setAllowEmptyValue(false);
    headerParameter.setDescription("User token id");
    headerParameter.setDefaultValue("swagger");
    operation.addParameter(headerParameter);
    super.decorateOperation(operation, method, chain);
}
 
開發者ID:code-obos,項目名稱:servicebuilder,代碼行數:11,代碼來源:SwaggerImplicitAppNameHeader.java

示例8: 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

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