Open
Description
Is your feature request related to a problem? Please describe.
I can't find a way to get "additionalProperties": true
in JSON schema for a TypedDict.
Describe the solution you'd like
I suggest the following:
- Add support for PEP 728 closed class parameter as a way to enable
"additionalProperties": true
in JSON schema for TypedDict. - Set
"additionalProperties": true
by default for TypedDict as the PEP states:
Passing closed=False explicitly requests the default TypedDict behavior, where arbitrary other keys may be present ...
Describe alternatives you've considered
None
Additional context
from typing_extensions import TypedDict, NotRequired
class SoftwareVersion(TypedDict, closed=False):
NAME: str
VERSION: str
BUILD: NotRequired[str]
>>> print(build_json_schema(SoftwareVersion).to_json())
{"type": "object", "properties": {"NAME": {"type": "string"}, "VERSION": {"type": "string"}, "BUILD": {"type": "string"}}, "additionalProperties": false, "required": ["NAME", "VERSION"]}