首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从WSDL/XML以编程方式生成Swagger YAML Open API规范

从WSDL/XML以编程方式生成Swagger YAML Open API规范
EN

Stack Overflow用户
提问于 2018-06-01 07:28:53
回答 2查看 10.1K关注 0票数 7

我已经通过WSDL定义了一个SOAP API。有什么工具可以将WSDL转换为Open API Swagger文档吗?

我假设我需要编写自定义代码来从XML创建Swagger 3.0Open API YAML规范。

XML:

代码语言:javascript
运行
复制
<country>
 <name>ABC</name>
 <population>100</population>
 <political_system>
  <system_type>Democracy</system_type>
  <legislature>bicameral</legislature>
</country>

开放API定义:

代码语言:javascript
运行
复制
openapi: "3.0.0"
info:
  version: 1.0.0
  title: SysCountry  
servers:
  - url: http://localhost:5595/api/
paths:
 /Country:
  get:
   tags:
    -countries
   responses:
    '200':
      description:List of countries
      content:
       application/json:
        schema:
         $ref:"#/components/schemas/Countries
  post:
   summary:Create a country
   tags:
    -Conuntries
   requestBody:
    required: true
    content:
          application/json:
           schema: 
            $ref: '#/components/schemas/Country'
    responses:
        '201':
          description: Null response
components:
  schemas:
    Country:
      type: object
      required:
        - name
      properties:
        name:
          type: string
        population:
          type: integer
        political_system:
          type: object
          properties:
            system_type:
              type: string
            legislature:
              type:string
    Countries:
      type: array
      items:
        $ref: "#/components/schemas/Country"

有没有什么.NET C#库可以用来以编程方式创建YAML文档(可能是类似于XMLDocument的东西)?

EN

回答 2

Stack Overflow用户

发布于 2020-08-13 18:47:21

我知道这是一个古老的问题,但是,我也在寻找同样的东西,但找不到一个像样的、没有麻烦的解决方案,所以也许这个答案也可以帮助其他人。

我找到的将WSDL转换为YAML的最简单方法是使用APIMATIC (www.apimatic.io)。一个免费的帐户可以转换任意数量的WSDL(或其他格式),不需要订阅。

干杯。

票数 4
EN

Stack Overflow用户

发布于 2018-06-01 15:06:46

有一个YamlDotNet - https://github.com/aaubry/YamlDotNet,您可以创建一个YamlStream + YamlDocument并从那里构建您的文档,类似于使用XmlDocument。另一种方法是创建类来表示swagger文档,并使用序列化API生成文档,这与使用XmlSerializer类似。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50634174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档