You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an complex object with some properties I wish to mark as Deprecated in the Swagger UI.
Using the [Obsolete] attribute on simple properties (int, string, bool, DateTime, etc) works perfectly - the property appears with a line through it in the Schema section of the Swagger UI, and I can include a message in the <summary> XML doc comment that shows up as well.
However, this does not work for referenced complex types - the XML doc commands and attributes from the referenced object are shown instead, and the property is not shown to be deprecated.
Oh, interesting. Based on the previous issue I linked to, above, I had ruled out the use of UseAllOfToExtendReferenceSchemas option. However, when I tried it in my sample project, it did exactly what I needed.
So, adding...
builder.Services.AddSwaggerGen(options =>{varxmlFilename=$"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename)); options.UseAllOfToExtendReferenceSchemas();// This line right here});
produced the following in my Swagger HTML:
That's perfect, actually. Sorry I doubted y'all.
Gonna close this as WAD.
I have an complex object with some properties I wish to mark as Deprecated in the Swagger UI.
Using the
[Obsolete]
attribute on simple properties (int, string, bool, DateTime, etc) works perfectly - the property appears with a line through it in the Schema section of the Swagger UI, and I can include a message in the<summary>
XML doc comment that shows up as well.However, this does not work for referenced complex types - the XML doc commands and attributes from the referenced object are shown instead, and the property is not shown to be deprecated.
Please see the attached simple sample project that reproduces this issue.
Code for the object in question:
Screencap from running the above in Swagger:
The text was updated successfully, but these errors were encountered: