Table of Contents

Class OpenApiSchemaGenerator

Namespace
NSwag.Generation
Assembly
NSwag.Generation.dll

A NJsonSchema.Generation.JsonSchemaGenerator which only generate the schema for the root type. Referenced types are added to the service's Definitions collection.

public class OpenApiSchemaGenerator : JsonSchemaGenerator
Inheritance
OpenApiSchemaGenerator

Constructors

OpenApiSchemaGenerator(OpenApiDocumentGeneratorSettings)

Initializes a new instance of the OpenApiSchemaGenerator class.

public OpenApiSchemaGenerator(OpenApiDocumentGeneratorSettings settings)

Parameters

settings OpenApiDocumentGeneratorSettings

The settings.

Methods

GenerateObject(JsonSchema, JsonTypeDescription, JsonSchemaResolver)

Generates the properties for the given type and schema.

protected override void GenerateObject(JsonSchema schema, JsonTypeDescription typeDescription, JsonSchemaResolver schemaResolver)

Parameters

schema JsonSchema

The properties

typeDescription JsonTypeDescription

The type description.

schemaResolver JsonSchemaResolver

The schema resolver.

GenerateWithReferenceAndNullability<TSchemaType>(ContextualType, bool, JsonSchemaResolver, Action<TSchemaType, JsonSchema>)

Generates a schema directly or referenced for the requested schema type; also adds nullability if required.

public override TSchemaType GenerateWithReferenceAndNullability<TSchemaType>(ContextualType contextualType, bool isNullable, JsonSchemaResolver schemaResolver, Action<TSchemaType, JsonSchema> transformation = null) where TSchemaType : JsonSchema, new()

Parameters

contextualType ContextualType

The type of the schema to generate.

isNullable bool

Specifies whether the property, parameter or requested schema type is nullable.

schemaResolver JsonSchemaResolver

The schema resolver.

transformation Action<TSchemaType, JsonSchema>

An action to transform the resulting schema (e.g. property or parameter) before the type of reference is determined (with $ref or allOf/oneOf).

Returns

TSchemaType

The requested schema object.

Type Parameters

TSchemaType

The resulted schema type which may reference the actual schema.