1
0
mirror of https://github.com/bitwarden/server synced 2025-12-06 00:03:34 +00:00

[PM-25182] Improve Swagger OperationIDs for Vault (#6240)

* Improve Swagger OperationIDs for Vault

* Some renames
This commit is contained in:
Daniel García
2025-09-15 18:05:06 +02:00
committed by GitHub
parent 0ee307a027
commit a173e7e2da
2 changed files with 129 additions and 21 deletions

View File

@@ -118,7 +118,6 @@ public class CiphersController : Controller
return new CipherMiniDetailsResponseModel(cipher, _globalSettings, collectionCiphersGroupDict, cipher.OrganizationUseTotp); return new CipherMiniDetailsResponseModel(cipher, _globalSettings, collectionCiphersGroupDict, cipher.OrganizationUseTotp);
} }
[HttpGet("{id}/full-details")]
[HttpGet("{id}/details")] [HttpGet("{id}/details")]
public async Task<CipherDetailsResponseModel> GetDetails(Guid id) public async Task<CipherDetailsResponseModel> GetDetails(Guid id)
{ {
@@ -134,8 +133,15 @@ public class CiphersController : Controller
return new CipherDetailsResponseModel(cipher, user, organizationAbilities, _globalSettings, collectionCiphers); return new CipherDetailsResponseModel(cipher, user, organizationAbilities, _globalSettings, collectionCiphers);
} }
[HttpGet("{id}/full-details")]
[Obsolete("This endpoint is deprecated. Use GET details method instead.")]
public async Task<CipherDetailsResponseModel> GetFullDetails(Guid id)
{
return await GetDetails(id);
}
[HttpGet("")] [HttpGet("")]
public async Task<ListResponseModel<CipherDetailsResponseModel>> Get() public async Task<ListResponseModel<CipherDetailsResponseModel>> GetAll()
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
var hasOrgs = _currentContext.Organizations.Count != 0; var hasOrgs = _currentContext.Organizations.Count != 0;
@@ -242,7 +248,6 @@ public class CiphersController : Controller
} }
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")]
public async Task<CipherResponseModel> Put(Guid id, [FromBody] CipherRequestModel model) public async Task<CipherResponseModel> Put(Guid id, [FromBody] CipherRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
@@ -283,8 +288,14 @@ public class CiphersController : Controller
return response; return response;
} }
[HttpPost("{id}")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherResponseModel> PostPut(Guid id, [FromBody] CipherRequestModel model)
{
return await Put(id, model);
}
[HttpPut("{id}/admin")] [HttpPut("{id}/admin")]
[HttpPost("{id}/admin")]
public async Task<CipherMiniResponseModel> PutAdmin(Guid id, [FromBody] CipherRequestModel model) public async Task<CipherMiniResponseModel> PutAdmin(Guid id, [FromBody] CipherRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
@@ -317,6 +328,13 @@ public class CiphersController : Controller
return response; return response;
} }
[HttpPost("{id}/admin")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherMiniResponseModel> PostPutAdmin(Guid id, [FromBody] CipherRequestModel model)
{
return await PutAdmin(id, model);
}
[HttpGet("organization-details")] [HttpGet("organization-details")]
public async Task<ListResponseModel<CipherMiniDetailsResponseModel>> GetOrganizationCiphers(Guid organizationId) public async Task<ListResponseModel<CipherMiniDetailsResponseModel>> GetOrganizationCiphers(Guid organizationId)
{ {
@@ -691,7 +709,6 @@ public class CiphersController : Controller
} }
[HttpPut("{id}/partial")] [HttpPut("{id}/partial")]
[HttpPost("{id}/partial")]
public async Task<CipherResponseModel> PutPartial(Guid id, [FromBody] CipherPartialRequestModel model) public async Task<CipherResponseModel> PutPartial(Guid id, [FromBody] CipherPartialRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
@@ -707,8 +724,14 @@ public class CiphersController : Controller
return response; return response;
} }
[HttpPost("{id}/partial")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherResponseModel> PostPartial(Guid id, [FromBody] CipherPartialRequestModel model)
{
return await PutPartial(id, model);
}
[HttpPut("{id}/share")] [HttpPut("{id}/share")]
[HttpPost("{id}/share")]
public async Task<CipherResponseModel> PutShare(Guid id, [FromBody] CipherShareRequestModel model) public async Task<CipherResponseModel> PutShare(Guid id, [FromBody] CipherShareRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
@@ -744,8 +767,14 @@ public class CiphersController : Controller
return response; return response;
} }
[HttpPost("{id}/share")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherResponseModel> PostShare(Guid id, [FromBody] CipherShareRequestModel model)
{
return await PutShare(id, model);
}
[HttpPut("{id}/collections")] [HttpPut("{id}/collections")]
[HttpPost("{id}/collections")]
public async Task<CipherDetailsResponseModel> PutCollections(Guid id, [FromBody] CipherCollectionsRequestModel model) public async Task<CipherDetailsResponseModel> PutCollections(Guid id, [FromBody] CipherCollectionsRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
@@ -770,8 +799,14 @@ public class CiphersController : Controller
collectionCiphers); collectionCiphers);
} }
[HttpPost("{id}/collections")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherDetailsResponseModel> PostCollections(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutCollections(id, model);
}
[HttpPut("{id}/collections_v2")] [HttpPut("{id}/collections_v2")]
[HttpPost("{id}/collections_v2")]
public async Task<OptionalCipherDetailsResponseModel> PutCollections_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model) public async Task<OptionalCipherDetailsResponseModel> PutCollections_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
@@ -804,8 +839,14 @@ public class CiphersController : Controller
return response; return response;
} }
[HttpPost("{id}/collections_v2")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<OptionalCipherDetailsResponseModel> PostCollections_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutCollections_vNext(id, model);
}
[HttpPut("{id}/collections-admin")] [HttpPut("{id}/collections-admin")]
[HttpPost("{id}/collections-admin")]
public async Task<CipherMiniDetailsResponseModel> PutCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model) public async Task<CipherMiniDetailsResponseModel> PutCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
@@ -834,6 +875,13 @@ public class CiphersController : Controller
return new CipherMiniDetailsResponseModel(cipher, _globalSettings, collectionCiphersGroupDict, cipher.OrganizationUseTotp); return new CipherMiniDetailsResponseModel(cipher, _globalSettings, collectionCiphersGroupDict, cipher.OrganizationUseTotp);
} }
[HttpPost("{id}/collections-admin")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherMiniDetailsResponseModel> PostCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutCollectionsAdmin(id, model);
}
[HttpPost("bulk-collections")] [HttpPost("bulk-collections")]
public async Task PostBulkCollections([FromBody] CipherBulkUpdateCollectionsRequestModel model) public async Task PostBulkCollections([FromBody] CipherBulkUpdateCollectionsRequestModel model)
{ {
@@ -895,7 +943,6 @@ public class CiphersController : Controller
} }
[HttpDelete("{id}")] [HttpDelete("{id}")]
[HttpPost("{id}/delete")]
public async Task Delete(Guid id) public async Task Delete(Guid id)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
@@ -908,8 +955,14 @@ public class CiphersController : Controller
await _cipherService.DeleteAsync(cipher, userId); await _cipherService.DeleteAsync(cipher, userId);
} }
[HttpPost("{id}/delete")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDelete(Guid id)
{
await Delete(id);
}
[HttpDelete("{id}/admin")] [HttpDelete("{id}/admin")]
[HttpPost("{id}/delete-admin")]
public async Task DeleteAdmin(Guid id) public async Task DeleteAdmin(Guid id)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
@@ -923,8 +976,14 @@ public class CiphersController : Controller
await _cipherService.DeleteAsync(cipher, userId, true); await _cipherService.DeleteAsync(cipher, userId, true);
} }
[HttpPost("{id}/delete-admin")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDeleteAdmin(Guid id)
{
await DeleteAdmin(id);
}
[HttpDelete("")] [HttpDelete("")]
[HttpPost("delete")]
public async Task DeleteMany([FromBody] CipherBulkDeleteRequestModel model) public async Task DeleteMany([FromBody] CipherBulkDeleteRequestModel model)
{ {
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
@@ -937,8 +996,14 @@ public class CiphersController : Controller
await _cipherService.DeleteManyAsync(model.Ids.Select(i => new Guid(i)), userId); await _cipherService.DeleteManyAsync(model.Ids.Select(i => new Guid(i)), userId);
} }
[HttpPost("delete")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDeleteMany([FromBody] CipherBulkDeleteRequestModel model)
{
await DeleteMany(model);
}
[HttpDelete("admin")] [HttpDelete("admin")]
[HttpPost("delete-admin")]
public async Task DeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model) public async Task DeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
{ {
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
@@ -964,6 +1029,13 @@ public class CiphersController : Controller
await _cipherService.DeleteManyAsync(cipherIds, userId, new Guid(model.OrganizationId), true); await _cipherService.DeleteManyAsync(cipherIds, userId, new Guid(model.OrganizationId), true);
} }
[HttpPost("delete-admin")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
{
await DeleteManyAdmin(model);
}
[HttpPut("{id}/delete")] [HttpPut("{id}/delete")]
public async Task PutDelete(Guid id) public async Task PutDelete(Guid id)
{ {
@@ -1145,7 +1217,6 @@ public class CiphersController : Controller
} }
[HttpPut("move")] [HttpPut("move")]
[HttpPost("move")]
public async Task MoveMany([FromBody] CipherBulkMoveRequestModel model) public async Task MoveMany([FromBody] CipherBulkMoveRequestModel model)
{ {
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
@@ -1158,8 +1229,14 @@ public class CiphersController : Controller
string.IsNullOrWhiteSpace(model.FolderId) ? (Guid?)null : new Guid(model.FolderId), userId); string.IsNullOrWhiteSpace(model.FolderId) ? (Guid?)null : new Guid(model.FolderId), userId);
} }
[HttpPost("move")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task PostMoveMany([FromBody] CipherBulkMoveRequestModel model)
{
await MoveMany(model);
}
[HttpPut("share")] [HttpPut("share")]
[HttpPost("share")]
public async Task<ListResponseModel<CipherMiniResponseModel>> PutShareMany([FromBody] CipherBulkShareRequestModel model) public async Task<ListResponseModel<CipherMiniResponseModel>> PutShareMany([FromBody] CipherBulkShareRequestModel model)
{ {
var organizationId = new Guid(model.Ciphers.First().OrganizationId); var organizationId = new Guid(model.Ciphers.First().OrganizationId);
@@ -1207,6 +1284,13 @@ public class CiphersController : Controller
return new ListResponseModel<CipherMiniResponseModel>(response); return new ListResponseModel<CipherMiniResponseModel>(response);
} }
[HttpPost("share")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<ListResponseModel<CipherMiniResponseModel>> PostShareMany([FromBody] CipherBulkShareRequestModel model)
{
return await PutShareMany(model);
}
[HttpPost("purge")] [HttpPost("purge")]
public async Task PostPurge([FromBody] SecretVerificationRequestModel model, Guid? organizationId = null) public async Task PostPurge([FromBody] SecretVerificationRequestModel model, Guid? organizationId = null)
{ {
@@ -1325,7 +1409,7 @@ public class CiphersController : Controller
[Obsolete("Deprecated Attachments API", false)] [Obsolete("Deprecated Attachments API", false)]
[RequestSizeLimit(Constants.FileSize101mb)] [RequestSizeLimit(Constants.FileSize101mb)]
[DisableFormValueModelBinding] [DisableFormValueModelBinding]
public async Task<CipherResponseModel> PostAttachment(Guid id) public async Task<CipherResponseModel> PostAttachmentV1(Guid id)
{ {
ValidateAttachment(); ValidateAttachment();
@@ -1419,7 +1503,6 @@ public class CiphersController : Controller
} }
[HttpDelete("{id}/attachment/{attachmentId}")] [HttpDelete("{id}/attachment/{attachmentId}")]
[HttpPost("{id}/attachment/{attachmentId}/delete")]
public async Task<DeleteAttachmentResponseData> DeleteAttachment(Guid id, string attachmentId) public async Task<DeleteAttachmentResponseData> DeleteAttachment(Guid id, string attachmentId)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
@@ -1432,8 +1515,14 @@ public class CiphersController : Controller
return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, false); return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, false);
} }
[HttpPost("{id}/attachment/{attachmentId}/delete")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task<DeleteAttachmentResponseData> PostDeleteAttachment(Guid id, string attachmentId)
{
return await DeleteAttachment(id, attachmentId);
}
[HttpDelete("{id}/attachment/{attachmentId}/admin")] [HttpDelete("{id}/attachment/{attachmentId}/admin")]
[HttpPost("{id}/attachment/{attachmentId}/delete-admin")]
public async Task<DeleteAttachmentResponseData> DeleteAttachmentAdmin(Guid id, string attachmentId) public async Task<DeleteAttachmentResponseData> DeleteAttachmentAdmin(Guid id, string attachmentId)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
@@ -1447,6 +1536,13 @@ public class CiphersController : Controller
return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, true); return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, true);
} }
[HttpPost("{id}/attachment/{attachmentId}/delete-admin")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task<DeleteAttachmentResponseData> PostDeleteAttachmentAdmin(Guid id, string attachmentId)
{
return await DeleteAttachmentAdmin(id, attachmentId);
}
[AllowAnonymous] [AllowAnonymous]
[HttpPost("attachment/validate/azure")] [HttpPost("attachment/validate/azure")]
public async Task<ObjectResult> AzureValidateFile() public async Task<ObjectResult> AzureValidateFile()

View File

@@ -45,7 +45,7 @@ public class FoldersController : Controller
} }
[HttpGet("")] [HttpGet("")]
public async Task<ListResponseModel<FolderResponseModel>> Get() public async Task<ListResponseModel<FolderResponseModel>> GetAll()
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var folders = await _folderRepository.GetManyByUserIdAsync(userId); var folders = await _folderRepository.GetManyByUserIdAsync(userId);
@@ -63,7 +63,6 @@ public class FoldersController : Controller
} }
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")]
public async Task<FolderResponseModel> Put(string id, [FromBody] FolderRequestModel model) public async Task<FolderResponseModel> Put(string id, [FromBody] FolderRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
@@ -77,8 +76,14 @@ public class FoldersController : Controller
return new FolderResponseModel(folder); return new FolderResponseModel(folder);
} }
[HttpPost("{id}")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<FolderResponseModel> PostPut(string id, [FromBody] FolderRequestModel model)
{
return await Put(id, model);
}
[HttpDelete("{id}")] [HttpDelete("{id}")]
[HttpPost("{id}/delete")]
public async Task Delete(string id) public async Task Delete(string id)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
@@ -91,6 +96,13 @@ public class FoldersController : Controller
await _cipherService.DeleteFolderAsync(folder); await _cipherService.DeleteFolderAsync(folder);
} }
[HttpPost("{id}/delete")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDelete(string id)
{
await Delete(id);
}
[HttpDelete("all")] [HttpDelete("all")]
public async Task DeleteAll() public async Task DeleteAll()
{ {