Skip to content

Commit

Permalink
Added several default values for optional parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Feb 7, 2019
1 parent 626e5e9 commit 8b246f2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
10 changes: 7 additions & 3 deletions aggregate_temporal.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "aggregate_temporal",
"summary": "Temporal aggregations",
"description": "Computes a temporal aggregation based on an array of date and/or time intervals.\n\nCalendar hierarchies such as year, month, week etc. must be transformed into specific intervals by the clients. For each interval, all data along the dimension will be passed through the reducer. The computed values will be projected to the labels, so the number of labels and the number of intervals need to be equal.\n\nIf the dimension is not set, the data cube is expected to only have one temporal dimension.",
"description": "Computes a temporal aggregation based on an array of date and/or time intervals.\n\nCalendar hierarchies such as year, month, week etc. must be transformed into specific intervals by the clients. For each interval, all data along the dimension will be passed through the reducer. The computed values will be projected to the labels, so the number of labels and the number of intervals need to be equal.\n\nIf the dimension is not set or is set to `null`, the data cube is expected to only have one temporal dimension.",
"categories": [
"cubes",
"aggregate"
Expand Down Expand Up @@ -97,9 +97,13 @@
"required": true
},
"dimension": {
"description": "The temporal dimension for aggregation. All data along the dimension will be passed through the specified reducer. If the dimension is not set, the data cube is expected to only have one temporal dimension.\n\n**Note:** The default dimensions a data cube provides are described in the collection's metadata field `cube:dimensions`.",
"description": "The temporal dimension for aggregation. All data along the dimension will be passed through the specified reducer. If the dimension is not set or set to `null`, the data cube is expected to only have one temporal dimension.\n\n**Note:** The default dimensions a data cube provides are described in the collection's metadata field `cube:dimensions`.",
"schema": {
"type": "string"
"type": [
"string",
"null"
],
"default": null
}
}
},
Expand Down
10 changes: 7 additions & 3 deletions filter_temporal.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "filter_temporal",
"summary": "Temporal filter for a date and/or time intervals",
"description": "Limits the data cube to the specified interval of dates and/or times.\n\nAlso supports open intervals by setting either `start` or `end` to `null`, but never both.\n\nMore precisely, the filter checks checks whether the end of the exposure time is greater than or equal to the value of `start` and the start of the exposure time is less than the value of `end`. This corresponds to a left-closed interval, which contains the `start` but not the `end`.\n\nIf the dimension is not set, the data cube is expected to only have one temporal dimension.",
"description": "Limits the data cube to the specified interval of dates and/or times.\n\nAlso supports open intervals by setting either `start` or `end` to `null`, but never both.\n\nMore precisely, the filter checks checks whether the end of the exposure time is greater than or equal to the value of `start` and the start of the exposure time is less than the value of `end`. This corresponds to a left-closed interval, which contains the `start` but not the `end`.\n\nIf the dimension is not set or is set to `null`, the data cube is expected to only have one temporal dimension.",
"categories": [
"filter"
],
Expand Down Expand Up @@ -62,9 +62,13 @@
}
},
"dimension": {
"description": "The temporal dimension to filter on. If the dimension is not set, the data cube is expected to only have one temporal dimension.\n\n**Note:** The default dimensions a data cube provides are described in the collection's metadata field `cube:dimensions`.",
"description": "The temporal dimension to filter on. If the dimension is not set or is set to `null`, the data cube is expected to only have one temporal dimension.\n\n**Note:** The default dimensions a data cube provides are described in the collection's metadata field `cube:dimensions`.",
"schema": {
"type": "string"
"type": [
"string",
"null"
],
"default": null
}
}
},
Expand Down
10 changes: 7 additions & 3 deletions resample_temporal.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "resample_temporal",
"summary": "Resample a temporal dimension",
"description": "Resamples a temporal dimension. If the dimension is not set, the data cube is expected to only have one temporal dimension.",
"description": "Resamples a temporal dimension.\n\nIf the dimension is not set or is set to `null`, the data cube is expected to only have one temporal dimension.",
"categories": [
"cubes",
"aggregate"
Expand Down Expand Up @@ -43,9 +43,13 @@
"required": true
},
"dimension": {
"description": "The temporal dimension to resample. If the dimension is not set, the data cube is expected to only have one temporal dimension.\n\n**Note:** The default dimensions a data cube provides are described in the collection's metadata field `cube:dimensions`.",
"description": "The temporal dimension to resample. If the dimension is not set or is set to `null`, the data cube is expected to only have one temporal dimension.\n\n**Note:** The default dimensions a data cube provides are described in the collection's metadata field `cube:dimensions`.",
"schema": {
"type": "string"
"type": [
"string",
"null"
],
"default": null
}
}
},
Expand Down
14 changes: 11 additions & 3 deletions run_udf.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
"required": true
},
"version": {
"description": "An UDF runtime version. Defaults to the default runtime version specified for each runtime.",
"description": "An UDF runtime version. If set to `null`, the default runtime version specified for each runtime is used.",
"schema": {
"type": "string",
"default": "latest"
"type": [
"string",
"null"
],
"default": null
}
},
"options": {
Expand All @@ -48,6 +51,11 @@
}
}
},
"exceptions": {
"InvalidVersion": {
"message": "The specified UDF runtime version is not supported."
}
},
"returns": {
"description": "The data processed by the UDF.",
"schema": {
Expand Down
7 changes: 6 additions & 1 deletion tests/openapi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ var exceptionNameRegExp = /^[A-Za-z0-9_]+$/;

var files = glob.sync("../*.json", {realpath: true});

var anyOfRequired = [
"filter_bands",
"quantiles"
];

var ajvOptions = {
format: 'full',
formats: {
Expand Down Expand Up @@ -124,7 +129,7 @@ describe.each(processes)("%s", (file, p) => {

// Parameters that are not required should define a default value - just a warning for now
// ToDo: Doesn't work for oneOf/allOf/...
if(param.required !== true && typeof param.schema.default === 'undefined') {
if(param.required !== true && typeof param.schema.default === 'undefined' && !anyOfRequired.includes(p.id)) {
console.warn(p.id + ": Optional parameter '" + key + "' should define a default value.");
}

Expand Down

0 comments on commit 8b246f2

Please sign in to comment.