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

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.


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.


externalDocs​

• Optional externalDocs: null | $Properties

Additional external documentation for this schema.


jsonSchema​

• Optional jsonSchema: null | $Properties

Schema 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.

Methods​

toJSON​

▸ toJSON(): Object

Converts this Schema to JSON.

Returns​

Object

JSON object


create​

▸ create(properties?): Schema & $Shape

Creates a new Schema instance using the specified properties.

Parameters​

NameTypeDescription
properties?$ShapeProperties to set

Returns​

Schema & $Shape

Schema instance

▸ create(properties?): Schema

Parameters​

NameType
properties?$Properties

Returns​

Schema


decode​

▸ decode(reader, length?): Schema & $Shape

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 & $Shape

Schema

Throws

If the payload is not a reader or valid buffer

Throws

If required fields are missing


decodeDelimited​

▸ decodeDelimited(reader): Schema & $Shape

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

Parameters​

NameTypeDescription
readerUint8Array | ReaderReader or buffer to decode from

Returns​

Schema & $Shape

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
message$PropertiesSchema 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
message$PropertiesSchema 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


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