.NET/C#中swagger json规范到静态html文件的转换 [英] Conversion of swagger json specification to the static html file in .NET/C#
问题描述
我正在尝试找到将 swagger json 规范转换为静态 html 文件的 .NET/C# 解决方案.我找到了 Java 和 Node.js 的替代方案:https://www.npmjs.com/package/bootprint-swagger(完全按照我们的需要工作,但我们可以在我们的环境中使用 node.js),https://github.com/swagger-api/swagger-codegen#generating-static-html-api-documentation,但对于 .NET 没有
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
可能你们在 .NET 中遇到过或做过类似的事情?提前致谢!
Probably you guys met or did something similar in .NET? Thanks in advance!
推荐答案
如果您有 swagger 规范 (yaml/json),您可以使用在线代码生成器 (https://generator.swagger.io) 而不使用 .NET/C#.下面是一个例子:
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
这是一个示例响应:
{"code":"1445940806041","link":"https://generator.swagger.io/api/gen/download/1445940806041"}
然后您可以从链接下载压缩的 HTML 文档.
You can then download the zipped HTML documentation from the link.
注意:如果您没有 swaggerUrl,也可以使用有效的 swagger JSON 对象(必须是有效的 json!!).只需清空 swaggerUrl 属性并将您的架构添加到规范属性.
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.
这篇关于.NET/C#中swagger json规范到静态html文件的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!