1

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?

JTIM
  • 2,774
  • 1
  • 34
  • 74
  • Do you want to maintain the version like this? https://github.com/RicoSuter/NSwag/issues/945 – Tupac Sep 10 '21 at 09:03
  • @Chaodeng for me that looks like the ideal solution :) specifically https://blog.readme.com/an-example-filled-guide-to-swagger-3-2/ with enum versions, or did you think of something else? But I was not aware of this capability in OAS, and as it doesn't exist right now my idea was more low level. Currently I define a few `documentNames`, so I as developer know the `documentNames` and the versions. However another person cannot know what versions/names exists without seeing the code or exposing swagger UI on the backend. Ideally I wanted to extract this information from dll/csproj if possible? – JTIM Sep 10 '21 at 11:57

0 Answers0