本文整理汇总了Java中org.raml.v2.api.model.v08.resources.Resource类的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于org.raml.v2.api.model.v08.resources包,在下文中一共展示了Resource类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildPathForMethod
import org.raml.v2.api.model.v08.resources.Resource; //导入依赖的package包/类
String buildPathForMethod(Integer statusCode, Method method) {
Resource resource = method.resource();
Preconditions.checkArgument(resource != null, "Resource for method {} cannot be null. ", method.method());
String resourcePath = resource.resourcePath();
String urlRegex = getPathAsRegex(resourcePath);
Optional<ResourceMap> anyStubWithSamePath = requestMapping.getResource(resourcePath);
if(anyStubWithSamePath.isPresent()){
// this path already exists. There should be UriParameters to use for this status code.
Optional<ResourceMap> resourceMapOptional = requestMapping.getResource(resourcePath);
if(resourceMapOptional.isPresent()) {
ResourceMap resourceMap = resourceMapOptional.get();
Optional<UriParameter[]> uriParametersOptional = resourceMap.getStatusCode(statusCode);
if (uriParametersOptional.isPresent()) {
UriParameter[] uriParameters = uriParametersOptional.get();
for(UriParameter uriParameter : uriParameters){
resourcePath = resourcePath.replace(format("{%s}", uriParameter.getKey()), uriParameter.getValue());
}
return getPathAsRegex(resourcePath);
}
}
}
return urlRegex;
}
示例2: getResources
import org.raml.v2.api.model.v08.resources.Resource; //导入依赖的package包/类
public void getResources(final List<Resource> resources, final List<RestResourceDto> result,
final String path, boolean generateResponse) {
if(resources.isEmpty()){
return;
}
for(Resource resource : resources){
String uri = path + resource.relativeUri().value();
List<Method> methods = resource.methods();
if(!methods.isEmpty()){
RestResourceDto restResource = new RestResourceDto();
restResource.setName(uri);
restResource.setUri(uri);
result.add(restResource);
for(Method method : methods){
HttpMethod httpMethod = HttpMethod.getValue(method.method());
if(httpMethod == null){
LOGGER.error("The REST method '" + method.method() + "' is not supported.");
continue;
}
RestMethodDto restMethod = new RestMethodDto();
restMethod.setName(httpMethod.name());
restMethod.setStatus(RestMethodStatus.MOCKED);
restMethod.setResponseStrategy(RestResponseStrategy.RANDOM);
restMethod.setHttpMethod(httpMethod);
if(generateResponse){
final Collection<RestMockResponseDto> mockResponses = createMockResponses(method.responses());
restMethod.getMockResponses().addAll(mockResponses);
}
restResource.getMethods().add(restMethod);
}
}
getResources(resource.resources(), result, uri, generateResponse);
}
}
示例3: V08_RamlResourceModel
import org.raml.v2.api.model.v08.resources.Resource; //导入依赖的package包/类
public V08_RamlResourceModel(Resource resource, List<RamlSecurityModel> securitySchemes) {
this.resource = resource;
this.securitySchemes = securitySchemes;
}
示例4: addStubIfHaveExamples
import org.raml.v2.api.model.v08.resources.Resource; //导入依赖的package包/类
void addStubIfHaveExamples(Resource resource) {
logger.debug("Processing resource {} ", resource.displayName());
List<Method> methods = resource.methods();
methods.forEach(this::addStubIfHaveExamples);
resource.resources().forEach(this::addStubIfHaveExamples);
}