OpenApiDocument Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Describes an OpenAPI object (OpenAPI document). See: https://spec.openapis.org
public class OpenApiDocument : Microsoft.OpenApi.IMetadataContainer, Microsoft.OpenApi.IOpenApiExtensible, Microsoft.OpenApi.IOpenApiSerializable
type OpenApiDocument = class
interface IOpenApiSerializable
interface IOpenApiElement
interface IOpenApiExtensible
interface IMetadataContainer
Public Class OpenApiDocument
Implements IMetadataContainer, IOpenApiExtensible, IOpenApiSerializable
- Inheritance
-
OpenApiDocument
- Implements
Constructors
| Name | Description |
|---|---|
| OpenApiDocument() |
Parameter-less constructor |
| OpenApiDocument(OpenApiDocument) |
Initializes a copy of an an OpenApiDocument object |
Properties
| Name | Description |
|---|---|
| BaseUri |
Absolute location of the document or a generated placeholder if location is not given |
| Components |
An element to hold various schemas for the specification. |
| Extensions |
This object MAY be extended with Specification Extensions. |
| ExternalDocs |
Additional external documentation. |
| Info |
REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required. |
| JsonSchemaDialect |
The default value for the $schema keyword within Schema Objects contained within this OAS document. This MUST be in the form of a URI. |
| Metadata |
A collection of properties associated with the current OpenAPI element to be used by the application. Metadata are NOT (de)serialized with the schema and can be used for custom properties. |
| Paths |
REQUIRED. The available paths and operations for the API. |
| Security |
A declaration of which security mechanisms can be used across the API. |
| Self |
The URI identifying this document. This MUST be in the form of a URI. (OAI 3.2.0+) |
| Servers |
An array of Server Objects, which provide connectivity information to a target server. |
| Tags |
A list of tags used by the specification with additional metadata. |
| Webhooks |
The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. A map of requests initiated other than by an API call, for example by an out of band registration. The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses |
| Workspace |
Related workspace containing components that are referenced in a document |
Methods
| Name | Description |
|---|---|
| AddComponent<T>(String, T) |
Adds a component to the components object of the current document and registers it to the underlying workspace. |
| GetHashCodeAsync(CancellationToken) |
Takes in an OpenApi document instance and generates its hash value |
| Load(MemoryStream, String, OpenApiReaderSettings) |
Reads the stream input and parses it into an Open API document. |
| LoadAsync(Stream, String, OpenApiReaderSettings, CancellationToken) |
Reads the stream input and parses it into an Open API document. |
| LoadAsync(String, OpenApiReaderSettings, CancellationToken) |
Parses a local file path or Url into an Open API document. |
| Parse(String, String, OpenApiReaderSettings) |
Parses a string into a OpenApiDocument object. |
| RegisterComponents() |
Register components in the document to the workspace |
| SerializeAs(OpenApiSpecVersion, IOpenApiWriter) |
Serialize OpenApiDocument to an Open API document using the specified version. |
| SerializeAsV2(IOpenApiWriter) |
Serialize OpenApiDocument to OpenAPI object V2.0. |
| SerializeAsV3(IOpenApiWriter) |
Serialize OpenApiDocument to the latest patch of OpenAPI object V3.0. |
| SerializeAsV31(IOpenApiWriter) |
Serialize OpenApiDocument to Open API v3.1 document. |
| SerializeAsV32(IOpenApiWriter) |
Serialize OpenApiDocument to Open API v3.2 document. |
| SetReferenceHostDocument() |
Walks the OpenApiDocument and sets the host document for all IOpenApiReferenceable objects |
Extension Methods
| Name | Description |
|---|---|
| Validate(IOpenApiElement, ValidationRuleSet) |
Validate element and all child elements |