[protobuf-schema] Use snake_case for protobuf fields, UPPER_SNAKE_CASE for enums. (#20696)

* protobuf enum prefix use upper underscore

Add json name parameters and change parameter field name to snake case

* rerun generate-samples.sh

* Add CI test

* rebase master

---------

Co-authored-by: xil <xil@uber.com>
This commit is contained in:
lucy66hw 2025-03-04 01:18:07 -08:00 committed by GitHub
parent 90de8dcd75
commit c96d3088c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 637 additions and 31 deletions

38
.github/workflows/samples-protobuf.yaml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Samples Protobuf
on:
push:
paths:
- .github/workflows/samples-protobuf.yaml
- samples/config/petstore/protobuf-schema/**
- samples/config/petstore/protobuf-schema-config/**
pull_request:
paths:
- .github/workflows/samples-protobuf.yaml
- samples/config/petstore/protobuf-schema/**
- samples/config/petstore/protobuf-schema-config/**
jobs:
build:
name: Build Protobuf Client
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
- 'samples/config/petstore/protobuf-schema/'
- 'samples/config/petstore/protobuf-schema-config/'
steps:
- uses: actions/checkout@v4
- name: Install Protocol Buffers Compiler
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Generate Protobuf Schema
working-directory: ${{ matrix.sample }}
run: |
mkdir out
protoc --proto_path=. --cpp_out=out models/*.proto services/*.proto
- name: Verify Generated Files
working-directory: ${{ matrix.sample }}
run: |
ls -l out/models
ls -l out/services

View File

@ -0,0 +1,9 @@
generatorName: protobuf-schema
outputDir: samples/config/petstore/protobuf-schema-config
inputSpec: modules/openapi-generator/src/test/resources/3_0/protobuf/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/protobuf-schema
additionalProperties:
packageName: petstore
addJsonNameAnnotation: true
numberedFieldNumberList: true
startEnumsWithUnspecified: true

View File

@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default | | Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- | | ------ | ----------- | ------ | ------- |
|addJsonNameAnnotation|Append &quot;json_name&quot; annotation to message field when the specification name differs from the protobuf field name| |false|
|numberedFieldNumberList|Field numbers in order.| |false| |numberedFieldNumberList|Field numbers in order.| |false|
|startEnumsWithUnspecified|Introduces &quot;UNSPECIFIED&quot; as the first element of enumerations.| |false| |startEnumsWithUnspecified|Introduces &quot;UNSPECIFIED&quot; as the first element of enumerations.| |false|

View File

@ -38,6 +38,7 @@ import java.io.File;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.google.common.base.CaseFormat;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -52,6 +53,8 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
public static final String START_ENUMS_WITH_UNSPECIFIED = "startEnumsWithUnspecified"; public static final String START_ENUMS_WITH_UNSPECIFIED = "startEnumsWithUnspecified";
public static final String ADD_JSON_NAME_ANNOTATION = "addJsonNameAnnotation";
private final Logger LOGGER = LoggerFactory.getLogger(ProtobufSchemaCodegen.class); private final Logger LOGGER = LoggerFactory.getLogger(ProtobufSchemaCodegen.class);
@Setter protected String packageName = "openapitools"; @Setter protected String packageName = "openapitools";
@ -60,11 +63,18 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
private boolean startEnumsWithUnspecified = false; private boolean startEnumsWithUnspecified = false;
private boolean addJsonNameAnnotation = false;
@Override @Override
public CodegenType getTag() { public CodegenType getTag() {
return CodegenType.SCHEMA; return CodegenType.SCHEMA;
} }
@Override
public String toEnumName(CodegenProperty property) {
return StringUtils.capitalize(property.name);
}
@Override @Override
public String getName() { public String getName() {
return "protobuf-schema"; return "protobuf-schema";
@ -163,6 +173,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
addSwitch(NUMBERED_FIELD_NUMBER_LIST, "Field numbers in order.", numberedFieldNumberList); addSwitch(NUMBERED_FIELD_NUMBER_LIST, "Field numbers in order.", numberedFieldNumberList);
addSwitch(START_ENUMS_WITH_UNSPECIFIED, "Introduces \"UNSPECIFIED\" as the first element of enumerations.", startEnumsWithUnspecified); addSwitch(START_ENUMS_WITH_UNSPECIFIED, "Introduces \"UNSPECIFIED\" as the first element of enumerations.", startEnumsWithUnspecified);
addSwitch(ADD_JSON_NAME_ANNOTATION, "Append \"json_name\" annotation to message field when the specification name differs from the protobuf field name", addJsonNameAnnotation);
} }
@Override @Override
@ -197,6 +208,10 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
this.startEnumsWithUnspecified = convertPropertyToBooleanAndWriteBack(START_ENUMS_WITH_UNSPECIFIED); this.startEnumsWithUnspecified = convertPropertyToBooleanAndWriteBack(START_ENUMS_WITH_UNSPECIFIED);
} }
if (additionalProperties.containsKey(this.ADD_JSON_NAME_ANNOTATION)) {
this.addJsonNameAnnotation = convertPropertyToBooleanAndWriteBack(ADD_JSON_NAME_ANNOTATION);
}
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
} }
@ -226,7 +241,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
public void addEnumValuesPrefix(Map<String, Object> allowableValues, String prefix) { public void addEnumValuesPrefix(Map<String, Object> allowableValues, String prefix) {
if (allowableValues.containsKey("enumVars")) { if (allowableValues.containsKey("enumVars")) {
List<Map<String, Object>> enumVars = (List<Map<String, Object>>) allowableValues.get("enumVars"); List<Map<String, Object>> enumVars = (List<Map<String, Object>>) allowableValues.get("enumVars");
prefix = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, prefix);
for (Map<String, Object> value : enumVars) { for (Map<String, Object> value : enumVars) {
String name = (String) value.get("name"); String name = (String) value.get("name");
value.put("name", prefix + "_" + name); value.put("name", prefix + "_" + name);
@ -338,6 +353,10 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
var.vendorExtensions.putIfAbsent("x-protobuf-index", "Generated field number is in reserved range (19000, 19999)"); var.vendorExtensions.putIfAbsent("x-protobuf-index", "Generated field number is in reserved range (19000, 19999)");
} }
} }
if (addJsonNameAnnotation && !var.baseName.equals(var.name)) {
var.vendorExtensions.put("x-protobuf-json-name", var.baseName);
}
} }
} }
return objs; return objs;
@ -493,10 +512,38 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
} }
@Override @Override
public String toVarName(final String name) { public String toVarName(String name) {
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
// sanitize name
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// if it's all upper case, convert to lower case
if (name.matches("^[A-Z_]*$")) {
name = name.toLowerCase(Locale.ROOT);
}
// underscore the variable name
// petId => pet_id
name = underscore(name);
// remove leading underscore
name = name.replaceAll("^_*", "");
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
name = escapeReservedWord(name);
}
return name; return name;
} }
@Override
public String toParamName(String name) {
return toVarName(name);
}
@Override @Override
public String toModelName(String name) { public String toModelName(String name) {
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
@ -571,6 +618,10 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
} }
} }
if (addJsonNameAnnotation && !p.baseName.equals(p.paramName) && !p.isBodyParam) {
p.vendorExtensions.put("x-protobuf-json-name", p.baseName);
}
p.vendorExtensions.putIfAbsent("x-protobuf-index", index); p.vendorExtensions.putIfAbsent("x-protobuf-index", index);
index++; index++;
} }
@ -646,4 +697,5 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
public GeneratorLanguage generatorLanguage() { public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.PROTOBUF; return GeneratorLanguage.PROTOBUF;
} }
} }

View File

@ -30,7 +30,7 @@ message {{operationId}}Request {
{{#description}} {{#description}}
// {{{.}}} // {{{.}}}
{{/description}} {{/description}}
{{#vendorExtensions.x-protobuf-type}}{{.}} {{/vendorExtensions.x-protobuf-type}}{{vendorExtensions.x-protobuf-data-type}} {{paramName}} = {{vendorExtensions.x-protobuf-index}}; {{#vendorExtensions.x-protobuf-type}}{{.}} {{/vendorExtensions.x-protobuf-type}}{{vendorExtensions.x-protobuf-data-type}} {{paramName}} = {{vendorExtensions.x-protobuf-index}}{{#vendorExtensions.x-protobuf-json-name}} [json_name="{{vendorExtensions.x-protobuf-json-name}}"]{{/vendorExtensions.x-protobuf-json-name}};
{{/allParams}} {{/allParams}}
} }

View File

@ -18,7 +18,7 @@ import public "{{{modelPackage}}}/{{{import}}}.proto";
// {{{.}}} // {{{.}}}
{{/description}} {{/description}}
{{^isEnum}} {{^isEnum}}
{{#vendorExtensions.x-protobuf-type}}{{{.}}} {{/vendorExtensions.x-protobuf-type}}{{{vendorExtensions.x-protobuf-data-type}}} {{{name}}} = {{vendorExtensions.x-protobuf-index}}{{#vendorExtensions.x-protobuf-packed}} [packed=true]{{/vendorExtensions.x-protobuf-packed}}; {{#vendorExtensions.x-protobuf-type}}{{{.}}} {{/vendorExtensions.x-protobuf-type}}{{{vendorExtensions.x-protobuf-data-type}}} {{{name}}} = {{vendorExtensions.x-protobuf-index}}{{#vendorExtensions.x-protobuf-packed}} [packed=true]{{/vendorExtensions.x-protobuf-packed}}{{#vendorExtensions.x-protobuf-json-name}} [json_name="{{vendorExtensions.x-protobuf-json-name}}"]{{/vendorExtensions.x-protobuf-json-name}};
{{/isEnum}} {{/isEnum}}
{{#isEnum}} {{#isEnum}}
enum {{enumName}} { enum {{enumName}} {

View File

@ -91,6 +91,6 @@ public class ProtobufSchemaCodegenTest {
final CodegenModel simpleName = codegen.fromModel("$DollarModel$", openAPI.getComponents().getSchemas().get("$DollarModel$")); final CodegenModel simpleName = codegen.fromModel("$DollarModel$", openAPI.getComponents().getSchemas().get("$DollarModel$"));
Assert.assertEquals(simpleName.name, "$DollarModel$"); Assert.assertEquals(simpleName.name, "$DollarModel$");
Assert.assertEquals(simpleName.classname, "DollarModel"); Assert.assertEquals(simpleName.classname, "DollarModel");
Assert.assertEquals(simpleName.classVarName, "$DollarModel$"); Assert.assertEquals(simpleName.classVarName, "dollar_model");
} }
} }

View File

@ -14,12 +14,12 @@ package openapitools;
message Pet { message Pet {
string petType = 140636936; string pet_type = 482112090;
string name = 3373707; string name = 3373707;
string bark = 3016376; string bark = 3016376;
bool lovesRocks = 499337491; bool loves_rocks = 465093427;
} }

View File

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,11 @@
README.md
models/api_response.proto
models/category.proto
models/order.proto
models/other_test.proto
models/pet.proto
models/tag.proto
models/user.proto
services/pet_service.proto
services/store_service.proto
services/user_service.proto

View File

@ -0,0 +1 @@
7.13.0-SNAPSHOT

View File

@ -0,0 +1,32 @@
# gPRC for petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
## Overview
These files were generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
- API version: 1.0.0
- Package version:
- Generator version: 7.13.0-SNAPSHOT
- Build package: org.openapitools.codegen.languages.ProtobufSchemaCodegen
## Usage
Below are some usage examples for Go and Ruby. For other languages, please refer to https://grpc.io/docs/quickstart/.
### Go
```
# assuming `protoc-gen-go` has been installed with `go get -u github.com/golang/protobuf/protoc-gen-go`
mkdir /var/tmp/go/petstore
protoc --go_out=/var/tmp/go/petstore services/*
protoc --go_out=/var/tmp/go/petstore models/*
```
### Ruby
```
# assuming `grpc_tools_ruby_protoc` has been installed via `gem install grpc-tools`
RUBY_OUTPUT_DIR="/var/tmp/ruby/petstore"
mkdir $RUBY_OUTPUT_DIR
grpc_tools_ruby_protoc --ruby_out=$RUBY_OUTPUT_DIR --grpc_out=$RUBY_OUTPUT_DIR/lib services/*
grpc_tools_ruby_protoc --ruby_out=$RUBY_OUTPUT_DIR --grpc_out=$RUBY_OUTPUT_DIR/lib models/*
```

View File

@ -0,0 +1,24 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore;
message ApiResponse {
int32 code = 1;
string type = 2;
string message = 3;
}

View File

@ -0,0 +1,22 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore;
message Category {
int64 id = 1;
string name = 2;
}

View File

@ -0,0 +1,38 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore;
message Order {
int64 id = 1;
int64 pet_id = 2 [json_name="petId"];
int32 quantity = 3;
string ship_date = 4 [json_name="shipDate"];
// Order Status
enum Status {
STATUS_UNSPECIFIED = 0;
STATUS_PLACED = 1;
STATUS_APPROVED = 2;
STATUS_DELIVERED = 3;
}
Status status = 5;
bool complete = 6;
}

View File

@ -0,0 +1,20 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore;
message OtherTest {
repeated string set_test = 1;
}

View File

@ -0,0 +1,40 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore;
import public "models/category.proto";
import public "models/tag.proto";
message Pet {
int64 id = 1;
Category category = 2;
string name = 3;
repeated string photo_urls = 4 [json_name="photoUrls"];
repeated Tag tags = 5;
// pet status in the store
enum Status {
STATUS_UNSPECIFIED = 0;
STATUS_AVAILABLE = 1;
STATUS_PENDING = 2;
STATUS_SOLD = 3;
}
Status status = 6;
}

View File

@ -0,0 +1,22 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore;
message Tag {
int64 id = 1;
string name = 2;
}

View File

@ -0,0 +1,35 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore;
message User {
int64 id = 1;
string username = 2;
string first_name = 3 [json_name="firstName"];
string last_name = 4 [json_name="lastName"];
string email = 5;
string password = 6;
string phone = 7;
// User Status
int32 user_status = 8 [json_name="userStatus"];
}

View File

@ -0,0 +1,102 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore.services.petservice;
import "google/protobuf/empty.proto";
import public "models/api_response.proto";
import public "models/pet.proto";
service PetService {
rpc AddPet (AddPetRequest) returns (Pet);
rpc DeletePet (DeletePetRequest) returns (google.protobuf.Empty);
rpc FindPetsByStatus (FindPetsByStatusRequest) returns (FindPetsByStatusResponse);
rpc FindPetsByTags (FindPetsByTagsRequest) returns (FindPetsByTagsResponse);
rpc GetPetById (GetPetByIdRequest) returns (Pet);
rpc UpdatePet (UpdatePetRequest) returns (Pet);
rpc UpdatePetWithForm (UpdatePetWithFormRequest) returns (google.protobuf.Empty);
rpc UploadFile (UploadFileRequest) returns (ApiResponse);
}
message AddPetRequest {
// Pet object that needs to be added to the store
Pet pet = 1;
}
message DeletePetRequest {
// Pet id to delete
int64 pet_id = 1 [json_name="petId"];
string api_key = 2;
}
message FindPetsByStatusRequest {
// Status values that need to be considered for filter
repeated string status = 1;
}
message FindPetsByStatusResponse {
repeated Pet data = 1;
}
message FindPetsByTagsRequest {
// Tags to filter by
repeated string tags = 1;
}
message FindPetsByTagsResponse {
repeated Pet data = 1;
}
message GetPetByIdRequest {
// ID of pet to return
int64 pet_id = 1 [json_name="petId"];
}
message UpdatePetRequest {
// Pet object that needs to be added to the store
Pet pet = 1;
}
message UpdatePetWithFormRequest {
// ID of pet that needs to be updated
int64 pet_id = 1 [json_name="petId"];
// Updated name of the pet
string name = 2;
// Updated status of the pet
string status = 3;
}
message UploadFileRequest {
// ID of pet to update
int64 pet_id = 1 [json_name="petId"];
// Additional data to pass to server
string additional_metadata = 2 [json_name="additionalMetadata"];
// file to upload
string file = 3;
}

View File

@ -0,0 +1,50 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore.services.storeservice;
import "google/protobuf/empty.proto";
import public "models/order.proto";
service StoreService {
rpc DeleteOrder (DeleteOrderRequest) returns (google.protobuf.Empty);
rpc GetInventory (google.protobuf.Empty) returns (GetInventoryResponse);
rpc GetOrderById (GetOrderByIdRequest) returns (Order);
rpc PlaceOrder (PlaceOrderRequest) returns (Order);
}
message DeleteOrderRequest {
// ID of the order that needs to be deleted
string order_id = 1 [json_name="orderId"];
}
message GetInventoryResponse {
int32 data = 1;
}
message GetOrderByIdRequest {
// ID of pet that needs to be fetched
int64 order_id = 1 [json_name="orderId"];
}
message PlaceOrderRequest {
// order placed for purchasing the pet
Order order = 1;
}

View File

@ -0,0 +1,86 @@
/*
OpenAPI Petstore
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package petstore.services.userservice;
import "google/protobuf/empty.proto";
import public "models/user.proto";
service UserService {
rpc CreateUser (CreateUserRequest) returns (google.protobuf.Empty);
rpc CreateUsersWithArrayInput (CreateUsersWithArrayInputRequest) returns (google.protobuf.Empty);
rpc CreateUsersWithListInput (CreateUsersWithListInputRequest) returns (google.protobuf.Empty);
rpc DeleteUser (DeleteUserRequest) returns (google.protobuf.Empty);
rpc GetUserByName (GetUserByNameRequest) returns (User);
rpc LoginUser (LoginUserRequest) returns (LoginUserResponse);
rpc LogoutUser (google.protobuf.Empty) returns (google.protobuf.Empty);
rpc UpdateUser (UpdateUserRequest) returns (google.protobuf.Empty);
}
message CreateUserRequest {
// Created user object
User user = 1;
}
message CreateUsersWithArrayInputRequest {
// List of user object
repeated User user = 1;
}
message CreateUsersWithListInputRequest {
// List of user object
repeated User user = 1;
}
message DeleteUserRequest {
// The name that needs to be deleted
string username = 1;
}
message GetUserByNameRequest {
// The name that needs to be fetched. Use user1 for testing.
string username = 1;
}
message LoginUserRequest {
// The user name for login
string username = 1;
// The password for login in clear text
string password = 2;
}
message LoginUserResponse {
string data = 1;
}
message UpdateUserRequest {
// name that need to be deleted
string username = 1;
// Updated user object
User user = 2;
}

View File

@ -17,20 +17,20 @@ message Order {
int64 id = 3355; int64 id = 3355;
int64 petId = 106557082; int64 pet_id = 454805446;
int32 quantity = 211262327; int32 quantity = 211262327;
string shipDate = 517554166; string ship_date = 86954963;
// Order Status // Order Status
enum StatusEnum { enum Status {
StatusEnum_PLACED = 0; STATUS_PLACED = 0;
StatusEnum_APPROVED = 1; STATUS_APPROVED = 1;
StatusEnum_DELIVERED = 2; STATUS_DELIVERED = 2;
} }
StatusEnum status = 355610639; Status status = 355610639;
bool complete = 62574280; bool complete = 62574280;

View File

@ -23,17 +23,17 @@ message Pet {
string name = 3373707; string name = 3373707;
repeated string photoUrls = 311086539; repeated string photo_urls = 507546927;
repeated Tag tags = 3552281; repeated Tag tags = 3552281;
// pet status in the store // pet status in the store
enum StatusEnum { enum Status {
StatusEnum_AVAILABLE = 0; STATUS_AVAILABLE = 0;
StatusEnum_PENDING = 1; STATUS_PENDING = 1;
StatusEnum_SOLD = 2; STATUS_SOLD = 2;
} }
StatusEnum status = 355610639; Status status = 355610639;
} }

View File

@ -19,9 +19,9 @@ message User {
string username = 265713450; string username = 265713450;
string firstName = 132835675; string first_name = 160985414;
string lastName = 385857985; string last_name = 402509463;
string email = 96619420; string email = 96619420;
@ -30,6 +30,6 @@ message User {
string phone = 106642798; string phone = 106642798;
// User Status // User Status
int32 userStatus = 517890975; int32 user_status = 150530330;
} }

View File

@ -43,8 +43,8 @@ message AddPetRequest {
message DeletePetRequest { message DeletePetRequest {
// Pet id to delete // Pet id to delete
int64 petId = 1; int64 pet_id = 1;
string apiKey = 2; string api_key = 2;
} }
@ -70,7 +70,7 @@ message FindPetsByTagsResponse {
message GetPetByIdRequest { message GetPetByIdRequest {
// ID of pet to return // ID of pet to return
int64 petId = 1; int64 pet_id = 1;
} }
@ -82,7 +82,7 @@ message UpdatePetRequest {
message UpdatePetWithFormRequest { message UpdatePetWithFormRequest {
// ID of pet that needs to be updated // ID of pet that needs to be updated
int64 petId = 1; int64 pet_id = 1;
// Updated name of the pet // Updated name of the pet
string name = 2; string name = 2;
// Updated status of the pet // Updated status of the pet
@ -92,9 +92,9 @@ message UpdatePetWithFormRequest {
message UploadFileRequest { message UploadFileRequest {
// ID of pet to update // ID of pet to update
int64 petId = 1; int64 pet_id = 1;
// Additional data to pass to server // Additional data to pass to server
string additionalMetadata = 2; string additional_metadata = 2;
// file to upload // file to upload
string file = 3; string file = 3;

View File

@ -28,7 +28,7 @@ service StoreService {
message DeleteOrderRequest { message DeleteOrderRequest {
// ID of the order that needs to be deleted // ID of the order that needs to be deleted
string orderId = 1; string order_id = 1;
} }
@ -38,7 +38,7 @@ message GetInventoryResponse {
message GetOrderByIdRequest { message GetOrderByIdRequest {
// ID of pet that needs to be fetched // ID of pet that needs to be fetched
int64 orderId = 1; int64 order_id = 1;
} }