问题
I'm trying to find the .NET/C# solution for the conversion of swagger json specification to the static html file. I've found the alternatives for Java and Node.js: https://www.npmjs.com/package/bootprint-swagger (works completely as we need, but we can use node.js in our environment), https://github.com/swagger-api/swagger-codegen#generating-static-html-api-documentation, but nothing for .NET
Probably you guys met or did something similar in .NET? Thanks in advance!
回答1:
If you've the swagger spec (yaml/json), you can generate the static HTML documentation or API clients using the online code generator (https://generator.swagger.io) without using .NET/C#. Here is an example:
curl -X POST -H "content-type:application/json" -d '{"swaggerUrl":"http://petstore.swagger.io/v2/swagger.json"}' https://generator.swagger.io/api/gen/clients/html
and here is a sample response:
{"code":"1445940806041","link":"https://generator.swagger.io/api/gen/download/1445940806041"}
You can then download the zipped HTML documentation from the link.
Note: If you don't have a swaggerUrl, you can use a valid swagger JSON object (must be valid json!!) as well. Just empty the swaggerUrl property and add your schema to the spec property.
来源:https://stackoverflow.com/questions/33395223/conversion-of-swagger-json-specification-to-the-static-html-file-in-net-c