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

Swagger Specifications are incomplete #1145

Open
xantari opened this issue Mar 17, 2024 · 0 comments
Open

Swagger Specifications are incomplete #1145

xantari opened this issue Mar 17, 2024 · 0 comments

Comments

@xantari
Copy link

xantari commented Mar 17, 2024

Describe the bug

The swagger specifications are missing the other potential response codes. For instance, the TodoItems endpoint has a CreateTodoItem. The swagger specification only mentions HTTP 200 as a potential result status.

However, if you pass in a request to that method with a blank title, the ValidationBehaviour which will throw a validation error. This then in turn gets routed to the CustomExceptionHandler, which returns Status400BadRequest and returns a ValidationProblemDetails.

For completeness, these other return types should be emitted as part of the swagger specification.json but they are not because the endpoint builders are not letting nswag know about these additional return values.

To Reproduce

Use the following json in the POST to /api/TodoItems:

{
  "listId": 0,
  "title": ""
}

You will notice that it works fine. However an undocumented return status code is emitted (HTTP Status 400).

Expected behavior
The error is being returned properly. However the swagger specification.json is not showing that as a potential return value and not describing the return object that will be returned when validation errors occur (ValidationProblemDetailsobject). This should be fully described by the API. This is normally done by annotating the API endpoints potential HTTP return status codes.

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

No branches or pull requests

1 participant