本文整理汇总了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"));
}
示例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));
}
示例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");
}
示例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");
}
示例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"));
}
示例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"));
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}