我已经通过WSDL定义了一个SOAP API。有什么工具可以将WSDL转换为Open API Swagger文档吗?
我假设我需要编写自定义代码来从XML创建Swagger 3.0Open API YAML规范。
XML:
<country>
<name>ABC</name>
<population>100</population>
<political_system>
<system_type>Democracy</system_type>
<legislature>bicameral</legislature>
</country>
开放API定义:
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的东西)?
发布于 2020-08-13 18:47:21
我知道这是一个古老的问题,但是,我也在寻找同样的东西,但找不到一个像样的、没有麻烦的解决方案,所以也许这个答案也可以帮助其他人。
我找到的将WSDL转换为YAML的最简单方法是使用APIMATIC (www.apimatic.io)。一个免费的帐户可以转换任意数量的WSDL(或其他格式),不需要订阅。
干杯。
发布于 2018-06-01 15:06:46
有一个YamlDotNet - https://github.com/aaubry/YamlDotNet,您可以创建一个YamlStream + YamlDocument并从那里构建您的文档,类似于使用XmlDocument。另一种方法是创建类来表示swagger文档,并使用序列化API生成文档,这与使用XmlSerializer类似。
https://stackoverflow.com/questions/50634174
复制相似问题