@@ -22,46 +22,91 @@ def add_routes(self, app: web.Application):
22
22
router .add_patch ('/abilities/{ability_id}' , self .update_ability )
23
23
router .add_delete ('/abilities/{ability_id}' , self .delete_ability )
24
24
25
- @aiohttp_apispec .docs (tags = ['abilities' ])
25
+ @aiohttp_apispec .docs (tags = ['abilities' ], summary = 'Get all abilities.' ,
26
+ description = 'Provides a list of all available abilities.' )
26
27
@aiohttp_apispec .querystring_schema (BaseGetAllQuerySchema )
27
- @aiohttp_apispec .response_schema (AbilitySchema (many = True , partial = True ))
28
+ @aiohttp_apispec .response_schema (AbilitySchema (many = True , partial = True ),
29
+ description = 'Returns a list of all abilities.' )
28
30
async def get_abilities (self , request : web .Request ):
29
31
abilities = await self .get_all_objects (request )
30
32
return web .json_response (abilities )
31
33
32
- @aiohttp_apispec .docs (tags = ['abilities' ])
34
+ @aiohttp_apispec .docs (tags = ['abilities' ], summary = 'Get an ability.' ,
35
+ description = 'Provides one ability based on its ability id.' ,
36
+ parameters = [{
37
+ 'in' : 'path' ,
38
+ 'name' : 'ability_id' ,
39
+ 'schema' : {'type' : 'string' },
40
+ 'required' : 'true' ,
41
+ 'description' : 'UUID of the Ability to be retrieved'
42
+ }])
33
43
@aiohttp_apispec .querystring_schema (BaseGetOneQuerySchema )
34
- @aiohttp_apispec .response_schema (AbilitySchema (partial = True ))
44
+ @aiohttp_apispec .response_schema (AbilitySchema (partial = True ),
45
+ description = 'JSON dictionary representation of the existing Ability.' )
35
46
async def get_ability_by_id (self , request : web .Request ):
36
47
ability = await self .get_object (request )
37
48
return web .json_response (ability )
38
49
39
- @aiohttp_apispec .docs (tags = ['abilities' ], summary = '"name", "tactic", and "executors" are all required fields.' )
50
+ @aiohttp_apispec .docs (tags = ['abilities' ], summary = 'Creates a new ability.' ,
51
+ description = 'Creates a new adversary based on the `AbilitySchema`. '
52
+ '"name", "tactic", and "executors" are all required fields.' )
40
53
@aiohttp_apispec .request_schema (AbilitySchema )
41
- @aiohttp_apispec .response_schema (AbilitySchema )
54
+ @aiohttp_apispec .response_schema (AbilitySchema ,
55
+ description = 'JSON dictionary representation of the created Ability.' )
42
56
async def create_ability (self , request : web .Request ):
43
57
ability = await self .create_on_disk_object (request )
44
58
return web .json_response (ability .display )
45
59
46
- @aiohttp_apispec .docs (tags = ['abilities' ], summary = '"name", "tactic", and "executors" are all required fields.' )
60
+ @aiohttp_apispec .docs (tags = ['abilities' ], summary = 'Replaces an existing ability.' ,
61
+ description = 'Replaces an ability based on the `AbilitySchema` values provided '
62
+ 'in the message body. "name", "tactic", and "executors" '
63
+ 'are all required fields.' ,
64
+ parameters = [{
65
+ 'in' : 'path' ,
66
+ 'name' : 'ability_id' ,
67
+ 'schema' : {'type' : 'string' },
68
+ 'required' : 'true' ,
69
+ 'description' : 'UUID of the Ability to be retrieved'
70
+ }])
47
71
@aiohttp_apispec .request_schema (AbilitySchema (partial = True ))
48
- @aiohttp_apispec .response_schema (AbilitySchema )
72
+ @aiohttp_apispec .response_schema (AbilitySchema ,
73
+ description = 'JSON dictionary representation of the replaced Ability.' )
49
74
async def create_or_update_ability (self , request : web .Request ):
50
75
ability = await self .create_or_update_on_disk_object (request )
51
76
return web .json_response (ability .display )
52
77
53
- @aiohttp_apispec .docs (tags = ['abilities' ])
54
- @aiohttp_apispec .request_schema (AbilitySchema (partial = True , exclude = ['ability_id' ,
55
- 'requirements' ,
56
- 'additional_info' ,
57
- 'access' ]))
58
- @aiohttp_apispec .response_schema (AbilitySchema )
78
+ @aiohttp_apispec .docs (tags = ['abilities' ], summary = 'Updates an existing ability.' ,
79
+ description = 'Updates an ability based on the `AbilitySchema` values provided '
80
+ 'in the message body.' ,
81
+ parameters = [{
82
+ 'in' : 'path' ,
83
+ 'name' : 'ability_id' ,
84
+ 'schema' : {'type' : 'string' },
85
+ 'required' : 'true' ,
86
+ 'description' : 'UUID of the Ability to be retrieved'
87
+ }])
88
+ @aiohttp_apispec .request_schema (AbilitySchema (partial = True ,
89
+ exclude = ['ability_id' ,
90
+ 'requirements' ,
91
+ 'additional_info' ,
92
+ 'access' ]))
93
+ @aiohttp_apispec .response_schema (AbilitySchema ,
94
+ description = 'JSON dictionary representation of the replaced Ability.' )
59
95
async def update_ability (self , request : web .Request ):
60
96
ability = await self .update_on_disk_object (request )
61
97
return web .json_response (ability .display )
62
98
63
- @aiohttp_apispec .docs (tags = ['abilities' ])
64
- @aiohttp_apispec .response_schema (AbilitySchema )
99
+ @aiohttp_apispec .docs (tags = ['abilities' ], summary = 'Deletes an ability.' ,
100
+ description = 'Deletes an existing ability.' ,
101
+ parameters = [{
102
+ 'in' : 'path' ,
103
+ 'name' : 'ability_id' ,
104
+ 'schema' : {'type' : 'string' },
105
+ 'required' : 'true' ,
106
+ 'description' : 'UUID of the Ability to be retrieved'
107
+ }])
108
+ @aiohttp_apispec .response_schema (AbilitySchema , code = 204 ,
109
+ description = 'HTTP 204 Status Code (No Content)' )
65
110
async def delete_ability (self , request : web .Request ):
66
111
await self .delete_on_disk_object (request )
67
112
return web .HTTPNoContent ()
0 commit comments