azure-functions-extensions-swashbuckle icon indicating copy to clipboard operation
azure-functions-extensions-swashbuckle copied to clipboard

Allow multiple xml files

Open LockTar opened this issue 5 years ago • 1 comments

Allow multiple xml files. You use this when you have in example your models in a separate class library.

I updated your test project for clarity.

You need to make sure that the xml file of the class library comes in the output directory. You can do this with:

<ItemGroup>
  <None Update="TestModels.xml">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </None>
</ItemGroup>

Fill the list of xml files in host.json as follow:

"extensions": {
  "Swashbuckle": {
    "XmlPaths": [ "TestFunction.xml", "TestModels.xml" ]
  }
}

Also fixes the xml comments in Azure. The xml comment weren't visible because the xml couldn't be found. Extended the SwashBuckleStartupConfig class with the AppDirectory property. This property is filled from the Startup.cs. You can fill this with:

var executioncontextoptions = builder.Services.BuildServiceProvider()
    .GetService<IOptions<ExecutionContextOptions>>().Value;

var currentDirectory = executioncontextoptions.AppDirectory;

//Register the extension
builder.AddSwashBuckle(Assembly.GetExecutingAssembly(), currentDirectory);

In Azure this is the correct path and on you local dev machine as well. See this StackOverflow post for more information about ExecutionContextOptions.

LockTar avatar Oct 28 '19 14:10 LockTar

@yuka1984 can you accept this pr?

LockTar avatar Dec 14 '19 08:12 LockTar