-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlink.v
More file actions
44 lines (40 loc) · 879 Bytes
/
link.v
File metadata and controls
44 lines (40 loc) · 879 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
39
40
41
42
43
44
module openapi
import x.json2 { Any }
import json
pub struct Link {
pub mut:
operation_ref string
operation_id string
request_body Any
parameters map[string]Any
description string
server Server
}
pub fn (mut link Link) from_json(json Any) ? {
for key, value in json.as_map() {
match key {
'operationRef' {
link.operation_ref = value.str()
}
'operationId' {
link.operation_id = value.str()
}
'requestBody' {
link.request_body = value
}
'parameters' {
link.parameters = decode_map_any(value.json_str())?
}
'description' {
link.description = value.str()
}
'server' {
link.server = decode<Server>(value.json_str())?
}
else {}
}
}
if link.operation_ref != '' && link.operation_id != '' {
return error('Failed Link decoding: "operationId" and "operationRef" are mutually exclusives')
}
}