-
Notifications
You must be signed in to change notification settings - Fork 57
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
"anyOf" with "required" doesn't appear to be generating the right enum variants #669
Comments
Adding to the above case: {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"definitions": {
"AmfCond": {
"description": "Subscription to a set of AMFs, based on AMF Set Id and/or AMF Region Id",
"type": "object",
"anyOf": [
{
"required": ["amfSetId"]
},
{
"required": ["amfRegionId"]
}
],
"properties": {
"amfRegionId": {
"$ref": "#/definitions/AmfRegionId"
},
"amfSetId": {
"$ref": "#/definitions/AmfSetId"
}
}
},
"AmfRegionId": {
"description": "String identifying the AMF Set ID (10 bits) as specified in clause 2.10.1 of 3GPP TS 23.003. It is encoded as a string of 3 hexadecimal characters where the first character is limited to values 0 to 3 (i.e. 10 bits)\n",
"type": "string",
"pattern": "^[A-Fa-f0-9]{2}$"
},
"AmfSetId": {
"description": "String identifying the AMF Set ID (10 bits) as specified in clause 2.10.1 of 3GPP TS 23.003. It is encoded as a string of 3 hexadecimal characters where the first character is limited to values 0 to 3 (i.e. 10 bits).\n",
"type": "string",
"pattern": "^[0-3][A-Fa-f0-9]{2}$"
}
}
} In the above json schema the the any of is generated as an Enum, where we can have a case of both the field presents. pub enum AmfCond {
Variant0 {
#[serde(rename = "amfSetId")]
amf_set_id: AmfSetId,
},
Variant1 {
#[serde(rename = "amfRegionId")]
amf_region_id: AmfRegionId,
},
} ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am running against v0.1.0.
I have a type definition in the json schema called
ResourceDescriptor
. It should require at least one ofcontent
,digest
,uri
fields to be set. However, what I'm seeing is that it makes them exclusive with each other.Here's my json schema:
It generates an enum like:
I would expect the enum variants to look more like:
If I run this schema against other validators it does work as intended where as long I have one of
content
,digest
, oruri
set it validates.Here is an example json that does not validate with an error:
Error: data did not match any variant of untagged enum ResourceDescriptor at line 20 column 7
The text was updated successfully, but these errors were encountered: