Support boolean values for additionalProperties #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
additionalProperties
property of an object should be either a boolean value or a schema that additional object properties will be validated against. While trying outas-typed
npm package as a potential replacement forjson-schema-to-typescript
package, I've noticed that as-typed doesn't currently supportadditionalProperties: false
. This PR implements partial support for such usage.Actually, the default value for
additionalProperties
should betrue
andjson-schema-to-typescript
types the following schema:like this:
and removes the
[k: string]
key only ifadditionalProperties
isfalse
which is technically more correct. But implementing it this way breaks almost all tests so I believe what I've done is an acceptable middle ground for the time being.