FHIR Chat · json schema bug? · conformance

Stream: conformance

Topic: json schema bug?


view this post on Zulip Jim Williams (Dec 07 2020 at 15:02):

I believe there is a bug in the published JSON schema.
The definitions of the integer, positiveInt, and unsignedInt types all use the type of number from the json schema spec. I believe this should be integer instead. Here is the defnition of integer from the FHIR spec:

    "integer": {
      "pattern": "^-?([0]|([1-9][0-9]*))$",
      "type": "number",
      "description": "A whole number"
    },

Usage of the type number causes problems for tools that generate classes from the json schema in that the number type gets represented by floating point types.

Any thoughts?

view this post on Zulip Lloyd McKenzie (Dec 07 2020 at 15:49):

@Grahame Grieve

view this post on Zulip Grahame Grieve (Dec 07 2020 at 22:48):

what's the defintion of an integer in JSON schema?

view this post on Zulip Jim Williams (Dec 08 2020 at 13:36):

6.25. type

The value of this keyword MUST be either a string or an array. If it
is an array, elements of the array MUST be strings and MUST be
unique.

String values MUST be one of the six primitive types ("null",
"boolean", "object", "array", "number", or "string"), or "integer"
which matches any number with a zero fractional part.

An instance validates if and only if the instance is in any of the
sets listed for this keyword.

this is from https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25, which is the draft 6 version of the schema.

view this post on Zulip Lloyd McKenzie (Dec 08 2020 at 14:13):

Does it define what the integer primitive type is somewhere?

view this post on Zulip Jim Williams (Dec 08 2020 at 14:50):

I cannot find any definition of an integer other than the description given above.

view this post on Zulip Vassil Peytchev (Dec 08 2020 at 15:03):

I found this, where it is stated (bolding is mine):

The precise treatment of the “integer” type may depend on the implementation of your JSON Schema validator. JavaScript (and thus also JSON) does not have distinct types for integers and floating-point values. Therefore, JSON Schema can not use type alone to distinguish between integers and non-integers. The JSON Schema specification recommends, but does not require, that validators use the mathematical value to determine whether a number is an integer, and not the type alone. Therefore, there is some disagreement between validators on this point. For example, a JavaScript-based validator may accept 1.0 as an integer, whereas the Python-based jsonschema does not.

view this post on Zulip Grahame Grieve (Dec 08 2020 at 21:04):

thanks. certain things about Json do not have a feel-good quality


Last updated: Apr 12 2022 at 19:14 UTC