Protobuf: import urls for well known types are undocumented

Created on 3 Jul 2017  路  3Comments  路  Source: protocolbuffers/protobuf

https://developers.google.com/protocol-buffers/docs/reference/google.protobuf lists all the well known types, but the URLs needed to import them into your .proto file are a secret. The only one I can find any reference to is Any, import "google/protobuf/any.proto". Others like Empty or any of the wrappers are undocumented.

documentation enhancement

Most helpful comment

FYI for those who can't seem to find the well known types in the docs. All wrappers (ie. int32Value) are under wrappers.proto.

import "google/protobuf/any.proto";
import "google/protobuf/api.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/source_context.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/type.proto";
import "google/protobuf/wrappers.proto";

Found a sample in a unit test:

https://github.com/google/protobuf/blob/c44ca26fe89ed8a81d3ee475a2ccc1797141dbce/src/google/protobuf/unittest_well_known_types.proto

All 3 comments

FYI for those who can't seem to find the well known types in the docs. All wrappers (ie. int32Value) are under wrappers.proto.

import "google/protobuf/any.proto";
import "google/protobuf/api.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/source_context.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/type.proto";
import "google/protobuf/wrappers.proto";

Found a sample in a unit test:

https://github.com/google/protobuf/blob/c44ca26fe89ed8a81d3ee475a2ccc1797141dbce/src/google/protobuf/unittest_well_known_types.proto

Still not fixed? I'm trying to import ListValue and can't find any reference of the import.

Just ran into the problem @otto-dev

import "google/protobuf/struct.proto";

google.protobuf.ListValue foo = 1;

seems to work

from google.protobuf import struct_pb2
struct_pb2.ListValue().add_list().extend([1,2,3])
Was this page helpful?
0 / 5 - 0 ratings