use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-edr10 by opengeospatial.
the class OpenApiUtils method isParameterSupportedForCollection.
public static boolean isParameterSupportedForCollection(OpenApi3 apiModel, String collectionName, String queryParam) {
String requestedPath = createCollectionPath(collectionName);
List<Path> paths = identifyTestPoints(apiModel, requestedPath, new PathMatcher());
for (Path path : paths) {
Collection<Parameter> parameters = path.getGet().getParameters();
for (Parameter parameter : parameters) {
if (queryParam.equalsIgnoreCase(parameter.getName())) {
return true;
}
}
}
return false;
}
use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-edr10 by opengeospatial.
the class OpenApiUtils method isFreeFormParameterSupportedForCollection.
public static boolean isFreeFormParameterSupportedForCollection(OpenApi3 apiModel, String collectionName) {
String requestedPath = createCollectionPath(collectionName);
List<Path> paths = identifyTestPoints(apiModel, requestedPath, new PathMatcher());
for (Path path : paths) {
Collection<Parameter> parameters = path.getGet().getParameters();
for (Parameter parameter : parameters) {
if (parameter.getSchema() != null && parameter.getSchema().isAdditionalProperties()) {
return true;
}
}
}
return false;
}
use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-edr10 by opengeospatial.
the class OpenApiUtils method identifyServerUrls.
/**
* A.4.3.2. Identify Server URIs:
*
* a) Purpose: To identify all server URIs applicable to an OpenAPI Operation
* Object
*
* b) Pre-conditions:
*
* Server Objects from the root level of the OpenAPI document have been obtained
*
* A Path Item Object has been retrieved
*
* An Operation Object has been retrieved
*
* The Operation Object is associated with the Path Item Object
*
* A list of URLs for the servers to be included in the compliance test has been
* provided
*
* c) Method:
*
* 1) Identify the Server Objects which are in-scope for this operationObject
*
* IF Server Objects are defined at the Operation level, then those and only
* those Server Objects apply to that Operation.
*
* IF Server Objects are defined at the Path Item level, then those and only
* those Server Objects apply to that Path Item.
*
* IF Server Objects are not defined at the Operation level, then the Server
* Objects defined for the parent Path Item apply to that Operation.
*
* IF Server Objects are not defined at the Path Item level, then the Server
* Objects defined for the root level apply to that Path.
*
* IF no Server Objects are defined at the root level, then the default server
* object is assumed as described in the OpenAPI specification.
*
* 2) Process each Server Object using A.4.3.3.
*
* 3) Delete any Server URI which does not reference a server on the list of
* servers to test.
*
* d) References: None
*
* @param apiModel never <code>null</code>
* @param iut never <code>null</code>
* @param pathItemObjects never <code>null</code>
*/
private static List<PathItemAndServer> identifyServerUrls(OpenApi3 apiModel, URI iut, List<Path> pathItemObjects) {
List<PathItemAndServer> pathItemAndServers = new ArrayList<>();
for (Path pathItemObject : pathItemObjects) {
Map<String, Operation> operationObjects = pathItemObject.getOperations();
for (Operation operationObject : operationObjects.values()) {
List<String> serverUrls = identifyServerObjects(apiModel, pathItemObject, operationObject);
for (String serverUrl : serverUrls) {
if (DEFAULT_SERVER_URL.equalsIgnoreCase(serverUrl)) {
serverUrl = iut.toString();
} else if (serverUrl.startsWith("/")) {
URI resolvedUri = iut.resolve(serverUrl);
serverUrl = resolvedUri.toString();
}
PathItemAndServer pathItemAndServer = new PathItemAndServer(pathItemObject, operationObject, serverUrl);
pathItemAndServers.add(pathItemAndServer);
}
}
}
return pathItemAndServers;
}
use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-edr10 by opengeospatial.
the class OpenApiUtils method identifyTestPoints.
private static List<Path> identifyTestPoints(OpenApi3 apiModel, String path, PathMatcherFunction<Boolean, String, String> pathMatch) {
List<Path> pathItems = new ArrayList<>();
Map<String, Path> pathItemObjects = apiModel.getPaths();
for (Path pathItemObject : pathItemObjects.values()) {
String pathString = pathItemObject.getPathString();
if (pathMatch.apply(pathString, path)) {
pathItems.add(pathItemObject);
}
}
return pathItems;
}
use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-edr10 by opengeospatial.
the class CollectionsTime method dateTimeParameterDefinition.
/**
* <pre>
* Abstract Test 42: Validate that the dateTime query parameters are constructed correctly. (position)
* Abstract Test 58: Validate that the dateTime query parameters are constructed correctly. (area)
* Abstract Test 74: Validate that the dateTime query parameters are constructed correctly. (cube)
* Abstract Test 139: Validate that the dateTime query parameters are constructed correctly. (instances)
* </pre>
*
* @param testPoint the testPoint under test, never <code>null</code>
* @param model api definition, never <code>null</code>
*/
public void dateTimeParameterDefinition(TestPoint testPoint, OpenApi3 model) {
Parameter datetime = null;
String paramName = "datetime";
for (Path path : model.getPaths().values()) {
if (path.getPathString().endsWith(testPoint.getPath())) {
for (Operation op : path.getOperations().values()) {
for (Parameter param : op.getParameters()) {
if (hasName(param)) {
if (param.getName().equals(paramName)) {
datetime = param;
}
}
}
}
}
}
if (datetime != null) {
String msg = "Expected property '%s' with value '%s' but was '%s'";
assertEquals(datetime.getName(), paramName, String.format(msg, "name", paramName, datetime.getName()));
assertEquals(datetime.getIn(), "query", String.format(msg, "in", "query", datetime.getIn()));
assertFalse(isRequired(datetime), String.format(msg, "required", "false", datetime.getRequired()));
assertEquals(datetime.getStyle(), "form", String.format(msg, "style", "form", datetime.getStyle()));
assertFalse(isExplode(datetime), String.format(msg, "explode", "false", datetime.getExplode()));
}
}
Aggregations