xref: /aosp_15_r20/system/extras/libjsonpb/verify/test.proto (revision 288bf5226967eb3dac5cce6c939ccc2a7f2b4fe5)
1*288bf522SAndroid Build Coastguard Worker/*
2*288bf522SAndroid Build Coastguard Worker * Copyright (C) 2019 The Android Open Source Project
3*288bf522SAndroid Build Coastguard Worker *
4*288bf522SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*288bf522SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*288bf522SAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*288bf522SAndroid Build Coastguard Worker *
8*288bf522SAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*288bf522SAndroid Build Coastguard Worker *
10*288bf522SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*288bf522SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*288bf522SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*288bf522SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*288bf522SAndroid Build Coastguard Worker * limitations under the License.
15*288bf522SAndroid Build Coastguard Worker */
16*288bf522SAndroid Build Coastguard Worker
17*288bf522SAndroid Build Coastguard Workersyntax = "proto3";
18*288bf522SAndroid Build Coastguard Worker
19*288bf522SAndroid Build Coastguard Workerpackage android.jsonpb;
20*288bf522SAndroid Build Coastguard Worker
21*288bf522SAndroid Build Coastguard Worker// Note: this file explicitly uses names that does NOT follow the Protobuf Style
22*288bf522SAndroid Build Coastguard Worker// Guide for testing purposes. When writing a .proto file as a JSON schema, you
23*288bf522SAndroid Build Coastguard Worker// should:
24*288bf522SAndroid Build Coastguard Worker// - Follow the Protobuf Style Guide for field names / enum value names
25*288bf522SAndroid Build Coastguard Worker// - If the JSON file is going to have field names that does not conform to the
26*288bf522SAndroid Build Coastguard Worker//   Protobuf Style Guide (a.k.a lower_snake_case), use json_name option to
27*288bf522SAndroid Build Coastguard Worker//   indicate an alternative name.
28*288bf522SAndroid Build Coastguard Worker// - If the JSON file is going to have enum value names that does not conform to
29*288bf522SAndroid Build Coastguard Worker//   the Protobuf Style Guide (a.k.a CAPITALIZED_SNAKE_CASE), use strings.
30*288bf522SAndroid Build Coastguard Worker
31*288bf522SAndroid Build Coastguard Workermessage WithJsonName {
32*288bf522SAndroid Build Coastguard Worker  string foo_bar = 1 [json_name = "FOOBAR"];
33*288bf522SAndroid Build Coastguard Worker  string barBaz = 2 [json_name = "BarBaz"];
34*288bf522SAndroid Build Coastguard Worker  string BazQux = 3 [json_name = "baz_qux"];
35*288bf522SAndroid Build Coastguard Worker  string QUX_QUUX = 4 [json_name = "quxQuux"];
36*288bf522SAndroid Build Coastguard Worker}
37*288bf522SAndroid Build Coastguard Worker
38*288bf522SAndroid Build Coastguard Workermessage NoJsonName {
39*288bf522SAndroid Build Coastguard Worker  string foo_bar = 1;
40*288bf522SAndroid Build Coastguard Worker  string barBaz = 2;
41*288bf522SAndroid Build Coastguard Worker  string BazQux = 3;
42*288bf522SAndroid Build Coastguard Worker  string QUX_QUUX = 4;
43*288bf522SAndroid Build Coastguard Worker}
44*288bf522SAndroid Build Coastguard Worker
45*288bf522SAndroid Build Coastguard Workermessage Parent {
46*288bf522SAndroid Build Coastguard Worker  repeated WithJsonName repeated_with_json_name = 1;
47*288bf522SAndroid Build Coastguard Worker  WithJsonName with_json_name = 2;
48*288bf522SAndroid Build Coastguard Worker  repeated NoJsonName repeated_no_json_name = 3;
49*288bf522SAndroid Build Coastguard Worker  NoJsonName no_json_name = 4;
50*288bf522SAndroid Build Coastguard Worker}
51*288bf522SAndroid Build Coastguard Worker
52*288bf522SAndroid Build Coastguard Workermessage Scalar {
53*288bf522SAndroid Build Coastguard Worker  int32 i32 = 1;
54*288bf522SAndroid Build Coastguard Worker  sint32 si32 = 2;
55*288bf522SAndroid Build Coastguard Worker  int64 i64 = 3;
56*288bf522SAndroid Build Coastguard Worker  sint64 si64 = 4;
57*288bf522SAndroid Build Coastguard Worker  float f = 5;
58*288bf522SAndroid Build Coastguard Worker  double d = 6;
59*288bf522SAndroid Build Coastguard Worker
60*288bf522SAndroid Build Coastguard Worker  enum Enum {
61*288bf522SAndroid Build Coastguard Worker    DEFAULT = 0;
62*288bf522SAndroid Build Coastguard Worker    FOO = 1;
63*288bf522SAndroid Build Coastguard Worker  }
64*288bf522SAndroid Build Coastguard Worker  Enum e = 7;
65*288bf522SAndroid Build Coastguard Worker}
66