Conversion of swagger json specification to the static html file in .NET/C#

我怕爱的太早我们不能终老 提交于 2021-01-28 04:21:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!