Closed martensievers closed 1 year ago
Hi Marten.
Thank you very much for reporting this issue.
The schema type was compared to the actual js type and thus failed for integer. This has been tested and fixed: https://github.com/sagold/json-schema-library/runs/10959229555#r0s17.
I published a version v7.4.5
including this fix.
Note that I am preparing the next major release v8. I have released a version v8.0.0-rc2
which also includes this fix. Since you are upgrading, you might want to go for v8. In case you do, pay attention to the following:
JSON
types and variables to Json
, e.g. JSONSchema
-> JsonSchema
getTemplate
will add only required properties per default. Use addOptionalProps:true
to change this behaviourgetTemplate
will respect additionalProperties:true
if missingCheers!
Thanks @sagold for the quick fix and yes I will be eventually updating to the latest version 👍🏼
I had actually already tested v8.0.0-rc1 before noticing the issue and it looks fine now but wanted to wait for the full release before using it in my production project 😉
I recently bumped up my version from
4.0.0
to7.4.4
and noticed some inconsistencies with using getTemplate.The problem appears once I use getTemplate with input data where it seems to replace existing values of type
integer
with a default (0
). This problem only seems to happen when the schema type isinteger
and works fine when the type of a property isnumber
.Example schema:
Example input data:
My implementation looks like this:
Received output:
Once I change the type of
age
tonumber
it works fine so it seems to be related to the schema type-definition.