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