Skip to content

schema attributes wrong for path etc. #1102

@samuelcolvin

Description

@samuelcolvin

@samuelcolvin current implementation causes issues with Path subclasses (same goes for other classes in field_class_to_schema_enum_disabled I presume):

class ConstrainedPath(Path):
    extensions = None

    @classmethod
    def __modify_schema__(cls, schema: dict):
        update_not_none(schema, extensions=cls.extensions)


class ImagePath(ConstrainedPath):
    extensions = ['.jpg']


class Model(BaseModel):
    path: ConstrainedPath  # 'path': {'title': 'Path', 'type': 'string', 'format': 'path'}
    image: ImagePath  # 'image': {'title': 'Image', 'extensions': ['.jpg']}

As you can see, ImagePath loses type and format keys from schema.

Originally posted by @laevilgenius in #1065 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions