Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Codegen] Constraints for array items are ignored #505

Open
MarshalX opened this issue Dec 20, 2024 · 0 comments
Open

[Codegen] Constraints for array items are ignored #505

MarshalX opened this issue Dec 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@MarshalX
Copy link
Owner

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.
@MarshalX MarshalX added the bug Something isn't working label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant