Share via


OpenApiReference Class

Definition

A simple object to allow referencing other components in the specification, internally and externally.

public class OpenApiReference : Microsoft.OpenApi.Interfaces.IOpenApiSerializable
type OpenApiReference = class
    interface IOpenApiSerializable
    interface IOpenApiElement
Public Class OpenApiReference
Implements IOpenApiSerializable
Inheritance
OpenApiReference
Implements

Constructors

OpenApiReference()

Parameterless constructor

OpenApiReference(OpenApiReference)

Initializes a copy instance of the OpenApiReference object

Fields

IsFragrament

Gets a flag indicating whether a file is a valid OpenAPI document or a fragment

Properties

ExternalResource

External resource in the reference. It maybe:

  1. a absolute/relative file path, for example: ../commons/pet.json
  2. a Url, for example: http://localhost/pet.json
HostDocument

The OpenApiDocument that is hosting the OpenApiReference instance. This is used to enable dereferencing the reference.

Id

The identifier of the reusable component of one particular ReferenceType. If ExternalResource is present, this is the path to the component after the '#/'. For example, if the reference is 'example.json#/path/to/component', the Id is 'path/to/component'. If ExternalResource is not present, this is the name of the component without the reference type name. For example, if the reference is '#/components/schemas/componentName', the Id is 'componentName'.

IsExternal

Gets a flag indicating whether this reference is an external reference.

IsLocal

Gets a flag indicating whether this reference is a local reference.

ReferenceV2

Gets the full reference string for V2.0

ReferenceV3

Gets the full reference string for v3.0.

Type

The element type referenced.

Methods

SerializeAsV2(IOpenApiWriter)

Serialize OpenApiReference to Open Api v2.0.

SerializeAsV3(IOpenApiWriter)

Serialize OpenApiReference to Open Api v3.0.

Extension Methods

Validate(IOpenApiElement, ValidationRuleSet)

Validate element and all child elements

Applies to