Swashbuckle.AspNetCore icon indicating copy to clipboard operation
Swashbuckle.AspNetCore copied to clipboard

[Feature req] Force different parameter type specification due to custom model binder

Open steuic opened this issue 2 years ago • 1 comments

I have and endpoint which uses a custom model binder that decrypts a string to an integer id (decryption use authenticated user session data) for a given parameter:

        /// <summary>
        /// Retrieve an image with given id
        /// </summary>
        /// <param name="imageId">string identifier of the image to be retrieved</param>
        /// <returns></returns>
        [HttpGet]
        [Route("get/{imageId}")]
        public IActionResult Get(
            [FromRoute,
             ModelBinder(BinderType = typeof(MyCustomModelBinder))] int imageId)
        {
            // here:
            // -before this method execution, MyCustomModelBinder decrypt string imagedId (using user session data) and produces a valid int imageId
            // -then this metod retrieve image with given id imageId and returns image data
        }

Even if imageId parameter is defined as int, the REST call should use a string. Example: GET https://localhost/images/get/BQwlwDLHGXoUvich4fxhzw%3D%3D

A new feature that for a given parameter allow to force Swashbuckle to use a specific type in swagger document (despite its declaring type) will be very useful for this scenario.

steuic avatar Aug 29 '22 09:08 steuic

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

github-actions[bot] avatar Apr 18 '24 01:04 github-actions[bot]

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

github-actions[bot] avatar Jun 25 '24 01:06 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jul 14 '24 01:07 github-actions[bot]