-
Notifications
You must be signed in to change notification settings - Fork 80
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
Deprecate ExamplesOperationFilter #108
Comments
There are several problems with the XML comment based examples, so I hope you don't actually proceed with deprecating this until they are resolved... Among the problems:
public class Reference
{
/// <summary>
/// Id of the referenced item.
/// </summary>
public string Id { get; set; }
/// <summary>
/// Name of the referenced item.
/// </summary>
public string Name { get; set; }
}
public class Widget
{
/// <summary>
/// Container this is inside of.
/// </summary>
public Reference WidgetContainer { get; set; }
/// <summary>
/// Dongles compatible with this Widget.
/// </summary>
public Reference[] CompatibleDongles { get; set; }
} In this model, I don't want the
Maybe I'm missing how to accomplish these things with the XML comments... if so, I would be happy to be mistaken! I'm all for having fewer dependencies as long as I can achieve what I need... |
@mattfrear does this also mean you are considering dropping |
We use it to generate examples which contain values unknown at design time, so the xml comments wouldn't work either. Our examples use dependency injection with the configuration to get values, and we also generate examples in code. |
Thanks @CumpsD those are valid use cases too. I'll leave it for now. |
yes, please leave support for IExamplesProvider |
I use a wrapper for the response so the response always has the same structure (for error and normal responses):
I needed to supply different examples for different status codes, one for status code 200 and two for status code 400. Don't deprecate it please! |
My use case is I generate examples using random data, dynamically at runtime using https://github.com/bchavez/Bogus. So on each page load I get new random data! public class UserExample : IExamplesProvider<User> {
public User GetExamples() =>
new Faker<User>()
.StrictMode(true)
.RuleFor(x => x.Email, x => x.Person.Email)
.RuleFor(x => x.Password, x => x.Internet.Password())
.RuleFor(x => x.Name, x => x.Person.FullName)
.Generate();
} Same thing for response examples. Please don't deprecate! 🙏 |
...like @sabbadino, I'm retrieving the example data from the DB that the API instance is pointing to, where I configure examples via a APISwaggerExample table:
So another "please don't deprecate" from me 🙏 ...unless there is a better way of doing it, of course! |
"Swashbuckle.AspNetCore.Filters" seems to be very scalable/extensible as compared to native XML comments. Dynamic examples can be generated very easily with it. I think this should be left as it is, till such things are not available natively. |
Don't worry folks, I'm not gonna deprecate it any time soon. |
Since May 2018, Swashbuckle.AspNetCore supports adding examples via XML comments:
Unfortunately it doesn't work correctly at the moment - ints are rendered as strings. The bugfix has been implemented but not yet released. domaindrivendev/Swashbuckle.AspNetCore#959
Once that fix gets released, I think I can begin to deprecate my examples filter... which is pretty much this repo's raison d'être.
The text was updated successfully, but these errors were encountered: