Nswag Generate OpenApi Spec

851 Views Asked by At

I have a number of controllers marked with different versioning, and marked with corresponding documentName. This works fine, I can then generate my OAS spec. Using the following and specifying the appropriate documentName

<Target Name="NSwag" AfterTargets="Build">
    <Exec Command="$(NSwagExe_Core31) aspnetcore2openapi /project:$(AssemblyName).csproj /nobuild:true /documentName:v1 /output:OAS_v1.json" />
</Target>

However what would I do in a CI/CD system if I do not know what versions exist for given assembly? Think about a feed of assemblies that I go through to generate OAS files and distribute them to an API Management system.

Therefore is there a way that I can only create the version marked as default? Is there a way for me to know what documentName's exist so I can generate all of them?

Proposed Solution

I have not come up with an elegant idea - other than having an endpoint on the service that exposes the existing versions - and then use that to query the service or assembly to generate OAS files. Somebody have a better idea?

0

There are 0 best solutions below