Skip to content

OpenApiDocument

Rico Suter edited this page Jun 6, 2019 · 2 revisions

Package: NSwag.Core

Class to describe an OpenAPI 3.0.0 or Swagger 2.0 specification. Head over to the official OpenAPI 3 specification for more information.

var url = "http://petstore.swagger.io/v2/swagger.json";
var document = await OpenApiDocument.FromUrlAsync(url);

To load a specification from a string use:

var specificationJson = "{ ... }";
var document = await OpenApiDocument.FromJsonAsync(specificationJson);

To convert a document to JSON, call ToJson():

var json = document.ToJson();

See also OpenAPI 3 support.

You can’t perform that action at this time.