jsonschema-typed icon indicating copy to clipboard operation
jsonschema-typed copied to clipboard

Handling patternProperties

Open emmaworley opened this issue 6 years ago • 1 comments

Hi, I'd like to use this project to type a schema that makes several uses of patternProperties. I was thinking I could handle them by relaxing the pattern constraint and simply typing objects with patternProperties as dicts from strings to Unions of all the patterned property types. For example, the schema:

{
    "type": "object",
    "patternProperties": {
        "^foo_[a-z]+$": {
            "type": "string"
        },
        "^bar_[a-z]+$": {
            "type": "int"
        }
    }
}

would be typed as Dict[str, Union[str, int]]. Would this be acceptable for you? If so, I can write a PR.

emmaworley avatar Aug 23 '19 20:08 emmaworley

Are you still interested in contributing this @connorworley ? This is a very old issue now.

felixvd avatar Oct 26 '23 00:10 felixvd