-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.v
More file actions
38 lines (33 loc) · 693 Bytes
/
example.v
File metadata and controls
38 lines (33 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module openapi
import x.json2 { Any }
import json
pub struct Example {
pub mut:
external_value string
summary string
description string
value Any
}
pub fn (mut example Example) from_json(json Any) ? {
object := json.as_map()
if 'value' in object && 'externalValue' in object {
return error('Failed Example decoding: "value" and "externalValue" are mutually exclusive')
}
for key, value in object {
match key {
'externalValue' {
example.external_value = value.str()
}
'summary' {
example.summary = value.str()
}
'description' {
example.description = value.str()
}
'value' {
example.value = value
}
else {}
}
}
}