Loopback 4, boolean values for additionalProperties are removed from JSON schema?

255 views
Skip to first unread message

Vladislav Stepanov

unread,
Apr 24, 2019, 2:09:09 AM4/24/19
to LoopbackJS
Hi there,

Does someone know why boolean values for additionalProperties are ignored when converting JSON Schemas into a SchemaObject? The exact code I'm talking about is here:

What I'm trying to do:
1. I created an "object" field which is mapped to a jsonb column in a postgresql db
2. Then I want to add some nested properties into that field and validation for it:
2.1 Option 1: add model references: if I got it right I could reference another model there but it means that I have to create a model per every level of nesting
2.2 Option 2: add JSON Schema validation for that field, the nested properties will not be publicly visible but the code is going to be pretty straightforward. And here I face the fact that I cannot restrict the schema to allow only defined properties because additionalProperties: false on my schema is just ignored

Vladislav Stepanov

unread,
Apr 25, 2019, 6:57:39 PM4/25/19
to LoopbackJS
Well, actually I can achieve it with setting additionalProperties to { "not": {} }:

>true is equivalent to {}, false is equivalent to {"not": {}}, but the intent is more clear and implementations can optimize these cases more easily
Reply all
Reply to author
Forward
0 new messages