-
Notifications
You must be signed in to change notification settings - Fork 679
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
XML comments from dependent Assemblies #93
Comments
Hey there Unfortunately, this is a use-case that I hadn't considered until yourself (and others) pointed it out. I've always thought of routes/controllers and DTO's as being very closely related (i.e. they "are" the API contract) and have never wanted to separate them into different libraries. Domain logic on the other hand would live in a separate project with mapping in place to convert between DTO's and Domain objects. But I can see now there are many reasons why people might want to do things differently and so believe that Swashbuckle should support this feature. Actually, it's probably not a significant change but the backlog is growing and I'll need to figure out where it sits on the list of priorities. In the meantime though, I have a workaround you could try but I have a sneaking suspicion it may result in some unwanted repercussions. If you look at the code, you'll see that IncludeXmlComments is really just a convenience method that wires up two "filters' - ApplyActionXmlComments and ApplyTypeXmlComments. You could conceivably just wire these up yourself providing a different file path for each. There is a gotcha though, this approach will cause the static config instance to hold onto to a ref for each of these filters which in turn will hold a ref to an XmlDocument. This may cause some memory issues but maybe you can do some trickery to work around it. Might be worth a try ... |
Thanks for the response! I wrote this as a workaround... seems to work. Including in case it helps someone out. Unless you see an issue I may just use this. ///
|
This issue still haunts in 2018. Function to get a of XML doc: Register XML files with help of C# |
It can be a option to add all xml files from bin directory. List<string> xmlFiles = Directory.GetFiles(AppContext.BaseDirectory,"*.xml",SearchOption.TopDirectoryOnly).ToList();
xmlFiles.ForEach(xmlFile => swaggerGenOptions.IncludeXmlComments(xmlFile)); |
Elegant solution. Highly configurable and simple. |
I may be missing something obvious here but I can't seem to figure out how to include XML comment documentation from more than one assembly. I have a web project that produces file a.xml in the app_data directory. I also have a DTO project that contains the objects the web project returns. It produces an xml file, b.xml. I have been able to include one file or the other, and Swashbuckle picks up either set of comments. However, I don't know how to ask it to look at both files at once. Is that supported?
string path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString() + "\a.xml";
SwaggerSpecConfig.Customize(
c => c.IncludeXmlComments(path));
Great project, btw!
The text was updated successfully, but these errors were encountered: