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

Documentation not being generated for models from NuGet packages #33

Open
jeremyVignelles opened this issue Jan 9, 2020 · 20 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@jeremyVignelles
Copy link
Contributor

I have some models exposed in my APIs that come from NuGetPackages.

While those types are properly documented (I can see the doc in intellisense), they have no documentation in the generated OpenApi spec.

This does not happen on netcoreapp2.1, but does happen on netcoreapp3.1.

To highlight this issue, please see this repro:
3.1 branch :
https://github.com/jeremyVignelles/TestNSwagNetCoreApp/blob/repro/doc-external-models/TestNSwagNetCoreApp/Hello.cs#L42

2.1 branch:
https://github.com/jeremyVignelles/TestNSwagNetCoreApp/blob/repro/doc-external-models-netcoreapp2.1/TestNSwagNetCoreApp/Hello.cs#L42

I used a type from the NSwag NuGet package to highlight the issue.

@RicoSuter
Copy link
Owner

Looks like .net core 3 uses another way to reference dlls in packages so that xml docs files cannot be found.

We need to repro and fix this here:
https://github.com/RicoSuter/Namotion.Reflection

@bpaczkowski
Copy link

@RicoSuter Is there a workaround for that in the meantime? This is pretty painful for us. Too late to go back to .net core 2.x unfortunately.

@RicoSuter RicoSuter transferred this issue from RicoSuter/NSwag Mar 5, 2020
@RicoSuter
Copy link
Owner

Moved to Namotion.Reflection - please repro and fix here.

@RicoSuter RicoSuter added help wanted Extra attention is needed bug Something isn't working labels Mar 5, 2020
@RicoSuter
Copy link
Owner

Related: #23

jeremyVignelles added a commit to jeremyVignelles/TestNamotion that referenced this issue Mar 5, 2020
@jeremyVignelles
Copy link
Contributor Author

Here is a repro for the bug using only Namotion as a NuGet package.
https://github.com/jeremyVignelles/TestNamotion

I don't know why, I didn't manage to get the XML documentation of my Program class...

@RicoSuter
Copy link
Owner

RicoSuter commented Mar 6, 2020

Just added a test and it seems that the XML doc file is not part of the output - only the DLL:

image

(there should be a NJsonSchema.xml)

@RicoSuter
Copy link
Owner

RicoSuter commented Mar 6, 2020

With .NET Core 2.1 the DLL is referenced in the NuGet cache where the XML is available:

image

@RicoSuter
Copy link
Owner

PR: #34

@RicoSuter
Copy link
Owner

Any idea how we can instruct the compiler to not only output NuGet DLLs but also the XML Docs?

/cc @pranavkm sorry to bother you again - is this possible?

@pranavkm
Copy link

pranavkm commented Mar 6, 2020

I'd have thought setting <GenerateDocumentationFile>true</GenerateDocumentationFile> should suffice which your project files have set - https://github.com/RicoSuter/Namotion.Reflection/pull/34/files#diff-a0b803fa5e2b2695ee9b80fe5a60a373R5

@RicoSuter
Copy link
Owner

RicoSuter commented Mar 6, 2020

<GenerateDocumentationFile>true</GenerateDocumentationFile>

Only outputs the xml docs for the project itself but not for the referenced NuGet packages. So this is quite the breaking change in .net core 3.0/3.1 it seems

@pranavkm
Copy link

pranavkm commented Mar 6, 2020

Ahh, are the xml files from package references no longer being copied to the output directory?

@RicoSuter
Copy link
Owner

RicoSuter commented Mar 6, 2020

Ahh, are the xml files from package references no longer being copied to the output directory?

It seems that this is not the case anymore... see my screenshots. The question is whether there is a csproj config where we can enable that again.

@pranavkm
Copy link

pranavkm commented Mar 6, 2020

I'm not entirely sure if this was a change in the 3.x SDK. You might have much better luck asking this question of https://github.com/dotnet/core-sdk/issues.

@danielmeza
Copy link

@bpaczkowski here is a workarround RicoSuter/NSwag#2161 (comment)

@danielmeza
Copy link

Here is other solution, copy the .xml from nuget folder to the build folder
https://snede.net/add-nuget-package-xml-documentation-to-swagger/

@RicoSuter
Copy link
Owner

RicoSuter commented Oct 21, 2020

Ref
dotnet/sdk#1458 (comment)
dotnet/sdk#1458 (comment)

Adding this here works for me (at least in the test project):
dotnet/sdk#1458 (comment)

@RicoSuter
Copy link
Owner

v1.0.20 might be a version where this is improved but might not be fixed in all scenarios.

@RicoSuter
Copy link
Owner

@mediawolf
Copy link

It looks to be a bug in XmlDocsExtensions.GetXmlDocsPathFromNuGetCacheFile which happens on Linux:

                var matches = Regex.Matches(json, $"\"((.*?){assemblyName.Name}((\\\\\\\\)|(////)){assemblyName.Version.ToString(3)})((\\\\\\\\)|(////))(.*?)\"", RegexOptions.IgnoreCase);

It should be a single forward slash - not four because no escaping is needed. Same could be applicable to runtimeConfigRegex
declared in the same file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants