I have a SOAP API already defined via WSDLs. Is there any tool that I can use to convert WSDL to Open API Swagger documents?
I am assuming that I would need to write custom code to to create a Swagger 3.0 Open API YAML specification from an XML.
XML:
<country>
<name>ABC</name>
<population>100</population>
<political_system>
<system_type>Democracy</system_type>
<legislature>bicameral</legislature>
</country>
Open API Definition:
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"
Is there any .NET C# library that can be used to create YAML documents programmatically (maybe something similar to an XMLDocument)?
There's YamlDotNet - https://github.com/aaubry/YamlDotNet You can create a YamlStream + YamlDocument and build your document from there, similar to using XmlDocument. Another approach is to create classes to represent the swagger document and use the serialization API to generate the document, similar to using XmlSerializer.