mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-05-09 16:10:42 +00:00
enum representations
[skip ci]
This commit is contained in:
parent
5f60599c41
commit
a57f1c097d
5 changed files with 246 additions and 19 deletions
|
@ -43,6 +43,15 @@ test_type!(SimpleStruct = {
|
|||
"required": ["foo", "bar"]
|
||||
});
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
#[openapi(rename = "FooBar")]
|
||||
struct StructRename;
|
||||
test_type!(StructRename = {
|
||||
"type": "object",
|
||||
"title": "FooBar",
|
||||
"additionalProperties": false
|
||||
});
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
enum EnumWithoutFields {
|
||||
Success,
|
||||
|
@ -119,6 +128,7 @@ test_type!(EnumWithFields = {
|
|||
#[derive(OpenapiType)]
|
||||
enum EnumExternallyTagged {
|
||||
Success { value: isize },
|
||||
Empty,
|
||||
Error
|
||||
}
|
||||
test_type!(EnumExternallyTagged = {
|
||||
|
@ -139,6 +149,101 @@ test_type!(EnumExternallyTagged = {
|
|||
"required": ["Success"]
|
||||
}, {
|
||||
"type": "string",
|
||||
"enum": ["Error"]
|
||||
"enum": ["Empty", "Error"]
|
||||
}]
|
||||
});
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
#[openapi(tag = "ty")]
|
||||
enum EnumInternallyTagged {
|
||||
Success { value: isize },
|
||||
Empty,
|
||||
Error
|
||||
}
|
||||
test_type!(EnumInternallyTagged = {
|
||||
"title": "EnumInternallyTagged",
|
||||
"oneOf": [{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"value": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ty": {
|
||||
"type": "string",
|
||||
"enum": ["Success"]
|
||||
}
|
||||
},
|
||||
"required": ["value", "ty"]
|
||||
}, {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ty": {
|
||||
"type": "string",
|
||||
"enum": ["Empty", "Error"]
|
||||
}
|
||||
},
|
||||
"required": ["ty"]
|
||||
}]
|
||||
});
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
#[openapi(tag = "ty", content = "ct")]
|
||||
enum EnumAdjacentlyTagged {
|
||||
Success { value: isize },
|
||||
Empty,
|
||||
Error
|
||||
}
|
||||
test_type!(EnumAdjacentlyTagged = {
|
||||
"title": "EnumAdjacentlyTagged",
|
||||
"oneOf": [{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ty": {
|
||||
"type": "string",
|
||||
"enum": ["Success"]
|
||||
},
|
||||
"ct": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"value": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": ["value"]
|
||||
}
|
||||
},
|
||||
"required": ["ty", "ct"]
|
||||
}, {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ty": {
|
||||
"type": "string",
|
||||
"enum": ["Empty", "Error"]
|
||||
}
|
||||
},
|
||||
"required": ["ty"]
|
||||
}]
|
||||
});
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
#[openapi(untagged)]
|
||||
enum EnumUntagged {
|
||||
Success { value: isize },
|
||||
Empty,
|
||||
Error
|
||||
}
|
||||
test_type!(EnumUntagged = {
|
||||
"title": "EnumUntagged",
|
||||
"oneOf": [{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"value": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": ["value"]
|
||||
}, {
|
||||
"type": "object",
|
||||
"additionalProperties": false
|
||||
}]
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue