Skip to main content

Class: Operation

protoc_gen_openapiv2.options.Operation

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

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

Example:

service EchoService { rpc Echo(SimpleMessage) returns (SimpleMessage) { option (google.api.http) = { get: "/v1/example/echo/{id}" };

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "Get a message."; operation_id: "getMessage"; tags: "echo"; responses: { key: "200" value: { description: "OK"; } } }; } }

Implements

Constructors

constructor

new Operation(properties?): Operation

Constructs a new Operation.

Parameters

NameTypeDescription
properties?IOperationProperties to set

Returns

Operation

Properties

consumes

consumes: string[]

A list of MIME types the operation can consume. This overrides the consumes definition at the OpenAPI Object. An empty value MAY be used to clear the global definition. Value MUST be as described under Mime Types.

Implementation of

IOperation.consumes


deprecated

deprecated: boolean

Declares this operation to be deprecated. Usage of the declared operation should be refrained. Default value is false.

Implementation of

IOperation.deprecated


description

description: string

A verbose explanation of the operation behavior. GFM syntax can be used for rich text representation.

Implementation of

IOperation.description


extensions

extensions: Object

Custom properties that start with "x-" such as "x-foo" used to describe extra functionality that is not covered by the standard OpenAPI Specification. See: https://swagger.io/docs/specification/2-0/swagger-extensions/

Index signature

▪ [k: string]: IValue

Implementation of

IOperation.extensions


externalDocs

Optional externalDocs: null | IExternalDocumentation

Additional external documentation for this operation.

Implementation of

IOperation.externalDocs


operationId

operationId: string

Unique string used to identify the operation. The id MUST be unique among all operations described in the API. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is recommended to follow common programming naming conventions.

Implementation of

IOperation.operationId


parameters

Optional parameters: null | IParameters

Custom parameters such as HTTP request headers. See: https://swagger.io/docs/specification/2-0/describing-parameters/ and https://swagger.io/specification/v2/#parameter-object.

Implementation of

IOperation.parameters


produces

produces: string[]

A list of MIME types the operation can produce. This overrides the produces definition at the OpenAPI Object. An empty value MAY be used to clear the global definition. Value MUST be as described under Mime Types.

Implementation of

IOperation.produces


responses

responses: Object

The list of possible responses as they are returned from executing this operation.

Index signature

▪ [k: string]: IResponse

Implementation of

IOperation.responses


schemes

schemes: Scheme[]

The transfer protocol for the operation. Values MUST be from the list: "http", "https", "ws", "wss". The value overrides the OpenAPI Object schemes definition.

Implementation of

IOperation.schemes


security

security: ISecurityRequirement[]

A declaration of which security schemes are applied for this operation. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). This definition overrides any declared top-level security. To remove a top-level security declaration, an empty array can be used.

Implementation of

IOperation.security


summary

summary: string

A short summary of what the operation does. For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.

Implementation of

IOperation.summary


tags

tags: string[]

A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.

Implementation of

IOperation.tags

Methods

toJSON

toJSON(): Object

Converts this Operation to JSON.

Returns

Object

JSON object


create

create(properties?): Operation

Creates a new Operation instance using the specified properties.

Parameters

NameTypeDescription
properties?IOperationProperties to set

Returns

Operation

Operation instance


decode

decode(reader, length?): Operation

Decodes an Operation message from the specified reader or buffer.

Parameters

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

Returns

Operation

Operation

Throws

If the payload is not a reader or valid buffer

Throws

If required fields are missing


decodeDelimited

decodeDelimited(reader): Operation

Decodes an Operation message from the specified reader or buffer, length delimited.

Parameters

NameTypeDescription
readerUint8Array | ReaderReader or buffer to decode from

Returns

Operation

Operation

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 Operation message. Does not implicitly grpc.gateway.protoc_gen_openapiv2.options.Operation.verify|verify messages.

Parameters

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

Returns

Writer

Writer


encodeDelimited

encodeDelimited(message, writer?): Writer

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

Parameters

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

Returns

Writer

Writer


fromObject

fromObject(object): Operation

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

Parameters

NameTypeDescription
objectObjectPlain object

Returns

Operation

Operation


getTypeUrl

getTypeUrl(typeUrlPrefix?): string

Gets the default type url for Operation

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 an Operation message. Also converts values to other types if specified.

Parameters

NameTypeDescription
messageOperationOperation
options?IConversionOptionsConversion options

Returns

Object

Plain object