use of com.reprezen.kaizen.oasparser.model3.Parameter in project ets-ogcapi-edr10 by opengeospatial.
the class OpenApiUtils method collectTemplateReplacements.
private static List<Map<String, String>> collectTemplateReplacements(PathItemAndServer pathItemAndServer, UriTemplate uriTemplate) {
List<Map<String, String>> templateReplacements = new ArrayList<>();
Collection<Parameter> parameters = pathItemAndServer.operationObject.getParameters();
for (String templateVariable : uriTemplate.getTemplateVariables()) {
for (Parameter parameter : parameters) {
if (templateVariable.equals(parameter.getName())) {
Schema schema = parameter.getSchema();
if (schema.hasEnums()) {
addEnumTemplateValues(templateReplacements, templateVariable, schema);
} else if (schema.getDefault() != null) {
addDefaultTemplateValue(templateReplacements, templateVariable, schema);
} else {
// TODO: What should be done if the parameter does not have a default value and
// no
// enumerated set of valid values?
}
}
}
}
return templateReplacements;
}
use of com.reprezen.kaizen.oasparser.model3.Parameter in project ets-ogcapi-edr10 by opengeospatial.
the class CollectionsTime method coordsParameterDefinition.
/**
* <pre>
* Abstract Test 38: Validate that the coords query parameters are constructed correctly. (position)
* Abstract Test 54: Validate that the coords query parameters are constructed correctly. (area)
* Abstract Test 70: Validate that the coords query parameters are constructed correctly. (cube)
* Abstract Test 92: Validate that the coords query parameters are constructed correctly. (trajectory)
* Abstract Test 116: Validate that the coords query parameters are constructed correctly. (corridor)
* </pre>
*
* @param testPoint the testPoint under test, never <code>null</code>
* @param model api definition, never <code>null</code>
*/
public void coordsParameterDefinition(TestPoint testPoint, OpenApi3 model) {
Parameter coords = null;
String paramName = "coords";
boolean hasCoordsParameter = false;
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)) {
coords = param;
}
}
}
}
}
}
if (!testPoint.getPath().endsWith("/locations")) {
assertNotNull(coords, "Required " + paramName + " parameter for collections with path '" + testPoint.getPath() + "' in OpenAPI document is missing");
if (coords != null) {
String msg = "Expected property '%s' with value '%s' but was '%s'";
assertEquals(coords.getName(), paramName, String.format(msg, "name", paramName, coords.getName()));
assertEquals(coords.getIn(), "query", String.format(msg, "in", "query", coords.getIn()));
assertTrue(isRequired(coords), String.format(msg, "required", "true", coords.getRequired()));
// assertEquals( coords.getStyle(), "form", String.format( msg, "style","form",
// coords.getStyle() ) ); //TODO SHOULD BE Enabled
assertFalse(isExplode(coords), String.format(msg, "explode", "false", coords.getExplode()));
Schema schema = coords.getSchema();
assertEquals(schema.getType(), "string", String.format(msg, "schema -> type", "string", schema.getType()));
}
}
}
use of com.reprezen.kaizen.oasparser.model3.Parameter in project ets-ogcapi-edr10 by opengeospatial.
the class CollectionsTime method withinUnitsParameterDefinition.
/**
* <pre>
* Requirement A.23: /req/edr/within-units-definition Parameter withinUnits
* definition
* </pre>
* NOTE: Not referenced by ATS
*
* @param testPoint the testPoint under test, never <code>null</code>
* @param model api definition, never <code>null</code>
*/
public void withinUnitsParameterDefinition(TestPoint testPoint, OpenApi3 model) {
Parameter withinUnits = null;
String paramName = "within-units";
for (Path path : model.getPaths().values()) {
if (testPoint.getPath().equals(path.getPathString())) {
for (Operation op : path.getOperations().values()) {
for (Parameter param : op.getParameters()) {
if (hasName(param)) {
if (param.getName().equals(paramName)) {
withinUnits = param;
}
}
}
}
}
}
if (withinUnits != null) {
String msg = "Expected property '%s' with value '%s' but was '%s'";
assertEquals(withinUnits.getName(), paramName, String.format(msg, "name", paramName, withinUnits.getName()));
assertEquals(withinUnits.getIn(), "query", String.format(msg, "in", "query", withinUnits.getIn()));
assertFalse(isRequired(withinUnits), String.format(msg, "required", "false", withinUnits.getRequired()));
assertEquals(withinUnits.getStyle(), "form", String.format(msg, "style", "form", withinUnits.getStyle()));
assertFalse(isExplode(withinUnits), String.format(msg, "explode", "false", withinUnits.getExplode()));
}
}
use of com.reprezen.kaizen.oasparser.model3.Parameter 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.Parameter 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;
}
Aggregations