Reputation: 537
We're trying to generate Swagger 1.2 spec JSON for our .NET Web API. I've tried using Swashbuckle, but it only seems to generate Swagger 2.0 spec JSON.
Does anyone know how to generate Swagger 1.2 JSON from a .NET Web API (using Swashbuckle or not)?
Upvotes: 3
Views: 2453
Reputation: 1
This swagger.json file can be generated as an ouput of the project build, using swagger. In your webApi .csproj file, add this section:
<Target Name="NSwag" AfterTargets="Build">
<Exec Command="$(NSwagExe) webapi2swagger /infotitle:"$(AssemblyName)" /assembly:$(TargetPath) /output:$(OutDir)/$(AssemblyName).swagger.json" />
</Target>
You also need to attribute your API controller methods like this, e.g.: [SwaggerResponse(HttpStatusCode.OK, Type = typeof(object))]
Upvotes: 0
Reputation: 14840
Not really sure why you want to use Swagger 1.2 over Swagger 2.0, but you can still use Swashbuckle, only an older version of it such as https://github.com/domaindrivendev/Swashbuckle/tree/v4.2.0.
Upvotes: 2