From 6fa82cabf2eebec572d23ff49a650e04128d2514 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 21 Aug 2020 17:41:29 +0800 Subject: ... --- Timeline/Controllers/TimelineController.cs | 144 ++++++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 1 deletion(-) (limited to 'Timeline/Controllers/TimelineController.cs') diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index 72404ea3..b376bce5 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -17,8 +17,12 @@ using Timeline.Services.Exceptions; namespace Timeline.Controllers { + /// + /// Operations about timeline. + /// [ApiController] [CatchTimelineNotExistException] + [ProducesErrorResponseType(typeof(CommonResponse))] public class TimelineController : Controller { private readonly ILogger _logger; @@ -28,6 +32,9 @@ namespace Timeline.Controllers private readonly IMapper _mapper; + /// + /// + /// public TimelineController(ILogger logger, IUserService userService, ITimelineService service, IMapper mapper) { _logger = logger; @@ -36,7 +43,17 @@ namespace Timeline.Controllers _mapper = mapper; } + /// + /// List all timelines. + /// + /// A username. If set, only timelines related to the user will return. + /// Specify the relation type, may be 'own' or 'join'. If not set, both type will return. + /// "Private" or "Register" or "Public". If set, only timelines whose visibility is specified one will return. + /// Succeeded to get timelines. + /// Model is invalid. Or user specified by "relate" param does not exist. [HttpGet("timelines")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] public async Task>> TimelineList([FromQuery][Username] string? relate, [FromQuery][RegularExpression("(own)|(join)")] string? relateType, [FromQuery] string? visibility) { List? visibilityFilter = null; @@ -93,7 +110,20 @@ namespace Timeline.Controllers return result; } + /// + /// Get info of a timeline. + /// + /// The timeline name. + /// A unique id. If specified and if-modified-since is also specified, the timeline info will return when unique id is not the specified one even if it is not modified. + /// Same effect as If-Modified-Since header and take precedence than it. + /// If specified, will return 304 if not modified. + /// Succeeded to get timeline info. + /// Timeline not change. + /// Timeline does not exist. [HttpGet("timelines/{name}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status304NotModified)] + [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task> TimelineGet([FromRoute][GeneralTimelineName] string name, [FromQuery] string? checkUniqueId, [FromQuery(Name = "ifModifiedSince")] DateTime? queryIfModifiedSince, [FromHeader(Name = "If-Modified-Since")] DateTime? headerIfModifiedSince) { DateTime? ifModifiedSince = null; @@ -140,7 +170,19 @@ namespace Timeline.Controllers } } + /// + /// Get posts of a timeline. You need to have permission. + /// + /// The name of the timeline. + /// If set, only posts modified since the time will return. + /// If set to true, deleted post will also return. + /// Succeeded to get posts. + /// You have no permission. + /// The timeline does not exist. [HttpGet("timelines/{name}/posts")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task>> PostListGet([FromRoute][GeneralTimelineName] string name, [FromQuery] DateTime? modifiedSince, [FromQuery] bool? includeDeleted) { if (!this.IsAdministrator() && !await _service.HasReadPermission(name, this.GetOptionalUserId())) @@ -154,9 +196,26 @@ namespace Timeline.Controllers return result; } + /// + /// Get the data of a post. Usually a image post. You need to have permission. + /// + /// Timeline name. + /// The id of the post. + /// If-None-Match header. + /// Succeeded to get data. + /// Data not changed. + /// Error code is 11040502 if post has no data. + /// You have no permission. + /// Timeline or post does not exist. [HttpGet("timelines/{name}/posts/{id}/data")] - public async Task>> PostDataGet([FromRoute][GeneralTimelineName] string name, [FromRoute] long id) + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(typeof(void), StatusCodes.Status304NotModified)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PostDataGet([FromRoute][GeneralTimelineName] string name, [FromRoute] long id, [FromHeader(Name = "If-None-Match")] string? ifNoneMatch) { + _ = ifNoneMatch; if (!this.IsAdministrator() && !await _service.HasReadPermission(name, this.GetOptionalUserId())) { return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid()); @@ -180,8 +239,22 @@ namespace Timeline.Controllers } } + /// + /// Create a new post. You need to have permission. + /// + /// Timeline name. + /// + /// Info of new post. + /// Succeeded to create post and return info of new post. + /// Body model is invalid. + /// You have not logged in. + /// You have no permission. [HttpPost("timelines/{name}/posts")] [Authorize] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task> PostPost([FromRoute][GeneralTimelineName] string name, [FromBody] TimelinePostCreateRequest body) { var id = this.GetUserId(); @@ -238,8 +311,19 @@ namespace Timeline.Controllers return result; } + /// + /// Delete a post. + /// + /// Timeline name. + /// Post id. + /// Succeeded to delete post. Or post does not exist. + /// You have not logged in. + /// You have no permission. [HttpDelete("timelines/{name}/posts/{id}")] [Authorize] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task> PostDelete([FromRoute][GeneralTimelineName] string name, [FromRoute] long id) { if (!this.IsAdministrator() && !await _service.HasPostModifyPermission(name, id, this.GetUserId())) @@ -257,8 +341,20 @@ namespace Timeline.Controllers } } + /// + /// Change properties of a timeline. + /// + /// Timeline name. + /// + /// The new info. + /// Succeeded to change properties of timeline. Return the new info. + /// You have not logged in. + /// You have no permission. [HttpPatch("timelines/{name}")] [Authorize] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task> TimelinePatch([FromRoute][GeneralTimelineName] string name, [FromBody] TimelinePatchRequest body) { if (!this.IsAdministrator() && !(await _service.HasManagePermission(name, this.GetUserId()))) @@ -271,8 +367,21 @@ namespace Timeline.Controllers return result; } + /// + /// Add a member to timeline. + /// + /// Timeline name. + /// The new member's username. + /// Succeeded. + /// User does not exist. + /// You have not logged in. + /// You have no permission. [HttpPut("timelines/{name}/members/{member}")] [Authorize] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task TimelineMemberPut([FromRoute][GeneralTimelineName] string name, [FromRoute][Username] string member) { if (!this.IsAdministrator() && !(await _service.HasManagePermission(name, this.GetUserId()))) @@ -291,8 +400,19 @@ namespace Timeline.Controllers } } + /// + /// Remove a member from timeline. + /// + /// Timeline name. + /// The member's username. + /// Succeeded. Or the user is not a member. + /// You have not logged in. + /// You have no permission. [HttpDelete("timelines/{name}/members/{member}")] [Authorize] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task TimelineMemberDelete([FromRoute][GeneralTimelineName] string name, [FromRoute][Username] string member) { if (!this.IsAdministrator() && !(await _service.HasManagePermission(name, this.GetUserId()))) @@ -311,8 +431,19 @@ namespace Timeline.Controllers } } + /// + /// Create a timeline. + /// + /// + /// Info of new timeline. + /// Succeeded and return info of new timeline. + /// Timeline name is conflict. + /// You have not logged in. [HttpPost("timelines")] [Authorize] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] public async Task> TimelineCreate([FromBody] TimelineCreateRequest body) { var userId = this.GetUserId(); @@ -329,8 +460,19 @@ namespace Timeline.Controllers } } + /// + /// Delete a timeline. + /// + /// Timeline name. + /// Succeeded. Or timeline does not exist. + /// You have not logged in. + /// You have no permission. [HttpDelete("timelines/{name}")] [Authorize] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task> TimelineDelete([FromRoute][TimelineName] string name) { if (!this.IsAdministrator() && !(await _service.HasManagePermission(name, this.GetUserId()))) -- cgit v1.2.3 From 53888df71f7580bf169dfab3d13d313cf96d26df Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 21 Aug 2020 21:25:33 +0800 Subject: ... --- Timeline/Controllers/TimelineController.cs | 48 ++++------------------ Timeline/Controllers/TokenController.cs | 10 ++--- Timeline/Controllers/UserAvatarController.cs | 8 +--- Timeline/Controllers/UserController.cs | 39 +++++++----------- Timeline/Startup.cs | 2 + Timeline/Swagger/ApiConvention.cs | 15 +++++++ .../DefaultDescriptionOperationProcessor.cs | 39 ++++++++++++++++++ Timeline/Timeline.csproj | 1 + 8 files changed, 86 insertions(+), 76 deletions(-) create mode 100644 Timeline/Swagger/ApiConvention.cs create mode 100644 Timeline/Swagger/DefaultDescriptionOperationProcessor.cs (limited to 'Timeline/Controllers/TimelineController.cs') diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index b376bce5..43178ac6 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -49,8 +49,7 @@ namespace Timeline.Controllers /// A username. If set, only timelines related to the user will return. /// Specify the relation type, may be 'own' or 'join'. If not set, both type will return. /// "Private" or "Register" or "Public". If set, only timelines whose visibility is specified one will return. - /// Succeeded to get timelines. - /// Model is invalid. Or user specified by "relate" param does not exist. + /// The timeline list. [HttpGet("timelines")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] @@ -117,9 +116,7 @@ namespace Timeline.Controllers /// A unique id. If specified and if-modified-since is also specified, the timeline info will return when unique id is not the specified one even if it is not modified. /// Same effect as If-Modified-Since header and take precedence than it. /// If specified, will return 304 if not modified. - /// Succeeded to get timeline info. - /// Timeline not change. - /// Timeline does not exist. + /// The timeline info. [HttpGet("timelines/{name}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status304NotModified)] @@ -171,14 +168,12 @@ namespace Timeline.Controllers } /// - /// Get posts of a timeline. You need to have permission. + /// Get posts of a timeline. /// /// The name of the timeline. /// If set, only posts modified since the time will return. /// If set to true, deleted post will also return. - /// Succeeded to get posts. - /// You have no permission. - /// The timeline does not exist. + /// The post list. [HttpGet("timelines/{name}/posts")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status403Forbidden)] @@ -197,16 +192,12 @@ namespace Timeline.Controllers } /// - /// Get the data of a post. Usually a image post. You need to have permission. + /// Get the data of a post. Usually a image post. /// /// Timeline name. /// The id of the post. /// If-None-Match header. - /// Succeeded to get data. - /// Data not changed. - /// Error code is 11040502 if post has no data. - /// You have no permission. - /// Timeline or post does not exist. + /// The data. [HttpGet("timelines/{name}/posts/{id}/data")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(typeof(void), StatusCodes.Status304NotModified)] @@ -240,15 +231,11 @@ namespace Timeline.Controllers } /// - /// Create a new post. You need to have permission. + /// Create a new post. /// /// Timeline name. /// /// Info of new post. - /// Succeeded to create post and return info of new post. - /// Body model is invalid. - /// You have not logged in. - /// You have no permission. [HttpPost("timelines/{name}/posts")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -316,9 +303,7 @@ namespace Timeline.Controllers /// /// Timeline name. /// Post id. - /// Succeeded to delete post. Or post does not exist. - /// You have not logged in. - /// You have no permission. + /// Info of deletion. [HttpDelete("timelines/{name}/posts/{id}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -347,9 +332,6 @@ namespace Timeline.Controllers /// Timeline name. /// /// The new info. - /// Succeeded to change properties of timeline. Return the new info. - /// You have not logged in. - /// You have no permission. [HttpPatch("timelines/{name}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -372,10 +354,6 @@ namespace Timeline.Controllers /// /// Timeline name. /// The new member's username. - /// Succeeded. - /// User does not exist. - /// You have not logged in. - /// You have no permission. [HttpPut("timelines/{name}/members/{member}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -405,9 +383,6 @@ namespace Timeline.Controllers /// /// Timeline name. /// The member's username. - /// Succeeded. Or the user is not a member. - /// You have not logged in. - /// You have no permission. [HttpDelete("timelines/{name}/members/{member}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -436,9 +411,6 @@ namespace Timeline.Controllers /// /// /// Info of new timeline. - /// Succeeded and return info of new timeline. - /// Timeline name is conflict. - /// You have not logged in. [HttpPost("timelines")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -464,9 +436,7 @@ namespace Timeline.Controllers /// Delete a timeline. /// /// Timeline name. - /// Succeeded. Or timeline does not exist. - /// You have not logged in. - /// You have no permission. + /// Info of deletion. [HttpDelete("timelines/{name}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] diff --git a/Timeline/Controllers/TokenController.cs b/Timeline/Controllers/TokenController.cs index 7792b318..8f2ca600 100644 --- a/Timeline/Controllers/TokenController.cs +++ b/Timeline/Controllers/TokenController.cs @@ -40,11 +40,10 @@ namespace Timeline.Controllers /// /// Create a new token for a user. /// - /// Succeed to create token. - /// Error code is 11010101 if user does not exist or password is wrong. + /// Result of token creation. [HttpPost("create")] [AllowAnonymous] - [ProducesResponseType(typeof(CreateTokenResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] public async Task> Create([FromBody] CreateTokenRequest request) { @@ -91,11 +90,10 @@ namespace Timeline.Controllers /// /// Verify a token. /// - /// Token is valid. - /// Error code is 11010201 if token is of bad format (it may not be created by this server). Error code is 11010202 if user does not exist. Error code is 11010203 if token is of old version (user may have changed password). Error code is 11010204 if token is expired. + /// Result of token verification. [HttpPost("verify")] [AllowAnonymous] - [ProducesResponseType(typeof(VerifyTokenResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] public async Task> Verify([FromBody] VerifyTokenRequest request) { diff --git a/Timeline/Controllers/UserAvatarController.cs b/Timeline/Controllers/UserAvatarController.cs index 3d3bc983..52e87df2 100644 --- a/Timeline/Controllers/UserAvatarController.cs +++ b/Timeline/Controllers/UserAvatarController.cs @@ -42,9 +42,7 @@ namespace Timeline.Controllers /// /// Username of the user to get avatar of. /// If-None-Match header. - /// Succeeded to get the avatar. - /// The avatar does not change. - /// The user does not exist. + /// Avatar data. [HttpGet("users/{username}/avatar")] [ProducesResponseType(typeof(byte[]), StatusCodes.Status200OK)] [ProducesResponseType(typeof(void), StatusCodes.Status304NotModified)] @@ -74,10 +72,6 @@ namespace Timeline.Controllers /// Set avatar of a user. You have to be administrator to change other's. /// /// Username of the user to set avatar of. - /// Succeeded to set avatar. - /// Error code is 10010001 if user does not exist. Or avatar is of bad format. - /// You have not logged in. - /// You are not administrator. [HttpPut("users/{username}/avatar")] [Authorize] [RequireContentType, RequireContentLength] diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs index fa2d37d8..02c09aab 100644 --- a/Timeline/Controllers/UserController.cs +++ b/Timeline/Controllers/UserController.cs @@ -43,9 +43,9 @@ namespace Timeline.Controllers /// /// Get all users. /// - /// The user list. + /// All user list. [HttpGet("users")] - [ProducesResponseType(typeof(UserInfo[]), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] public async Task> List() { var users = await _userService.GetUsers(); @@ -54,12 +54,13 @@ namespace Timeline.Controllers } /// - /// Get a user info. + /// Get a user's info. /// /// Username of the user. - /// The user info. + /// User info. [HttpGet("users/{username}")] - [ProducesResponseType(typeof(UserInfo), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task> Get([FromRoute][Username] string username) { try @@ -75,16 +76,14 @@ namespace Timeline.Controllers } /// - /// Change a user's property. You have to be administrator in some condition. + /// Change a user's property. /// /// /// Username of the user to change. - /// Succeed to change the user and return the new user info. - /// You have not logged in. - /// You are not administrator. - /// The user to change does not exist. + /// The new user info. [HttpPatch("users/{username}"), Authorize] - [ProducesResponseType(typeof(UserInfo), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] @@ -134,11 +133,9 @@ namespace Timeline.Controllers /// Delete a user and all his related data. You have to be administrator. /// /// Username of the user to delete. - /// Succeeded to delete or the user does not exist. - /// You have not logged in. - /// You are not administrator. + /// Info of deletion. [HttpDelete("users/{username}"), AdminAuthorize] - [ProducesResponseType(typeof(CommonDeleteResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task> Delete([FromRoute][Username] string username) @@ -153,12 +150,9 @@ namespace Timeline.Controllers /// /// Create a new user. You have to be administrator. /// - /// Succeeded to create a new user and return his user info. - /// Error code is 11020101 if a user with given username already exists. - /// You have not logged in. - /// You are not administrator. + /// The new user's info. [HttpPost("userop/createuser"), AdminAuthorize] - [ProducesResponseType(typeof(UserInfo), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] @@ -178,11 +172,8 @@ namespace Timeline.Controllers /// /// Change password with old password. /// - /// Succeeded to change password. - /// Error code is 11020201 if old password is wrong. - /// You have not logged in. [HttpPost("userop/changepassword"), Authorize] - [ProducesResponseType(typeof(void), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] public async Task ChangePassword([FromBody] ChangePasswordRequest request) diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index 3e5dd24d..960bbc2c 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -20,6 +20,7 @@ using Timeline.Helpers; using Timeline.Models.Converters; using Timeline.Routes; using Timeline.Services; +using Timeline.Swagger; namespace Timeline { @@ -112,6 +113,7 @@ namespace Timeline Description = "Type into the textbox: Bearer {your JWT token}." })); document.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT")); + document.OperationProcessors.Add(new DefaultDescriptionOperationProcessor()); }); if (!disableFrontEnd) diff --git a/Timeline/Swagger/ApiConvention.cs b/Timeline/Swagger/ApiConvention.cs new file mode 100644 index 00000000..dbf0b2fe --- /dev/null +++ b/Timeline/Swagger/ApiConvention.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Mvc; + +[assembly: ApiConventionType(typeof(Timeline.Controllers.ApiConvention))] + +namespace Timeline.Controllers +{ + // There is some bug if nullable is enable. So disable it. +#nullable disable + /// + /// My api convention. + /// + public static class ApiConvention + { + } +} diff --git a/Timeline/Swagger/DefaultDescriptionOperationProcessor.cs b/Timeline/Swagger/DefaultDescriptionOperationProcessor.cs new file mode 100644 index 00000000..4967cc6a --- /dev/null +++ b/Timeline/Swagger/DefaultDescriptionOperationProcessor.cs @@ -0,0 +1,39 @@ +using NSwag.Generation.Processors; +using NSwag.Generation.Processors.Contexts; +using System.Collections.Generic; + +namespace Timeline.Swagger +{ + /// + /// Swagger operation processor that adds default description to response. + /// + public class DefaultDescriptionOperationProcessor : IOperationProcessor + { + private readonly Dictionary defaultDescriptionMap = new Dictionary + { + ["200"] = "Succeeded to perform the operation.", + ["304"] = "Item does not change.", + ["400"] = "See code and message for error info.", + ["401"] = "You need to log in to perform this operation.", + ["403"] = "You have no permission to perform the operation.", + ["404"] = "Item does not exist. See code and message for error info." + }; + + /// + public bool Process(OperationProcessorContext context) + { + var responses = context.OperationDescription.Operation.Responses; + + foreach (var (httpStatusCode, res) in responses) + { + if (!string.IsNullOrEmpty(res.Description)) continue; + if (defaultDescriptionMap.ContainsKey(httpStatusCode)) + { + res.Description = defaultDescriptionMap[httpStatusCode]; + } + } + + return true; + } + } +} diff --git a/Timeline/Timeline.csproj b/Timeline/Timeline.csproj index 5c2f7adf..5fc69fc8 100644 --- a/Timeline/Timeline.csproj +++ b/Timeline/Timeline.csproj @@ -17,6 +17,7 @@ 0.3.0 true + true -- cgit v1.2.3