当前位置: 首页>>代码示例>>Java>>正文


Java HttpMethod类代码示例

本文整理汇总了Java中io.swagger.models.HttpMethod的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod类的具体用法?Java HttpMethod怎么用?Java HttpMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpMethod类属于io.swagger.models包,在下文中一共展示了HttpMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testApplyParameters

import io.swagger.models.HttpMethod; //导入依赖的package包/类
@SuppressWarnings({  "serial" })
	@Test
	public void testApplyParameters(){
		Swagger swagger = new Swagger();
		Reader.read(swagger, new HashMap<Class<?>, Object>(){{
			put(InterfaceServiceTest.class, new InterfaceServiceImplTest());
		}}, "/h");
		
//		System.out.println(Json.pretty(swagger));
		
		Path path = swagger.getPaths().get("/h/com.deepoove.swagger.dubbo.api.InterfaceServiceTest/test");
		Assert.assertNotNull(path);
		Operation operation = path.getOperationMap().get(HttpMethod.POST);
		Assert.assertNotNull(operation);
		Assert.assertNotNull(operation.getParameters());
		
		List<Parameter> parameters = operation.getParameters();
		Assert.assertTrue(parameters.get(0).getName().equals("para"));
		Assert.assertTrue(parameters.get(1).getName().equals("code"));
		
	}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:22,代码来源:ReaderTest.java

示例2: newGetRequestHandler_createsGetRequestHandler_WithValidData

import io.swagger.models.HttpMethod; //导入依赖的package包/类
@Test
public void newGetRequestHandler_createsGetRequestHandler_WithValidData() {
  // Arrange
  Operation operation = new Operation();
  ApiOperation apiOperation = new ApiOperation(new ApiPathImpl("/", ""), new ApiPathImpl("/", ""),
      HttpMethod.GET, operation);
  InformationProduct product = new TestInformationProduct(DBEERPEDIA.ORIGIN_INFORMATION_PRODUCT,
      DBEERPEDIA.BREWERIES_LABEL.stringValue(), ResultType.GRAPH, ImmutableList.of(),
      templateProcessorMock);
  Map<MediaType, Property> schemaMap = ImmutableMap.of();

  // Act
  GetRequestHandler result = getRequestHandlerFactory.newGetRequestHandler(apiOperation, product,
      schemaMap, swaggerMock);


  // Assert
  assertThat(result.getInformationProduct(), sameInstance(product));
  assertThat(result.getSchemaMap(), is(schemaMap));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:GetRequestHandlerFactoryTest.java

示例3: ShouldBeAbleToParseRequestWithParamtersInQueryString

import io.swagger.models.HttpMethod; //导入依赖的package包/类
@Test
public void ShouldBeAbleToParseRequestWithParamtersInQueryString() {
    SwaggerRequestSchema parsedRequest = swaggerSchemaParser.parseRequest("/user/login", HttpMethod.GET);
    ArrayList<RequestParameter> requestParameters = parsedRequest.getParameters();
    Assert.assertEquals(requestParameters.size(), 2);
    Assert.assertEquals(requestParameters.get(0).getParameterIn(), "query");
    Assert.assertEquals(requestParameters.get(0).getName(), "username");
    Assert.assertEquals(requestParameters.get(0).getIsRequired(), true);
    Assert.assertNotNull(requestParameters.get(0).getSwaggerSchema());
    Assert.assertEquals(requestParameters.get(0).getSwaggerSchema().getType(), "string");

    Assert.assertEquals(requestParameters.get(1).getParameterIn(), "query");
    Assert.assertEquals(requestParameters.get(1).getName(), "password");
    Assert.assertEquals(requestParameters.get(1).getIsRequired(), true);
    Assert.assertNotNull(requestParameters.get(1).getSwaggerSchema());
    Assert.assertEquals(requestParameters.get(1).getSwaggerSchema().getType(), "string");

}
 
开发者ID:bsneha90,项目名称:RecursiveSwaggerSchemaParser,代码行数:19,代码来源:SwaggerSchemaRequestParserTest.java

示例4: ShouldBeAbleToParseRequestWithParamtersInFormData

import io.swagger.models.HttpMethod; //导入依赖的package包/类
@Test
public void ShouldBeAbleToParseRequestWithParamtersInFormData() {
    SwaggerRequestSchema parsedRequest = swaggerSchemaParser.parseRequest("/pet/{petId}/uploadImage", HttpMethod.POST);
    ArrayList<RequestParameter> requestParameters = parsedRequest.getParameters();
    Assert.assertEquals(requestParameters.size(), 3);
    Assert.assertEquals(requestParameters.get(1).getParameterIn(), "formData");
    Assert.assertEquals(requestParameters.get(1).getName(), "additionalMetadata");
    Assert.assertEquals(requestParameters.get(1).getIsRequired(), false);
    Assert.assertNotNull(requestParameters.get(1).getSwaggerSchema());
    Assert.assertEquals(requestParameters.get(1).getSwaggerSchema().getType(), "string");

    Assert.assertEquals(requestParameters.get(2).getParameterIn(), "formData");
    Assert.assertEquals(requestParameters.get(2).getName(), "file");
    Assert.assertEquals(requestParameters.get(2).getIsRequired(), false);
    Assert.assertNotNull(requestParameters.get(2).getSwaggerSchema());
    Assert.assertEquals(requestParameters.get(2).getSwaggerSchema().getType(), "file");

}
 
开发者ID:bsneha90,项目名称:RecursiveSwaggerSchemaParser,代码行数:19,代码来源:SwaggerSchemaRequestParserTest.java

示例5: ShouldBeAbleToParseRequestWithParamtersInBody

import io.swagger.models.HttpMethod; //导入依赖的package包/类
@Test
public void ShouldBeAbleToParseRequestWithParamtersInBody() {
    SwaggerRequestSchema parsedRequest = swaggerSchemaParser.parseRequest("/pet", HttpMethod.POST);
    ArrayList<RequestParameter> requestParameters = parsedRequest.getParameters();
    Assert.assertEquals(requestParameters.size(), 1);
    Assert.assertEquals(requestParameters.get(0).getParameterIn(), "body");
    Assert.assertEquals(requestParameters.get(0).getName(), "body");
    Assert.assertEquals(requestParameters.get(0).getIsRequired(), true);
    SwaggerSchema swaggerSchema = requestParameters.get(0).getSwaggerSchema();
    Assert.assertNotNull(swaggerSchema);
    Assert.assertEquals(swaggerSchema.getType(), "ref");
    HashMap<String, JsonNode> parsedSchema = swaggerSchema.getParsedSchema();
    Assert.assertEquals(parsedSchema.size(), 3);
    Assert.assertEquals(ExpectedPet, parsedSchema.get("root"));
    Assert.assertEquals(ExpectedCatergory, parsedSchema.get("category"));
    Assert.assertEquals(ExpectedTag, parsedSchema.get("tags"));
}
 
开发者ID:bsneha90,项目名称:RecursiveSwaggerSchemaParser,代码行数:18,代码来源:SwaggerSchemaRequestParserTest.java

示例6: ShouldBeAbleToParseRequestWithParamtersInBodyWithSchemaTypeArray

import io.swagger.models.HttpMethod; //导入依赖的package包/类
@Test
public void ShouldBeAbleToParseRequestWithParamtersInBodyWithSchemaTypeArray() {
    SwaggerRequestSchema parsedRequest = swaggerSchemaParser.parseRequest("/user/createWithList", HttpMethod.POST);
    ArrayList<RequestParameter> requestParameters = parsedRequest.getParameters();
    Assert.assertEquals(requestParameters.size(), 1);
    Assert.assertEquals(requestParameters.get(0).getParameterIn(), "body");
    Assert.assertEquals(requestParameters.get(0).getName(), "body");
    Assert.assertEquals(requestParameters.get(0).getIsRequired(), true);
    SwaggerSchema swaggerSchema = requestParameters.get(0).getSwaggerSchema();
    Assert.assertNotNull(swaggerSchema);
    Assert.assertEquals(swaggerSchema.getType(), "array");
    Assert.assertEquals(swaggerSchema.getItemsType(), "ref");
    HashMap<String, JsonNode> parsedSchema = swaggerSchema.getParsedSchema();
    Assert.assertEquals(parsedSchema.size(), 1);
    Assert.assertEquals(User, parsedSchema.get("root"));
}
 
开发者ID:bsneha90,项目名称:RecursiveSwaggerSchemaParser,代码行数:17,代码来源:SwaggerSchemaRequestParserTest.java

示例7: shouldBeAbleToParseResponseWithSchemaAsSimpleRef

import io.swagger.models.HttpMethod; //导入依赖的package包/类
@Test
public void shouldBeAbleToParseResponseWithSchemaAsSimpleRef() {
    HashMap<String, SwaggerSchema> parsedResponse = swaggerSchemaParser.parseReponseForGivenPathHTTPMethodAndResponseType("/pet/{petId}", HttpMethod.GET, ResponseType.OK).getSwaggerStructurePerReponseType();
    Assert.assertEquals(parsedResponse.size(), 1);
    SwaggerSchema swaggerSchema = parsedResponse.get(ResponseType.OK.getCodeValue());
    Assert.assertNotNull(swaggerSchema);
    HashMap<String, JsonNode> parsedSchema = swaggerSchema.getParsedSchema();
    Assert.assertNotNull(parsedSchema);
    Assert.assertEquals(swaggerSchema.getType(), "ref");
    Assert.assertEquals(swaggerSchema.getDescription(), "successful operation");
    Assert.assertEquals(parsedSchema.size(), 3);
    Assert.assertEquals(parsedSchema.get("root"), ExpectedPet);
    Assert.assertEquals(parsedSchema.get("category"), ExpectedCatergory);
    Assert.assertEquals(parsedSchema.get("tags"), ExpectedTag);

}
 
开发者ID:bsneha90,项目名称:RecursiveSwaggerSchemaParser,代码行数:17,代码来源:SwaggerSchemaResponseParserTest.java

示例8: shouldBeAbleToParseResponseWithSchemaAsArrayRef

import io.swagger.models.HttpMethod; //导入依赖的package包/类
@Test
public void shouldBeAbleToParseResponseWithSchemaAsArrayRef() {
    HashMap<String, SwaggerSchema> parsedResponse = swaggerSchemaParser.parseReponseForGivenPathHTTPMethodAndResponseType("/pet/findByStatus", HttpMethod.GET, ResponseType.OK).getSwaggerStructurePerReponseType();
    Assert.assertEquals(parsedResponse.size(), 1);
    SwaggerSchema swaggerSchema = parsedResponse.get(ResponseType.OK.getCodeValue());
    Assert.assertNotNull(swaggerSchema);
    HashMap<String, JsonNode> parsedSchema = swaggerSchema.getParsedSchema();
    Assert.assertNotNull(parsedSchema);
    Assert.assertEquals(swaggerSchema.getType(), "array");
    Assert.assertEquals(swaggerSchema.getDescription(), "successful operation");
    Assert.assertEquals(parsedSchema.size(), 3);
    Assert.assertEquals(parsedSchema.get("root"), ExpectedPet);
    Assert.assertEquals(parsedSchema.get("category"), ExpectedCatergory);
    Assert.assertEquals(parsedSchema.get("tags"), ExpectedTag);

}
 
开发者ID:bsneha90,项目名称:RecursiveSwaggerSchemaParser,代码行数:17,代码来源:SwaggerSchemaResponseParserTest.java

示例9: mergePathDefinitions

import io.swagger.models.HttpMethod; //导入依赖的package包/类
public Map<String, Path> mergePathDefinitions(Swagger target, Swagger source) {
	LinkedHashMap<String, Path> mergedDefinitions = new LinkedHashMap<>();
	mergedDefinitions.putAll(target.getPaths());

	Map<String, Path> pathsToBeMerged = source.getPaths();

	for (Entry<String, Path> entry : pathsToBeMerged.entrySet()) {
		if (!mergedDefinitions.containsKey(entry.getKey())) {
			logger.info("source path %s is not present in existing Swagger JSON file.", entry.getKey());
			mergedDefinitions.put(entry.getKey(), entry.getValue());
		} else {
			
			logger.info("source path %s is present in existing Swagger JSON file...merging operations", entry.getKey());
			
			Map<HttpMethod, Operation> modifedOperations = mergeOperationPaths(mergedDefinitions.get(entry.getKey()),
					entry.getValue());
			
			for(Entry<HttpMethod, Operation> operation : modifedOperations.entrySet()){
				mergedDefinitions.get(entry.getKey()).set(operation.getKey().name().toLowerCase(), operation.getValue());
			}				
		}
	}

	return mergedDefinitions;

}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:27,代码来源:SwaggerUpdater.java

示例10: mergeOperationPaths

import io.swagger.models.HttpMethod; //导入依赖的package包/类
private Map<HttpMethod, Operation> mergeOperationPaths(Path target, Path source) {
	Map<HttpMethod, Operation> mergedOperations = target.getOperationMap();

	for (Entry<HttpMethod, Operation> entry : source.getOperationMap().entrySet()) {
		if (!mergedOperations.containsKey(entry.getKey())) {
			logger.info("source operation %s is not present in existing Swagger JSON path", entry.getKey());
			mergedOperations.put(entry.getKey(), entry.getValue());
		} else {
			logger.info("source operation %s is present in existing Swagger JSON path, we shall merge operation responses", entry.getKey());
			Map<String, Response> modifiedResponses = mergeOperationResponse(mergedOperations.get(entry.getKey()),
					entry.getValue());
			mergedOperations.get(entry.getKey()).getResponses().putAll(modifiedResponses);
			mergedOperations.get(entry.getKey()).setParameters(entry.getValue().getParameters());
			logger.info("source operation %s is present in existing Swagger JSON path, merging of operation responses completed", entry.getKey());
		}
	}
	return mergedOperations;
}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:19,代码来源:SwaggerUpdater.java

示例11: getOperation

import io.swagger.models.HttpMethod; //导入依赖的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();
    }
}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:21,代码来源:Paths.java

示例12: convert2EndpointList

import io.swagger.models.HttpMethod; //导入依赖的package包/类
private List<Endpoint> convert2EndpointList(Map<String, Path> map) {
    List<Endpoint> endpoints = new ArrayList<Endpoint>();
    if (null == map) return endpoints;
    for (Entry<String, Path> entry : map.entrySet()) {
        String url = entry.getKey();
        Path path = entry.getValue();

        Map<HttpMethod, Operation> operationMap = path.getOperationMap();
        for (Entry<HttpMethod, Operation> entryOper : operationMap.entrySet()) {
            HttpMethod httpMethod = entryOper.getKey();
            Operation operation = entryOper.getValue();

            Endpoint endpoint = new Endpoint();
            endpoint.setPathUrl(url);
            endpoint.setMethod(httpMethod);
            endpoint.setSummary(operation.getSummary());
            endpoint.setPath(path);
            endpoint.setOperation(operation);
            endpoints.add(endpoint);
        }
    }
    return endpoints;
}
 
开发者ID:Sayi,项目名称:swagger-diff,代码行数:24,代码来源:SwaggerDiff.java

示例13: buildHeaders

import io.swagger.models.HttpMethod; //导入依赖的package包/类
private List<String> buildHeaders(
    Swagger swagger, Map.Entry<String, Path> path, Map.Entry<HttpMethod, Operation> operation
) {
  List<String> headers = new ArrayList<>();

  headers.add(
      operation.getKey().toString() + " " + swagger.getBasePath() + path.getKey() + " HTTP/1.1");
  headers.add("Host: " + swagger.getHost().split(":")[0]);

  if (operation.getValue().getProduces() != null && !operation.getValue().getProduces()
      .isEmpty()) {
    headers.add("Accept: " + String.join(",", operation.getValue().getProduces()));
  } else if (swagger.getProduces() != null && !swagger.getProduces().isEmpty()) {
    headers.add("Accept: " + String.join(",", swagger.getProduces()));
  }

  if (operation.getValue().getConsumes() != null && !operation.getValue().getConsumes()
      .isEmpty()) {
    headers.add("Content-Type: " + String.join(",", operation.getValue().getConsumes()));
  } else if (swagger.getConsumes() != null && !swagger.getConsumes().isEmpty()) {
    headers.add("Content-Type: " + String.join(",", swagger.getConsumes()));
  }

  return headers;
}
 
开发者ID:AresS31,项目名称:swurg,代码行数:26,代码来源:ExtensionHelper.java

示例14: buildRequest

import io.swagger.models.HttpMethod; //导入依赖的package包/类
public byte[] buildRequest(
    Swagger swagger, Map.Entry<String, Path> path, Map.Entry<HttpMethod, Operation> operation
) {
  List<String> headers = buildHeaders(swagger, path, operation);
  byte[] httpMessage = this.burpExtensionHelpers.buildHttpMessage(headers, null);

  for (Parameter parameter : operation.getValue().getParameters()) {
    if (parameter.getIn().equals("query")) {
      httpMessage = this.burpExtensionHelpers.addParameter(httpMessage, this.burpExtensionHelpers
          .buildParameter(parameter.getName(), "fuzzMe", (byte) 0));
    } else if (parameter.getIn().equals("body")) {
      httpMessage = this.burpExtensionHelpers.addParameter(httpMessage, this.burpExtensionHelpers
          .buildParameter(parameter.getName(), "fuzzMe", (byte) 1));
    }
  }

  return httpMessage;
}
 
开发者ID:AresS31,项目名称:swurg,代码行数:19,代码来源:ExtensionHelper.java

示例15: findSwaggerOperation

import io.swagger.models.HttpMethod; //导入依赖的package包/类
private boolean findSwaggerOperation(String operationId) {
    swaggerOperation = null;

    for (String resourcePath : swagger.getPaths().keySet()) {
        Path path = swagger.getPath(resourcePath);
        for (HttpMethod httpMethod : path.getOperationMap().keySet()) {
            Operation operation = path.getOperationMap().get(httpMethod);
            if (operationId.equalsIgnoreCase(operation.getOperationId())) {
                restStepDefs.setMethod(httpMethod.name().toUpperCase());
                restStepDefs.setPath(resourcePath);
                swaggerOperation = operation;
            }
        }
    }

    return swaggerOperation != null;
}
 
开发者ID:readyapi,项目名称:testserver-cucumber,代码行数:18,代码来源:SwaggerStepDefs.java


注:本文中的io.swagger.models.HttpMethod类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。