Skip to content

$ref siblings #24

@rgusmero

Description

@rgusmero

Please consider the following code:

@dataclass
class B:
    id: str

@dataclass
class A:
    x: list[Annotated[B,'desc']]

schema = dataglasses.to_json_schema(A)
pprint.pprint(schema)

The produced output is

{'$defs': {'A': {'properties': {'x': {'items': {'$ref': '#/$defs/B',
                                                'description': 'desc'},
                                      'type': 'array'}},
                 'required': ['x'],
                 'type': 'object'},
           'B': {'properties': {'id': {'type': 'string'}},
                 'required': ['id'],
                 'type': 'object'}},
 '$ref': '#/$defs/A',
 '$schema': 'https://json-schema.org/draft/2020-12/schema'}

AFAIK, though, siblings of $ref are ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions