-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Idea: Improvements to Default OpenAPI Descriptions #432
Comments
implemented in public override void Configure()
{
//lack of AllowAnonymous() will auto add 401 produces meta
Roles("test"); //any Roles/Claims/Permissions will auto add 403 produces meta
Description(x => x
.ClearDefaultProduces(200, 401, 403) //user has the choice which default produces to clear
.Produces<Response>(201, "application/json"));
} mind the small breaking change in this beta build: https://github.com/FastEndpoints/FastEndpoints/blob/main/Src/Library/changelog.md#breaking-changes |
Works brilliantly. Thanks! |
@dj-nitehawk Curious about adding on one more case, what do you think? When ErrorOptions.ProducesMetadataType is set, it checks if there is a validator and sets the 400 response:
Would it be good to set
|
done in however, if you want to make app.UseFastEndpoints(config =>
{
config.Errors.UseProblemDetails();
}); |
You're right, Just tried the changes out. It works good so far. Thanks again! 💯 |
Produces 200 is always set. This is a reasonable default; however, how can we handle cases where the endpoint may only return, for example, just a 201? The Swagger doc will output a 200 where that endpoint doesn't return that. Describe() with clearDefaults=true would require you to have to describe everything again, not just the sucessful response(s), and potentially missing other defaults for an endpoint.
Since endpoints are authorized by default, would it be good to add in a default for 401? AnonymousVerbs is empty unless AllowAnonymous is set for any verb. On an aside, I believe there isn't a way yet to set Produces for different verbs, but for now, here's an example:
What are your thoughts?
The text was updated successfully, but these errors were encountered: