Skip to main content

Class: 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"; } } }; } }

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.


deprecated​

deprecated: boolean

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


description​

description: string

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


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]: $Properties


externalDocs?​

optional externalDocs?: $Properties | null

Additional external documentation for this operation.


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.


parameters?​

optional parameters?: $Properties | null

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.


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.


responses​

responses: object

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

Index Signature​

[k: string]: $Properties


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.


security​

security: $Properties[]

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.


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.


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.

Methods​

toJSON()​

toJSON(): object

Converts this Operation to JSON.

Returns​

object

JSON object


create()​

Call Signature​

static create(properties?): Operation & $Shape

Creates a new Operation instance using the specified properties.

Parameters​
properties?​

$Shape

Properties to set

Returns​

Operation & $Shape

Operation instance

Call Signature​

static create(properties?): Operation

Creates a new Operation instance using the specified properties.

Parameters​
properties?​

$Properties

Properties to set

Returns​

Operation

Operation instance


decode()​

static decode(reader, length?): Operation & $Shape

Decodes an Operation message from the specified reader or buffer.

Parameters​

reader​

Uint8Array<ArrayBufferLike> | Reader

Reader or buffer to decode from

length?​

number

Message length if known beforehand

Returns​

Operation & $Shape

Operation

Throws​

If the payload is not a reader or valid buffer

Throws​

If required fields are missing


decodeDelimited()​

static decodeDelimited(reader): Operation & $Shape

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

Parameters​

reader​

Uint8Array<ArrayBufferLike> | Reader

Reader or buffer to decode from

Returns​

Operation & $Shape

Operation

Throws​

If the payload is not a reader or valid buffer

Throws​

If required fields are missing


encode()​

static encode(message, writer?): Writer

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

Parameters​

message​

$Properties

Operation message or plain object to encode

writer?​

Writer

Writer to encode to

Returns​

Writer

Writer


encodeDelimited()​

static 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​

message​

$Properties

Operation message or plain object to encode

writer?​

Writer

Writer to encode to

Returns​

Writer

Writer


fromObject()​

static fromObject(object): Operation

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

Parameters​

object​

{[k: string]: any; }

Plain object

Returns​

Operation

Operation


toObject()​

static toObject(message, options?): object

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

Parameters​

message​

Operation

Operation

options?​

IConversionOptions

Conversion options

Returns​

object

Plain object