Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[http-server-csharp] Errors defined on the spec is not honored at all #5224

Open
ArcturusZhang opened this issue Nov 29, 2024 · 0 comments
Open

Comments

@ArcturusZhang
Copy link
Member

The generated controller looks like this:

        [HttpGet]
        [Route("/items")]
        [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(TodoPage))]
        public virtual async Task<IActionResult> List([FromQuery(Name = "limit")] int limit = 50, [FromQuery(Name = "offset")] int offset = 0)
        {
            var result = await TodoItemsOperationsImpl.ListAsync(limit, offset);
            return Ok(result);
        }

which is always returning the successful result.
We also defined those errors with some specific status code, which means the server implementation should only return those status code in errors, but the current implementation, we did not really honor this - imagine this, since this controllerBase class is abstract, I must create a derived type, and these methods are virtual therefore I can override them to return any status code I want - if this is the case, we lose the benefit of defining those error status code in the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant