-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Feature Request
https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.3
This is a very useful feature for when structural subtyping just doesn't quite cut it and you need to differentiate two semantically different but structurally identical types.
Some ways that this could be implemented:
class Foo(pydantic.BaseModel):
bar: pydantic.Constant = "baz"class Foo(pydantic.BaseModel):
bar: pydantic.constant("baz")Which would each generate the following schema:
{
"title": "Foo",
"type": "object",
"properties": {
"bar": {
"title": "Bar",
"const": "baz"
}
},
"required": ["bar"]
}I'm happy to put some work in for this, if it's something that you're willing to support.