Skip to main content

Class: Schema

protoc_gen_openapiv2.options.Schema

Schema is a representation of OpenAPI v2 specification's Schema object.

See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject

Implements

Constructors

constructor

new Schema(properties?): Schema

Constructs a new Schema.

Parameters

NameTypeDescription
properties?ISchemaProperties to set

Returns

Schema

Properties

discriminator

discriminator: string

Adds support for polymorphism. The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema. The property name used MUST be defined at this schema and it MUST be in the required property list. When used, the value MUST be the name of this schema or any schema that inherits it.

Implementation of

ISchema.discriminator


example

example: string

A free-form property to include an example of an instance for this schema in JSON. This is copied verbatim to the output.

Implementation of

ISchema.example


externalDocs

Optional externalDocs: null | IExternalDocumentation

Additional external documentation for this schema.

Implementation of

ISchema.externalDocs


jsonSchema

Optional jsonSchema: null | IJSONSchema

Schema jsonSchema.

Implementation of

ISchema.jsonSchema


readOnly

readOnly: boolean

Relevant only for Schema "properties" definitions. Declares the property as "read only". This means that it MAY be sent as part of a response but MUST NOT be sent as part of the request. Properties marked as readOnly being true SHOULD NOT be in the required list of the defined schema. Default value is false.

Implementation of

ISchema.readOnly

Methods

toJSON

toJSON(): Object

Converts this Schema to JSON.

Returns

Object

JSON object


create

create(properties?): Schema

Creates a new Schema instance using the specified properties.

Parameters

NameTypeDescription
properties?ISchemaProperties to set

Returns

Schema

Schema instance


decode

decode(reader, length?): Schema

Decodes a Schema message from the specified reader or buffer.

Parameters

NameTypeDescription
readerUint8Array | ReaderReader or buffer to decode from
length?numberMessage length if known beforehand

Returns

Schema

Schema

Throws

If the payload is not a reader or valid buffer

Throws

If required fields are missing


decodeDelimited

decodeDelimited(reader): Schema

Decodes a Schema message from the specified reader or buffer, length delimited.

Parameters

NameTypeDescription
readerUint8Array | ReaderReader or buffer to decode from

Returns

Schema

Schema

Throws

If the payload is not a reader or valid buffer

Throws

If required fields are missing


encode

encode(message, writer?): Writer

Encodes the specified Schema message. Does not implicitly grpc.gateway.protoc_gen_openapiv2.options.Schema.verify|verify messages.

Parameters

NameTypeDescription
messageISchemaSchema message or plain object to encode
writer?WriterWriter to encode to

Returns

Writer

Writer


encodeDelimited

encodeDelimited(message, writer?): Writer

Encodes the specified Schema message, length delimited. Does not implicitly grpc.gateway.protoc_gen_openapiv2.options.Schema.verify|verify messages.

Parameters

NameTypeDescription
messageISchemaSchema message or plain object to encode
writer?WriterWriter to encode to

Returns

Writer

Writer


fromObject

fromObject(object): Schema

Creates a Schema message from a plain object. Also converts values to their respective internal types.

Parameters

NameTypeDescription
objectObjectPlain object

Returns

Schema

Schema


getTypeUrl

getTypeUrl(typeUrlPrefix?): string

Gets the default type url for Schema

Parameters

NameTypeDescription
typeUrlPrefix?stringyour custom typeUrlPrefix(default "type.googleapis.com")

Returns

string

The default type url


toObject

toObject(message, options?): Object

Creates a plain object from a Schema message. Also converts values to other types if specified.

Parameters

NameTypeDescription
messageSchemaSchema
options?IConversionOptionsConversion options

Returns

Object

Plain object