Skip to content

Commit ad4be7f

Browse files
committed
Improve Swagger OperationIDs for Vault
1 parent a180317 commit ad4be7f

File tree

2 files changed

+129
-21
lines changed

2 files changed

+129
-21
lines changed

src/Api/Vault/Controllers/CiphersController.cs

Lines changed: 114 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ public async Task<CipherMiniResponseModel> GetAdmin(string id)
108108
return new CipherMiniDetailsResponseModel(cipher, _globalSettings, collectionCiphersGroupDict, cipher.OrganizationUseTotp);
109109
}
110110

111-
[HttpGet("{id}/full-details")]
112111
[HttpGet("{id}/details")]
113112
public async Task<CipherDetailsResponseModel> GetDetails(Guid id)
114113
{
@@ -124,8 +123,15 @@ public async Task<CipherDetailsResponseModel> GetDetails(Guid id)
124123
return new CipherDetailsResponseModel(cipher, user, organizationAbilities, _globalSettings, collectionCiphers);
125124
}
126125

126+
[HttpGet("{id}/full-details")]
127+
[Obsolete("This endpoint is deprecated. Use GET details method instead.")]
128+
public async Task<CipherDetailsResponseModel> GetFullDetails(Guid id)
129+
{
130+
return await GetDetails(id);
131+
}
132+
127133
[HttpGet("")]
128-
public async Task<ListResponseModel<CipherDetailsResponseModel>> Get()
134+
public async Task<ListResponseModel<CipherDetailsResponseModel>> GetAll()
129135
{
130136
var user = await _userService.GetUserByPrincipalAsync(User);
131137
var hasOrgs = _currentContext.Organizations.Count != 0;
@@ -232,7 +238,6 @@ public async Task<CipherMiniResponseModel> PostAdmin([FromBody] CipherCreateRequ
232238
}
233239

234240
[HttpPut("{id}")]
235-
[HttpPost("{id}")]
236241
public async Task<CipherResponseModel> Put(Guid id, [FromBody] CipherRequestModel model)
237242
{
238243
var user = await _userService.GetUserByPrincipalAsync(User);
@@ -273,8 +278,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
273278
return response;
274279
}
275280

281+
[HttpPost("{id}")]
282+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
283+
public async Task<CipherResponseModel> PostPut(Guid id, [FromBody] CipherRequestModel model)
284+
{
285+
return await Put(id, model);
286+
}
287+
276288
[HttpPut("{id}/admin")]
277-
[HttpPost("{id}/admin")]
278289
public async Task<CipherMiniResponseModel> PutAdmin(Guid id, [FromBody] CipherRequestModel model)
279290
{
280291
var userId = _userService.GetProperUserId(User).Value;
@@ -307,6 +318,13 @@ public async Task<CipherMiniResponseModel> PutAdmin(Guid id, [FromBody] CipherRe
307318
return response;
308319
}
309320

321+
[HttpPost("{id}/admin")]
322+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
323+
public async Task<CipherMiniResponseModel> PostPutAdmin(Guid id, [FromBody] CipherRequestModel model)
324+
{
325+
return await PutAdmin(id, model);
326+
}
327+
310328
[HttpGet("organization-details")]
311329
public async Task<ListResponseModel<CipherMiniDetailsResponseModel>> GetOrganizationCiphers(Guid organizationId)
312330
{
@@ -678,7 +696,6 @@ private async Task<bool> CanEditItemsInCollections(Guid organizationId, IEnumera
678696
}
679697

680698
[HttpPut("{id}/partial")]
681-
[HttpPost("{id}/partial")]
682699
public async Task<CipherResponseModel> PutPartial(Guid id, [FromBody] CipherPartialRequestModel model)
683700
{
684701
var user = await _userService.GetUserByPrincipalAsync(User);
@@ -694,8 +711,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
694711
return response;
695712
}
696713

714+
[HttpPost("{id}/partial")]
715+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
716+
public async Task<CipherResponseModel> PostPutPartial(Guid id, [FromBody] CipherPartialRequestModel model)
717+
{
718+
return await PutPartial(id, model);
719+
}
720+
697721
[HttpPut("{id}/share")]
698-
[HttpPost("{id}/share")]
699722
public async Task<CipherResponseModel> PutShare(Guid id, [FromBody] CipherShareRequestModel model)
700723
{
701724
var user = await _userService.GetUserByPrincipalAsync(User);
@@ -731,8 +754,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
731754
return response;
732755
}
733756

757+
[HttpPost("{id}/share")]
758+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
759+
public async Task<CipherResponseModel> PostPutShare(Guid id, [FromBody] CipherShareRequestModel model)
760+
{
761+
return await PutShare(id, model);
762+
}
763+
734764
[HttpPut("{id}/collections")]
735-
[HttpPost("{id}/collections")]
736765
public async Task<CipherDetailsResponseModel> PutCollections(Guid id, [FromBody] CipherCollectionsRequestModel model)
737766
{
738767
var user = await _userService.GetUserByPrincipalAsync(User);
@@ -757,8 +786,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
757786
collectionCiphers);
758787
}
759788

789+
[HttpPost("{id}/collections")]
790+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
791+
public async Task<CipherDetailsResponseModel> PostPutCollections(Guid id, [FromBody] CipherCollectionsRequestModel model)
792+
{
793+
return await PutCollections(id, model);
794+
}
795+
760796
[HttpPut("{id}/collections_v2")]
761-
[HttpPost("{id}/collections_v2")]
762797
public async Task<OptionalCipherDetailsResponseModel> PutCollections_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
763798
{
764799
var user = await _userService.GetUserByPrincipalAsync(User);
@@ -791,8 +826,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
791826
return response;
792827
}
793828

829+
[HttpPost("{id}/collections_v2")]
830+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
831+
public async Task<OptionalCipherDetailsResponseModel> PostPutCollections_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
832+
{
833+
return await PutCollections_vNext(id, model);
834+
}
835+
794836
[HttpPut("{id}/collections-admin")]
795-
[HttpPost("{id}/collections-admin")]
796837
public async Task<CipherMiniDetailsResponseModel> PutCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
797838
{
798839
var userId = _userService.GetProperUserId(User).Value;
@@ -821,6 +862,13 @@ public async Task<CipherMiniDetailsResponseModel> PutCollectionsAdmin(string id,
821862
return new CipherMiniDetailsResponseModel(cipher, _globalSettings, collectionCiphersGroupDict, cipher.OrganizationUseTotp);
822863
}
823864

865+
[HttpPost("{id}/collections-admin")]
866+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
867+
public async Task<CipherMiniDetailsResponseModel> PostPutCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
868+
{
869+
return await PutCollectionsAdmin(id, model);
870+
}
871+
824872
[HttpPost("bulk-collections")]
825873
public async Task PostBulkCollections([FromBody] CipherBulkUpdateCollectionsRequestModel model)
826874
{
@@ -841,7 +889,6 @@ public async Task PostBulkCollections([FromBody] CipherBulkUpdateCollectionsRequ
841889
}
842890

843891
[HttpDelete("{id}")]
844-
[HttpPost("{id}/delete")]
845892
public async Task Delete(Guid id)
846893
{
847894
var userId = _userService.GetProperUserId(User).Value;
@@ -854,8 +901,14 @@ public async Task Delete(Guid id)
854901
await _cipherService.DeleteAsync(cipher, userId);
855902
}
856903

904+
[HttpPost("{id}/delete")]
905+
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
906+
public async Task PostDelete(Guid id)
907+
{
908+
await Delete(id);
909+
}
910+
857911
[HttpDelete("{id}/admin")]
858-
[HttpPost("{id}/delete-admin")]
859912
public async Task DeleteAdmin(Guid id)
860913
{
861914
var userId = _userService.GetProperUserId(User).Value;
@@ -869,8 +922,14 @@ public async Task DeleteAdmin(Guid id)
869922
await _cipherService.DeleteAsync(cipher, userId, true);
870923
}
871924

925+
[HttpPost("{id}/delete-admin")]
926+
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
927+
public async Task PostDeleteAdmin(Guid id)
928+
{
929+
await DeleteAdmin(id);
930+
}
931+
872932
[HttpDelete("")]
873-
[HttpPost("delete")]
874933
public async Task DeleteMany([FromBody] CipherBulkDeleteRequestModel model)
875934
{
876935
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
@@ -883,8 +942,14 @@ public async Task DeleteMany([FromBody] CipherBulkDeleteRequestModel model)
883942
await _cipherService.DeleteManyAsync(model.Ids.Select(i => new Guid(i)), userId);
884943
}
885944

945+
[HttpPost("delete")]
946+
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
947+
public async Task PostDeleteMany([FromBody] CipherBulkDeleteRequestModel model)
948+
{
949+
await DeleteMany(model);
950+
}
951+
886952
[HttpDelete("admin")]
887-
[HttpPost("delete-admin")]
888953
public async Task DeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
889954
{
890955
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
@@ -910,6 +975,13 @@ public async Task DeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
910975
await _cipherService.DeleteManyAsync(cipherIds, userId, new Guid(model.OrganizationId), true);
911976
}
912977

978+
[HttpPost("delete-admin")]
979+
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
980+
public async Task PostDeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
981+
{
982+
await DeleteManyAdmin(model);
983+
}
984+
913985
[HttpPut("{id}/delete")]
914986
public async Task PutDelete(Guid id)
915987
{
@@ -1050,7 +1122,6 @@ public async Task<ListResponseModel<CipherMiniResponseModel>> PutRestoreManyAdmi
10501122
}
10511123

10521124
[HttpPut("move")]
1053-
[HttpPost("move")]
10541125
public async Task MoveMany([FromBody] CipherBulkMoveRequestModel model)
10551126
{
10561127
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
@@ -1063,8 +1134,14 @@ public async Task MoveMany([FromBody] CipherBulkMoveRequestModel model)
10631134
string.IsNullOrWhiteSpace(model.FolderId) ? (Guid?)null : new Guid(model.FolderId), userId);
10641135
}
10651136

1137+
[HttpPost("move")]
1138+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
1139+
public async Task PostMoveMany([FromBody] CipherBulkMoveRequestModel model)
1140+
{
1141+
await MoveMany(model);
1142+
}
1143+
10661144
[HttpPut("share")]
1067-
[HttpPost("share")]
10681145
public async Task<ListResponseModel<CipherMiniResponseModel>> PutShareMany([FromBody] CipherBulkShareRequestModel model)
10691146
{
10701147
var organizationId = new Guid(model.Ciphers.First().OrganizationId);
@@ -1112,6 +1189,13 @@ public async Task<ListResponseModel<CipherMiniResponseModel>> PutShareMany([From
11121189
return new ListResponseModel<CipherMiniResponseModel>(response);
11131190
}
11141191

1192+
[HttpPost("share")]
1193+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
1194+
public async Task<ListResponseModel<CipherMiniResponseModel>> PostPutShareMany([FromBody] CipherBulkShareRequestModel model)
1195+
{
1196+
return await PutShareMany(model);
1197+
}
1198+
11151199
[HttpPost("purge")]
11161200
public async Task PostPurge([FromBody] SecretVerificationRequestModel model, Guid? organizationId = null)
11171201
{
@@ -1230,7 +1314,7 @@ await Request.GetFileAsync(async (stream) =>
12301314
[Obsolete("Deprecated Attachments API", false)]
12311315
[RequestSizeLimit(Constants.FileSize101mb)]
12321316
[DisableFormValueModelBinding]
1233-
public async Task<CipherResponseModel> PostAttachment(Guid id)
1317+
public async Task<CipherResponseModel> PostAttachmentV1(Guid id)
12341318
{
12351319
ValidateAttachment();
12361320

@@ -1324,7 +1408,6 @@ await _cipherService.CreateAttachmentShareAsync(cipher, stream, fileName, key,
13241408
}
13251409

13261410
[HttpDelete("{id}/attachment/{attachmentId}")]
1327-
[HttpPost("{id}/attachment/{attachmentId}/delete")]
13281411
public async Task<DeleteAttachmentResponseData> DeleteAttachment(Guid id, string attachmentId)
13291412
{
13301413
var userId = _userService.GetProperUserId(User).Value;
@@ -1337,8 +1420,14 @@ public async Task<DeleteAttachmentResponseData> DeleteAttachment(Guid id, string
13371420
return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, false);
13381421
}
13391422

1423+
[HttpPost("{id}/attachment/{attachmentId}/delete")]
1424+
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
1425+
public async Task<DeleteAttachmentResponseData> PostDeleteAttachment(Guid id, string attachmentId)
1426+
{
1427+
return await DeleteAttachment(id, attachmentId);
1428+
}
1429+
13401430
[HttpDelete("{id}/attachment/{attachmentId}/admin")]
1341-
[HttpPost("{id}/attachment/{attachmentId}/delete-admin")]
13421431
public async Task<DeleteAttachmentResponseData> DeleteAttachmentAdmin(Guid id, string attachmentId)
13431432
{
13441433
var userId = _userService.GetProperUserId(User).Value;
@@ -1352,6 +1441,13 @@ public async Task<DeleteAttachmentResponseData> DeleteAttachmentAdmin(Guid id, s
13521441
return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, true);
13531442
}
13541443

1444+
[HttpPost("{id}/attachment/{attachmentId}/delete-admin")]
1445+
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
1446+
public async Task<DeleteAttachmentResponseData> PostDeleteAttachmentAdmin(Guid id, string attachmentId)
1447+
{
1448+
return await DeleteAttachmentAdmin(id, attachmentId);
1449+
}
1450+
13551451
[AllowAnonymous]
13561452
[HttpPost("attachment/validate/azure")]
13571453
public async Task<ObjectResult> AzureValidateFile()

src/Api/Vault/Controllers/FoldersController.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public async Task<FolderResponseModel> Get(string id)
4545
}
4646

4747
[HttpGet("")]
48-
public async Task<ListResponseModel<FolderResponseModel>> Get()
48+
public async Task<ListResponseModel<FolderResponseModel>> GetAll()
4949
{
5050
var userId = _userService.GetProperUserId(User).Value;
5151
var folders = await _folderRepository.GetManyByUserIdAsync(userId);
@@ -63,7 +63,6 @@ public async Task<FolderResponseModel> Post([FromBody] FolderRequestModel model)
6363
}
6464

6565
[HttpPut("{id}")]
66-
[HttpPost("{id}")]
6766
public async Task<FolderResponseModel> Put(string id, [FromBody] FolderRequestModel model)
6867
{
6968
var userId = _userService.GetProperUserId(User).Value;
@@ -77,8 +76,14 @@ public async Task<FolderResponseModel> Put(string id, [FromBody] FolderRequestMo
7776
return new FolderResponseModel(folder);
7877
}
7978

79+
[HttpPost("{id}")]
80+
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
81+
public async Task<FolderResponseModel> PostPut(string id, [FromBody] FolderRequestModel model)
82+
{
83+
return await Put(id, model);
84+
}
85+
8086
[HttpDelete("{id}")]
81-
[HttpPost("{id}/delete")]
8287
public async Task Delete(string id)
8388
{
8489
var userId = _userService.GetProperUserId(User).Value;
@@ -91,6 +96,13 @@ public async Task Delete(string id)
9196
await _cipherService.DeleteFolderAsync(folder);
9297
}
9398

99+
[HttpPost("{id}/delete")]
100+
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
101+
public async Task PostDelete(string id)
102+
{
103+
await Delete(id);
104+
}
105+
94106
[HttpDelete("all")]
95107
public async Task DeleteAll()
96108
{

0 commit comments

Comments
 (0)