-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi_test.v
More file actions
42 lines (34 loc) · 1.24 KB
/
openapi_test.v
File metadata and controls
42 lines (34 loc) · 1.24 KB
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
module openapi
import os
fn test_basic_open_api_struct() ? {
content := os.read_file(@VMODROOT + '/testdata/open_api_basic.json')?
open_api := decode<OpenApi>(content)?
assert open_api.openapi == '3'
assert open_api.info.title == 'Sample Pet Store App'
assert open_api.info.version == '1.0.1'
assert open_api.paths.len == 1
assert '/home' in open_api.paths
assert open_api.paths['/home'].description == 'homepage'
assert open_api.tags.len == 2
assert open_api.tags[0].name == 'cat'
assert open_api.tags[1].name == 'dog'
assert open_api.servers.len == 1
assert open_api.servers[0].url == 'https://random.fr'
assert open_api.servers[0].variables.len == 1
assert open_api.servers[0].variables['var1'].default_value == 'default'
}
fn test_open_api_struct_without_paths() ? {
content := '{ "open_api": "3", "info": {"title": "oui", "version": "1"} }'
info := decode<OpenApi>(content) or { return }
assert false
}
fn test_open_api_struct_without_info() ? {
content := '{ "open_api": "3", "paths": {} }'
info := decode<OpenApi>(content) or { return }
assert false
}
fn test_open_api_struct_without_openapi() ? {
content := '{ "info": {"title": "oui", "version": "1"}, "paths": {} }'
info := decode<OpenApi>(content) or { return }
assert false
}