1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-05-09 08:00:41 +00:00

more enum stuff

[skip ci]
This commit is contained in:
Dominic 2021-03-08 17:33:49 +01:00
parent 43d3a1cd89
commit 5f60599c41
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
2 changed files with 85 additions and 2 deletions

View file

@ -77,3 +77,68 @@ test_type!(EnumWithOneField = {
},
"required": ["Success"]
});
#[derive(OpenapiType)]
enum EnumWithFields {
Success { value: isize },
Error { msg: String }
}
test_type!(EnumWithFields = {
"title": "EnumWithFields",
"oneOf": [{
"type": "object",
"properties": {
"Success": {
"type": "object",
"properties": {
"value": {
"type": "integer"
}
},
"required": ["value"]
}
},
"required": ["Success"]
}, {
"type": "object",
"properties": {
"Error": {
"type": "object",
"properties": {
"msg": {
"type": "string"
}
},
"required": ["msg"]
}
},
"required": ["Error"]
}]
});
#[derive(OpenapiType)]
enum EnumExternallyTagged {
Success { value: isize },
Error
}
test_type!(EnumExternallyTagged = {
"title": "EnumExternallyTagged",
"oneOf": [{
"type": "object",
"properties": {
"Success": {
"type": "object",
"properties": {
"value": {
"type": "integer"
}
},
"required": ["value"]
}
},
"required": ["Success"]
}, {
"type": "string",
"enum": ["Error"]
}]
});