Skip to content

Commit 307cd58

Browse files
authored
Allow numbers again (#414)
* Allow numbers again Revert the changes in #257 which updated the spec to disallow non-integer values. We misunderstood the canonical json spec and were using a library that didn't support numbers. I have an open PRs for cnab-go which tested out switching to a library that support numbers in canonical json and it works great. * cnabio/cnab-go#247 * cnabio/cnab-go#248 So now fields such as default, maximum, minimum, etc can use numbers again! Signed-off-by: Carolyn Van Slyck <[email protected]> * Include integer and number in primitives list Signed-off-by: Carolyn Van Slyck <[email protected]>
1 parent 762e461 commit 307cd58

File tree

4 files changed

+12
-179
lines changed

4 files changed

+12
-179
lines changed

101-bundle-json.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ Fields:
369369
The `definitions` section of the `bundle.json` defines set of JSONSchema definitions outlining how bundle configuration should be validated by a runtime.
370370

371371
Definitions have no utility on their own. They enable the runtime to validate parameters and outputs when used in combination with those features. Examples
372-
of how to use `definitions` along with `parameters` and `outputs` can be seen in the [Parameters](#parameters) and [Outputs](#outputs) sections below. A `definition` must conform to both JSON Schema and Canonical JSON, therefore only `integer` numeric types are supported.
372+
of how to use `definitions` along with `parameters` and `outputs` can be seen in the [Parameters](#parameters) and [Outputs](#outputs) sections below. A `definition` must conform to both JSON Schema and Canonical JSON.
373373

374374
- `definitions`: A collection of JSONSchema definitions used to validate user-input.
375375
- `<name>`: The name of the definition.
@@ -384,27 +384,27 @@ of how to use `definitions` along with `parameters` and `outputs` can be seen in
384384
- `contains`: Parameter validation requiring at least one item included in the user-provided array conform to the specified schema. MUST be a JSON schema. (OPTIONAL)
385385
- `contentEncoding`: Indicates that the user-provided content should interpreted as binary data and decoded using the encoding named by this property. MUST be a string in accordance with [RFC2045, Sec 6.1](https://json-schema.org/latest/json-schema-validation.html#RFC2045). (OPTIONAL)
386386
- `contentMediaType`: MIME type indicating the media type of the user-provided content. MUST be a string in accordance with [RFC2046](https://json-schema.org/latest/json-schema-validation.html#RFC2046). (OPTIONAL)
387-
- `default`: A default JSON value associated with a particular schema. RECOMMENDED that a default value be valid against the associated schema. Numeric values MUST be integers.(OPTIONAL)
387+
- `default`: A default JSON value associated with a particular schema. RECOMMENDED that a default value be valid against the associated schema. (OPTIONAL)
388388
- `definitions`: Provides a standardized location for bundle authors to inline re-usable JSON Schemas into a more general schema. MUST be an object where each named property contains a JSON schema. (OPTIONAL)
389389
- `dependencies`: Specifies rules that are evaluated if the parameter type is an object and contains a certain property. MUST be an object where each named dependency is either an array of unique strings or a JSON schema. (OPTIONAL)
390390
- `description`: Descriptive text for the field. Can be used to decorate a user interface. MUST be a string. (OPTIONAL)
391391
- `else`: Parameter validation requiring that the user-provided value match the specified schema. Only matches if the user-provided value does NOT match the schema provided in the `if` property. MUST be a JSON schema. (OPTIONAL)
392392
- `enum`: Parameter validation requiring that the user-provided value is one of the specified items in the specified array. MUST be a non-empty array of unique elements that can be of any type. (OPTIONAL)
393393
- `examples`: Sample JSON values associated with a particular schema. MUST be an array. (OPTIONAL)
394-
- `exclusiveMaximum`: Parameter validation requiring that the user-provided integer be less than the integer specified. MUST be an integer. (OPTIONAL)
395-
- `exclusiveMinimum`: Parameter validation requiring that the user-provided integer be greater than the integer specified. MUST be an integer. (OPTIONAL)
394+
- `exclusiveMaximum`: Parameter validation requiring that the user-provided number be less than the number specified. MUST be an number. (OPTIONAL)
395+
- `exclusiveMinimum`: Parameter validation requiring that the user-provided number be greater than the number specified. MUST be an number. (OPTIONAL)
396396
- `format`: Parameter validation requiring that the user-provided value adhere to the specified format. MUST be a string. (OPTIONAL)
397397
- `if`: Provides a method to conditionally validate user-provided values against a schema. MUST be a JSON schema. (OPTIONAL)
398398
- `items`: Parameter validation requiring the items included in a user-provided array must conform to the specified schema(s). MUST be either a JSON schema or an array of JSON schemas. (OPTIONAL)
399399
- `maxItems`: Parameter validation requiring the length of the user-provided array be less than or equal to the number specified. MUST be a non-negative number. (OPTIONAL)
400400
- `maxLength`: Parameter validation requiring that the length of the user-provided string be less than or equal to the number specified. MUST be a non-negative integer. (OPTIONAL)
401401
- `maxProperties`: Parameter validation requiring the number of properties included in the user-provided object be less than or equal to the specified number. MUST be a non-negative integer. (OPTIONAL)
402-
- `maximum`: Parameter validation requiring that the user-provided number be less than or equal to the integer specified. MUST be an integer. (OPTIONAL)
402+
- `maximum`: Parameter validation requiring that the user-provided number be less than or equal to the number specified. MUST be an number. (OPTIONAL)
403403
- `minItems`: Parameter validation requiring the length of the user-provided array be greater than or equal to the number specified. MUST be a non-negative integer. (OPTIONAL)
404404
- `minLength`: Parameter validation requiring that the length of the user-provided string be greater than or equal to the number specified. MUST be a non-negative integer. (OPTIONAL)
405405
- `minProperties`: Parameter validation requiring the number of properties included in the user-provided object be greater than or equal to the specified number. MUST be a non-negative integer. (OPTIONAL)
406-
- `minimum`: Parameter validation requiring that the user-provided number be greater than or equal to the integer specified. MUST be an integer. (OPTIONAL)
407-
- `multipleOf`: Parameter validation requiring that the user-provided number be wholly divisible by the integer specified. MUST be an integer strictly greater than zero. (OPTIONAL)
406+
- `minimum`: Parameter validation requiring that the user-provided number be greater than or equal to the number specified. MUST be an number. (OPTIONAL)
407+
- `multipleOf`: Parameter validation requiring that the user-provided number be wholly divisible by the number specified. MUST be an number strictly greater than zero. (OPTIONAL)
408408
- `not`: Parameter validation requiring that the user-provided value NOT match the specified schema. MUST be a JSON schema. (OPTIONAL)
409409
- `oneOf`: Parameter validation requiring that the user-provided value match ONE of the specified schemas. MUST be a non-empty array of JSON schemas. (OPTIONAL)
410410
- `patternProperties`: The set of matching properties and schemas for their values included in an object type parameter. MUST be an object where each named property is a regular expression with a JSON schema as the value. (OPTIONAL)
@@ -415,7 +415,7 @@ of how to use `definitions` along with `parameters` and `outputs` can be seen in
415415
- `required`: Parameter validation requiring the properties named in the user-provided object include the specified list of properties. MUST be an array of strings. (OPTIONAL)
416416
- `then`: Parameter validation requiring that the user-provided value match the specified schema. Only matches if the user-provided value matches the schema provided in the `if` property. MUST be a JSON schema. (OPTIONAL)
417417
- `title`: Short, human-readable descriptive name for the field. Can be used to decorate a user interface. MUST be a string. (OPTIONAL)
418-
- `type`: Parameter validation requiring that the user-provided value is either a "null", "boolean", "object", "array", "string", or "integer". MUST be a string or an array of strings with unique elements. If you need to represent another numeric type, upscale to an integer or use a string type and convert within your bundle. (OPTIONAL)
418+
- `type`: Parameter validation requiring that the user-provided value is either a "null", "boolean", "object", "array", "string", "integer", or "number". MUST be a string or an array of strings with unique elements. (OPTIONAL)
419419
- `uniqueItems`: Parameter validation requiring the items included in the user-provided array be unique. MUST be a boolean. (OPTIONAL)
420420
- `writeOnly`: Indicates that the value of the parameter is sensitive and MUST NOT be written to insecure locations such as log files or user-facing output. MUST be a boolean. (OPTIONAL)
421421

schema/bundle.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
},
226226
"definitions": {
227227
"additionalProperties": {
228-
"$ref": "https://cnab.io/v1/definitions.schema.json"
228+
"$ref": "http://json-schema.org/draft-07/schema#"
229229
},
230230
"type": "object"
231231
},

schema/definitions.schema.json

Lines changed: 0 additions & 167 deletions
This file was deleted.

scripts/validate.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ set -eou pipefail
1111
for json in $(ls -1 examples/*-bundle.json); do
1212
schema="schema/bundle.schema.json"
1313
echo "Testing json '$json' against schema '$schema'"
14-
ajv test -s $schema -d $json --valid -r schema/definitions.schema.json
14+
ajv test -s $schema -d $json --valid
1515
done
1616

1717
# Test all of the claim files against the claim schema.
1818
for json in $(ls -1 examples/*-claim.json); do
1919
schema="schema/claim.schema.json"
2020
echo "Testing json '$json' against schema '$schema'"
21-
ajv test -s $schema -d $json --valid -r schema/bundle.schema.json -r schema/definitions.schema.json
21+
ajv test -s $schema -d $json --valid -r schema/bundle.schema.json
2222
done
2323

2424
# Test all of the claim result files against the claim result schema.
2525
for json in $(ls -1 examples/*-claim-result.json); do
2626
schema="schema/claim-result.schema.json"
2727
echo "Testing json '$json' against schema '$schema'"
28-
ajv test -s $schema -d $json --valid -r schema/definitions.schema.json
28+
ajv test -s $schema -d $json --valid
2929
done
3030

3131
# Test all of the dependency files against the dependencies schema

0 commit comments

Comments
 (0)