Protocol Documentation

Table of Contents

Top

protoc-gen-openapiv2/options/annotations.proto

File-level Extensions

Extension Type Base Number Description
openapiv2_enum EnumSchema .google.protobuf.EnumOptions 1042

ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project.

All IDs are the same, as assigned. It is okay that they are the same, as they extend different descriptor messages.

openapiv2_field JSONSchema .google.protobuf.FieldOptions 1042

ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project.

All IDs are the same, as assigned. It is okay that they are the same, as they extend different descriptor messages.

openapiv2_swagger Swagger .google.protobuf.FileOptions 1042

ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project.

All IDs are the same, as assigned. It is okay that they are the same, as they extend different descriptor messages.

openapiv2_schema Schema .google.protobuf.MessageOptions 1042

ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project.

All IDs are the same, as assigned. It is okay that they are the same, as they extend different descriptor messages.

openapiv2_operation Operation .google.protobuf.MethodOptions 1042

ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project.

All IDs are the same, as assigned. It is okay that they are the same, as they extend different descriptor messages.

openapiv2_tag Tag .google.protobuf.ServiceOptions 1042

ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project.

All IDs are the same, as assigned. It is okay that they are the same, as they extend different descriptor messages.

Top

protoc-gen-openapiv2/options/openapiv2.proto

Contact

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

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

Example:

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { info: { … contact: { name: "gRPC-Gateway project"; url: "https://github.com/grpc-ecosystem/grpc-gateway"; email: "none@example.com"; }; … }; … };

Field Type Label Description
name string   The identifying name of the contact person/organization.
url string   The URL pointing to the contact information. MUST be in the format of a URL.
email string   The email address of the contact person/organization. MUST be in the format of an email address.

EnumSchema

EnumSchema is subset of fields from the OpenAPI v2 specification's Schema object. Only fields that are applicable to Enums are included See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject

Example:

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum) = { … title: "MyEnum"; description:"This is my nice enum"; example: "ZERO"; required: true; … };

Field Type Label Description
description string   A short description of the schema.
default string    
title string   The title of the schema.
required bool    
read_only bool    
external_docs ExternalDocumentation   Additional external documentation for this schema.
example string    
ref string   Ref is used to define an external reference to include in the message. This could be a fully qualified proto message reference, and that type must be imported into the protofile. If no message is identified, the Ref will be used verbatim in the output. For example: ref: ".google.protobuf.Timestamp".
extensions EnumSchema.ExtensionsEntry repeated 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/

EnumSchema.ExtensionsEntry

Field Type Label Description
key string    
value google.protobuf.Value    

ExternalDocumentation

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

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

Example:

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { … external_docs: { description: "More about gRPC-Gateway"; url: "https://github.com/grpc-ecosystem/grpc-gateway"; } … };

Field Type Label Description
description string   A short description of the target documentation. GFM syntax can be used for rich text representation.
url string   The URL for the target documentation. Value MUST be in the format of a URL.

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

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

Field Type Label Description
description string   Description is a short description of the header.
type string   The type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported.
format string   Format The extending format for the previously mentioned type.
default string   Default Declares the value of the header that the server will use if none is provided. See: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. Unlike JSON Schema this value MUST conform to the defined type for the header.
pattern string   'Pattern' See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3.

HeaderParameter

HeaderParameter a HTTP header parameter. See: https://swagger.io/specification/v2/#parameter-object

Field Type Label Description
name string   Name is the header name.
description string   Description is a short description of the header.
type HeaderParameter.Type   Type is the type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. See: https://swagger.io/specification/v2/#parameterType.
format string   Format The extending format for the previously mentioned type.
required bool   Required indicates if the header is optional

Info

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

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

Example:

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { info: { title: "Echo API"; version: "1.0"; description: ""; contact: { name: "gRPC-Gateway project"; url: "https://github.com/grpc-ecosystem/grpc-gateway"; email: "none@example.com"; }; license: { name: "BSD 3-Clause License"; url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; }; }; … };

Field Type Label Description
title string   The title of the application.
description string   A short description of the application. GFM syntax can be used for rich text representation.
terms_of_service string   The Terms of Service for the API.
contact Contact   The contact information for the exposed API.
license License   The license information for the exposed API.
version string   Provides the version of the application API (not to be confused with the specification version).
extensions Info.ExtensionsEntry repeated 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/

Info.ExtensionsEntry

Field Type Label Description
key string    
value google.protobuf.Value    

JSONSchema

JSONSchema represents properties from JSON Schema taken, and as used, in the OpenAPI v2 spec.

This includes changes made by OpenAPI v2.

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

See also: https://cswr.github.io/JsonSchema/spec/basic_types/, https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json

Example:

message SimpleMessage { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { json_schema: { title: "SimpleMessage" description: "A simple message." required: ["id"] } };

// Id represents the message identifier. string id = 1; [ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "The unique identifier of the simple message." }]; }

Field Type Label Description
ref string   Ref is used to define an external reference to include in the message. This could be a fully qualified proto message reference, and that type must be imported into the protofile. If no message is identified, the Ref will be used verbatim in the output. For example: ref: ".google.protobuf.Timestamp".
title string   The title of the schema.
description string   A short description of the schema.
default string    
read_only bool    
example string   A free-form property to include a JSON example of this field. This is copied verbatim to the output swagger.json. Quotes must be escaped. This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
multiple_of double    
maximum double   Maximum represents an inclusive upper limit for a numeric instance. The value of MUST be a number,
exclusive_maximum bool    
minimum double   minimum represents an inclusive lower limit for a numeric instance. The value of MUST be a number,
exclusive_minimum bool    
max_length uint64    
min_length uint64    
pattern string    
max_items uint64    
min_items uint64    
unique_items bool    
max_properties uint64    
min_properties uint64    
required string repeated  
array string repeated Items in 'array' must be unique.
type JSONSchema.JSONSchemaSimpleTypes repeated  
format string   Format
enum string repeated Items in enum must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1
field_configuration JSONSchema.FieldConfiguration   Additional field level properties used when generating the OpenAPI v2 file.
extensions JSONSchema.ExtensionsEntry repeated 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/

JSONSchema.ExtensionsEntry

Field Type Label Description
key string    
value google.protobuf.Value    

JSONSchema.FieldConfiguration

'FieldConfiguration' provides additional field level properties used when generating the OpenAPI v2 file. These properties are not defined by OpenAPIv2, but they are used to control the generation.

Field Type Label Description
path_param_name string   Alternative parameter name when used as path parameter. If set, this will be used as the complete parameter name when this field is used as a path parameter. Use this to avoid having auto generated path parameter names for overlapping paths.

License

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

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

Example:

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { info: { … license: { name: "BSD 3-Clause License"; url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; }; … }; … };

Field Type Label Description
name string   The license name used for the API.
url string   A URL to the license used for the API. MUST be in the format of a URL.

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";
     }
   }
 };    }  }
Field Type Label Description
tags string repeated A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.
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.
description string   A verbose explanation of the operation behavior. GFM syntax can be used for rich text representation.
external_docs ExternalDocumentation   Additional external documentation for this operation.
operation_id 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.
consumes string repeated 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.
produces string repeated 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 Operation.ResponsesEntry repeated The list of possible responses as they are returned from executing this operation.
schemes Scheme repeated The transfer protocol for the operation. Values MUST be from the list: "http", "https", "ws", "wss". The value overrides the OpenAPI Object schemes definition.
deprecated bool   Declares this operation to be deprecated. Usage of the declared operation should be refrained. Default value is false.
security SecurityRequirement repeated 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.
extensions Operation.ExtensionsEntry repeated 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/
parameters Parameters   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.

Operation.ExtensionsEntry

Field Type Label Description
key string    
value google.protobuf.Value    

Operation.ResponsesEntry

Field Type Label Description
key string    
value Response    

Parameters

Parameters is a representation of OpenAPI v2 specification's parameters object. Note: This technically breaks compatibility with the OpenAPI 2 definition structure as we only allow header parameters to be set here since we do not want users specifying custom non-header parameters beyond those inferred from the Protobuf schema. See: https://swagger.io/specification/v2/#parameter-object

Field Type Label Description
headers HeaderParameter repeated Headers is one or more HTTP header parameter. See: https://swagger.io/docs/specification/2-0/describing-parameters/#header-parameters

Response

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

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

Field Type Label Description
description string   Description is a short description of the response. GFM syntax can be used for rich text representation.
schema Schema   Schema optionally defines the structure of the response. If Schema is not provided, it means there is no content to the response.
headers Response.HeadersEntry repeated Headers A list of headers that are sent with the response. Header name is expected to be a string in the canonical format of the MIME header key See: https://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey
examples Response.ExamplesEntry repeated Examples gives per-mimetype response examples. See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#example-object
extensions Response.ExtensionsEntry repeated 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/

Response.ExamplesEntry

Field Type Label Description
key string    
value string    

Response.ExtensionsEntry

Field Type Label Description
key string    
value google.protobuf.Value    

Response.HeadersEntry

Field Type Label Description
key string    
value Header    

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

Field Type Label Description
json_schema JSONSchema    
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.
read_only bool   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.
external_docs ExternalDocumentation   Additional external documentation for this schema.
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.

Scopes

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

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

Lists the available scopes for an OAuth2 security scheme.

Field Type Label Description
scope Scopes.ScopeEntry repeated Maps between a name of a scope to a short description of it (as the value of the property).

Scopes.ScopeEntry

Field Type Label Description
key string    
value string    

SecurityDefinitions

SecurityDefinitions is a representation of OpenAPI v2 specification's Security Definitions object.

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

A declaration of the security schemes available to be used in the specification. This does not enforce the security schemes on the operations and only serves to provide the relevant details for each scheme.

Field Type Label Description
security SecurityDefinitions.SecurityEntry repeated A single security scheme definition, mapping a "name" to the scheme it defines.

SecurityDefinitions.SecurityEntry

Field Type Label Description
key string    
value SecurityScheme    

SecurityRequirement

SecurityRequirement is a representation of OpenAPI v2 specification's Security Requirement object.

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

Lists the required security schemes to execute this operation. The object can have multiple security schemes declared in it which are all required (that is, there is a logical AND between the schemes).

The name used for each property MUST correspond to a security scheme declared in the Security Definitions.

Field Type Label Description
security_requirement SecurityRequirement.SecurityRequirementEntry repeated Each name must correspond to a security scheme which is declared in the Security Definitions. If the security scheme is of type "oauth2", then the value is a list of scope names required for the execution. For other security scheme types, the array MUST be empty.

SecurityRequirement.SecurityRequirementEntry

Field Type Label Description
key string    
value SecurityRequirement.SecurityRequirementValue    

SecurityRequirement.SecurityRequirementValue

If the security scheme is of type "oauth2", then the value is a list of scope names required for the execution. For other security scheme types, the array MUST be empty.

Field Type Label Description
scope string repeated  

SecurityScheme

SecurityScheme is a representation of OpenAPI v2 specification's Security Scheme object.

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

Allows the definition of a security scheme that can be used by the operations. Supported schemes are basic authentication, an API key (either as a header or as a query parameter) and OAuth2's common flows (implicit, password, application and access code).

Field Type Label Description
type SecurityScheme.Type   The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
description string   A short description for security scheme.
name string   The name of the header or query parameter to be used. Valid for apiKey.
in SecurityScheme.In   The location of the API key. Valid values are "query" or "header". Valid for apiKey.
flow SecurityScheme.Flow   The flow used by the OAuth2 security scheme. Valid values are "implicit", "password", "application" or "accessCode". Valid for oauth2.
authorization_url string   The authorization URL to be used for this flow. This SHOULD be in the form of a URL. Valid for oauth2/implicit and oauth2/accessCode.
token_url string   The token URL to be used for this flow. This SHOULD be in the form of a URL. Valid for oauth2/password, oauth2/application and oauth2/accessCode.
scopes Scopes   The available scopes for the OAuth2 security scheme. Valid for oauth2.
extensions SecurityScheme.ExtensionsEntry repeated 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/

SecurityScheme.ExtensionsEntry

Field Type Label Description
key string    
value google.protobuf.Value    

Swagger

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

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

Example:

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { info: { title: "Echo API"; version: "1.0"; description: ""; contact: { name: "gRPC-Gateway project"; url: "https://github.com/grpc-ecosystem/grpc-gateway"; email: "none@example.com"; }; license: { name: "BSD 3-Clause License"; url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; }; }; schemes: HTTPS; consumes: "application/json"; produces: "application/json"; };

Field Type Label Description
swagger string   Specifies the OpenAPI Specification version being used. It can be used by the OpenAPI UI and other clients to interpret the API listing. The value MUST be "2.0".
info Info   Provides metadata about the API. The metadata can be used by the clients if needed.
host string   The host (name or ip) serving the API. This MUST be the host only and does not include the scheme nor sub-paths. It MAY include a port. If the host is not included, the host serving the documentation is to be used (including the port). The host does not support path templating.
base_path string   The base path on which the API is served, which is relative to the host. If it is not included, the API is served directly under the host. The value MUST start with a leading slash (/). The basePath does not support path templating. Note that using base_path does not change the endpoint paths that are generated in the resulting OpenAPI file. If you wish to use base_path with relatively generated OpenAPI paths, the base_path prefix must be manually removed from your google.api.http paths and your code changed to serve the API from the base_path.
schemes Scheme repeated The transfer protocol of the API. Values MUST be from the list: "http", "https", "ws", "wss". If the schemes is not included, the default scheme to be used is the one used to access the OpenAPI definition itself.
consumes string repeated A list of MIME types the APIs can consume. This is global to all APIs but can be overridden on specific API calls. Value MUST be as described under Mime Types.
produces string repeated A list of MIME types the APIs can produce. This is global to all APIs but can be overridden on specific API calls. Value MUST be as described under Mime Types.
responses Swagger.ResponsesEntry repeated An object to hold responses that can be used across operations. This property does not define global responses for all operations.
security_definitions SecurityDefinitions   Security scheme definitions that can be used across the specification.
security SecurityRequirement repeated A declaration of which security schemes are applied for the API as a whole. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). Individual operations can override this definition.
tags Tag repeated A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.
external_docs ExternalDocumentation   Additional external documentation.
extensions Swagger.ExtensionsEntry repeated 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/

Swagger.ExtensionsEntry

Field Type Label Description
key string    
value google.protobuf.Value    

Swagger.ResponsesEntry

Field Type Label Description
key string    
value Response    

Tag

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

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

Field Type Label Description
name string   The name of the tag. Use it to allow override of the name of a global Tag object, then use that name to reference the tag throughout the OpenAPI file.
description string   A short description for the tag. GFM syntax can be used for rich text representation.
external_docs ExternalDocumentation   Additional external documentation for this tag.
extensions Tag.ExtensionsEntry repeated 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/

Tag.ExtensionsEntry

Field Type Label Description
key string    
value google.protobuf.Value    

HeaderParameter.Type

Type is a supported HTTP header type. See https://swagger.io/specification/v2/#parameterType.

Name Number Description
UNKNOWN 0  
STRING 1  
NUMBER 2  
INTEGER 3  
BOOLEAN 4  

JSONSchema.JSONSchemaSimpleTypes

Name Number Description
UNKNOWN 0  
ARRAY 1  
BOOLEAN 2  
INTEGER 3  
NULL 4  
NUMBER 5  
OBJECT 6  
STRING 7  

Scheme

Scheme describes the schemes supported by the OpenAPI Swagger and Operation objects.

Name Number Description
UNKNOWN 0  
HTTP 1  
HTTPS 2  
WS 3  
WSS 4  

SecurityScheme.Flow

The flow used by the OAuth2 security scheme. Valid values are "implicit", "password", "application" or "accessCode".

Name Number Description
FLOW_INVALID 0  
FLOW_IMPLICIT 1  
FLOW_PASSWORD 2  
FLOW_APPLICATION 3  
FLOW_ACCESS_CODE 4  

SecurityScheme.In

The location of the API key. Valid values are "query" or "header".

Name Number Description
IN_INVALID 0  
IN_QUERY 1  
IN_HEADER 2  

SecurityScheme.Type

The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".

Name Number Description
TYPE_INVALID 0  
TYPE_BASIC 1  
TYPE_API_KEY 2  
TYPE_OAUTH2 3  

Scalar Value Types

.proto Type Notes C++ Java Python Go C# PHP Ruby
double   double double float float64 double float Float
float   float float float float32 float float Float
int32 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. int32 int int int32 int integer Bignum or Fixnum (as required)
int64 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. int64 long int/long int64 long integer/string Bignum
uint32 Uses variable-length encoding. uint32 int int/long uint32 uint integer Bignum or Fixnum (as required)
uint64 Uses variable-length encoding. uint64 long int/long uint64 ulong integer/string Bignum or Fixnum (as required)
sint32 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. int32 int int int32 int integer Bignum or Fixnum (as required)
sint64 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. int64 long int/long int64 long integer/string Bignum
fixed32 Always four bytes. More efficient than uint32 if values are often greater than 2^28. uint32 int int uint32 uint integer Bignum or Fixnum (as required)
fixed64 Always eight bytes. More efficient than uint64 if values are often greater than 2^56. uint64 long int/long uint64 ulong integer/string Bignum
sfixed32 Always four bytes. int32 int int int32 int integer Bignum or Fixnum (as required)
sfixed64 Always eight bytes. int64 long int/long int64 long integer/string Bignum
bool   bool boolean boolean bool bool boolean TrueClass/FalseClass
string A string must always contain UTF-8 encoded or 7-bit ASCII text. string String str/unicode string string string String (UTF-8)
bytes May contain any arbitrary sequence of bytes. string ByteString str []byte ByteString string String (ASCII-8BIT)

Back to top

Copyright © 2025 HotelEngine, Inc., d/b/a Engine
Documentation generated: August 06, 2025
Version: 2.0.0-pre.5