Skip to content

add const keyword to schema object#6

Merged
ismailmo1 merged 2 commits intomasterfrom
add-const-for-literals
May 2, 2025
Merged

add const keyword to schema object#6
ismailmo1 merged 2 commits intomasterfrom
add-const-for-literals

Conversation

@ismailmo1
Copy link
Contributor

this adds the const keyword - see test for example

    class Body1(pydantic.BaseModel):
        name: Literal["i-am-literal"] = "i-am-literal"

results in:

{
    "title": "Body1",
    "type": "object",
    "properties": {
        "name": {
            "title": "Name",
            "type": "string",
            "default": "i-am-literal",
            "const": "i-am-literal" // new!
        }
    }
}

@ismailmo1
Copy link
Contributor Author

mypy is currently failing (we didnt run it before) - have added issue here #7 to address it

@ismailmo1 ismailmo1 merged commit 552fbc3 into master May 2, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants