-
Notifications
You must be signed in to change notification settings - Fork 1
/
clean.py
107 lines (83 loc) · 5.51 KB
/
clean.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import yaml
with open('api.yaml') as f:
doc = yaml.safe_load(f)
doc['externalDocs']['url'] = 'https://github.com/jexia/'
doc['externalDocs']['description'] = 'Management contracts for Jexia Platform'
doc['info']['title'] = 'Jexia Management Swagger Contracts'
doc['servers']=[{'description':'Production server','url':'https://app.jexia.com'},{'url': 'https://services.jexia.com/management/{project_id}','description': 'Service endpoint for all paths below'}]
doc['paths'].pop('/signup', None)
doc['tags']=[]
#================= Adjust DataSet contracts ====================
name = ['paths for Dataset']
doc['paths']['/ds/']['get']['tags']=name
doc['paths']['/ds/']['post']['tags']=name
doc['paths']['/ds/{dataset_id}']['put']['tags']=name
doc['paths']['/ds/{dataset_id}']['delete']['tags']=name
doc['paths']['/ds/{dataset_id}/data']['delete']['tags']=name
doc['paths']['/ds/{dataset_id}/field']['post']['tags']=name
doc['paths']['/ds/{dataset_id}/field/{field_id}']['put']['tags']=name
doc['paths']['/ds/{dataset_id}/field/{field_id}']['delete']['tags']=name
doc['paths']['/ds/{dataset_id}/constraint/{field_id}']['post']['tags']=name
doc['paths']['/ds/{dataset_id}/constraint/{constraint_id}']['put']['tags']=name
doc['paths']['/ds/{dataset_id}/constraint/{constraint_id}']['delete']['tags']=name
doc['paths']['/ds/{dataset_id}/constraints/{field_id}']['put']['tags']=name
doc['paths']['/ds/relation']['post']['tags']=name
doc['paths']['/ds/relation/{relation_id}']['delete']['tags']=name
doc['paths']['/mimir/ds/']=doc['paths']['/ds/']
del doc['paths']['/ds/']
doc['paths']['/mimir/ds/{dataset_id}']=doc['paths']['/ds/{dataset_id}']
del doc['paths']['/ds/{dataset_id}']
doc['paths']['/mimir/ds/{dataset_id}/data']=doc['paths']['/ds/{dataset_id}/data']
del doc['paths']['/ds/{dataset_id}/data']
doc['paths']['/mimir/ds/{dataset_id}/field']=doc['paths']['/ds/{dataset_id}/field']
del doc['paths']['/ds/{dataset_id}/field']
doc['paths']['/mimir/ds/{dataset_id}/constraint/{field_id}']=doc['paths']['/ds/{dataset_id}/constraint/{field_id}']
del doc['paths']['/ds/{dataset_id}/constraint/{field_id}']
doc['paths']['/mimir/ds/relation']=doc['paths']['/ds/relation']
del doc['paths']['/ds/relation']
doc['paths']['/mimir/ds/relation/{relation_id}']=doc['paths']['/ds/relation/{relation_id}']
del doc['paths']['/ds/relation/{relation_id}']
doc['paths']['/mimir/ds/{dataset_id}/constraint/{constraint_id}']=doc['paths']['/ds/{dataset_id}/constraint/{constraint_id}']
del doc['paths']['/ds/{dataset_id}/constraint/{constraint_id}']
doc['paths']['/mimir/ds/{dataset_id}/constraints/{field_id}']=doc['paths']['/ds/{dataset_id}/constraints/{field_id}']
del doc['paths']['/ds/{dataset_id}/constraints/{field_id}']
doc['paths']['/mimir/ds/{dataset_id}/field/{field_id}']=doc['paths']['/ds/{dataset_id}/field/{field_id}']
del doc['paths']['/ds/{dataset_id}/field/{field_id}']
#=================== Adjust FileSet ================
name = ['paths for FileSet']
doc['paths']['/fs/']['get']['tags']=name
doc['paths']['/storage/']['post']['tags']=name
doc['paths']['/fs/']['post']['tags']=name
doc['paths']['/fs/{fileset_id}']['put']['tags']=name
doc['paths']['/fs/{fileset_id}']['delete']['tags']=name
doc['paths']['/fs/{fileset_id}/field']['post']['tags']=name
doc['paths']['/fs/{fileset_id}/field/{field_id}']['put']['tags']=name
doc['paths']['/fs/{fileset_id}/field/{field_id}']['delete']['tags']=name
doc['paths']['/fs/{fileset_id}/constraint/{field_id}']['post']['tags']=name
doc['paths']['/fs/{fileset_id}/constraint/{constraint_id}']['put']['tags']=name
doc['paths']['/fs/{fileset_id}/constraint/{constraint_id}']['delete']['tags']=name
doc['paths']['/fs/{fileset_id}/constraints/{field_id}']['put']['tags']=name
doc['paths']['/fs/relation']['post']['tags']=name
doc['paths']['/fs/relation/{relation_id}']['delete']['tags']=name
doc['paths']['/bestla/storage/']=doc['paths']['/storage/']
del doc['paths']['/storage/']
doc['paths']['/bestla/fs/']=doc['paths']['/fs/']
del doc['paths']['/fs/']
doc['paths']['/bestla/fs/{fileset_id}']=doc['paths']['/fs/{fileset_id}']
del doc['paths']['/fs/{fileset_id}']
doc['paths']['/bestla/fs/{fileset_id}/field']=doc['paths']['/fs/{fileset_id}/field']
del doc['paths']['/fs/{fileset_id}/field']
doc['paths']['/bestla/fs/{fileset_id}/constraint/{field_id}']=doc['paths']['/fs/{fileset_id}/constraint/{field_id}']
del doc['paths']['/fs/{fileset_id}/constraint/{field_id}']
doc['paths']['/bestla/fs/relation']=doc['paths']['/fs/relation']
del doc['paths']['/fs/relation']
doc['paths']['/bestla/fs/relation/{relation_id}']=doc['paths']['/fs/relation/{relation_id}']
del doc['paths']['/fs/relation/{relation_id}']
doc['paths']['/bestla/fs/{fileset_id}/constraint/{constraint_id}']=doc['paths']['/fs/{fileset_id}/constraint/{constraint_id}']
del doc['paths']['/fs/{fileset_id}/constraint/{constraint_id}']
doc['paths']['/bestla/fs/{fileset_id}/constraints/{field_id}']=doc['paths']['/fs/{fileset_id}/constraints/{field_id}']
del doc['paths']['/fs/{fileset_id}/constraints/{field_id}']
doc['paths']['/bestla/fs/{fileset_id}/field/{field_id}']=doc['paths']['/fs/{fileset_id}/field/{field_id}']
del doc['paths']['/fs/{fileset_id}/field/{field_id}']
with open('api.yaml', 'w') as f:
yaml.safe_dump(doc, f)