Open mlieberman85 opened 2 months ago
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. The generated rust code is:
pub enum AmfCond {
Variant0 {
#[serde(rename = "amfSetId")]
amf_set_id: AmfSetId,
},
Variant1 {
#[serde(rename = "amfRegionId")]
amf_region_id: AmfRegionId,
},
}
?
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