Skip to content

[Codegen] Constraints for array items are ignored #505

@MarshalX

Description

@MarshalX

Example lexicon:

"tags": {
    "type": "array",
    "items": {
        "type": "string"
        "type": "string",
        "maxLength": 25,
        "description": "Items in this array are applied with OR filters. To apply AND filter, put all tags in the same string and separate using && characters"
    }
}

Actual behavior:

tags: t.Optional[t.List[str]] = None

Expected behavior:

tags: t.Optional[t.List[constr(max_length=25)]] = None

So the constraints of the array must be provided using constr. The issue comes that for today we describe constraints only using Field(). Found in #503

More about constr: https://docs.pydantic.dev/1.10/usage/types/#arguments-to-constr

That's how we do it today for non-inner type:

limit: t.Optional[int] = Field(default=50, ge=1, le=100)  #: Limit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions