forked from loafle/openapi-generator-original
[Protobuf Schema] Add Support for Multiple Response (#20989)
* Protobuf Schema Support Multiple Response * change the supportMultiple response to true * address build failure * address build failure
This commit is contained in:
parent
36287acfd6
commit
3b0bb0a73d
@ -8,6 +8,7 @@ additionalProperties:
|
|||||||
numberedFieldNumberList: true
|
numberedFieldNumberList: true
|
||||||
startEnumsWithUnspecified: true
|
startEnumsWithUnspecified: true
|
||||||
wrapComplexType: false
|
wrapComplexType: false
|
||||||
|
supportMultipleResponses: false
|
||||||
aggregateModelsName: data
|
aggregateModelsName: data
|
||||||
typeMappings:
|
typeMappings:
|
||||||
object: "google.protobuf.Struct"
|
object: "google.protobuf.Struct"
|
||||||
|
@ -22,6 +22,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|aggregateModelsName|Aggregated model filename. If set, all generated models will be combined into this single file.| |null|
|
|aggregateModelsName|Aggregated model filename. If set, all generated models will be combined into this single file.| |null|
|
||||||
|numberedFieldNumberList|Field numbers in order.| |false|
|
|numberedFieldNumberList|Field numbers in order.| |false|
|
||||||
|startEnumsWithUnspecified|Introduces "UNSPECIFIED" as the first element of enumerations.| |false|
|
|startEnumsWithUnspecified|Introduces "UNSPECIFIED" as the first element of enumerations.| |false|
|
||||||
|
|supportMultipleResponses|Support multiple responses| |true|
|
||||||
|wrapComplexType|Generate Additional message for complex type| |true|
|
|wrapComplexType|Generate Additional message for complex type| |true|
|
||||||
|
|
||||||
## IMPORT MAPPING
|
## IMPORT MAPPING
|
||||||
|
@ -68,6 +68,8 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
|
|
||||||
public static final String AGGREGATE_MODELS_NAME = "aggregateModelsName";
|
public static final String AGGREGATE_MODELS_NAME = "aggregateModelsName";
|
||||||
|
|
||||||
|
public static final String SUPPORT_MULTIPLE_RESPONSES = "supportMultipleResponses";
|
||||||
|
|
||||||
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";
|
||||||
@ -82,6 +84,8 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
|
|
||||||
private boolean wrapComplexType = true;
|
private boolean wrapComplexType = true;
|
||||||
|
|
||||||
|
private boolean supportMultipleResponses = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag() {
|
||||||
return CodegenType.SCHEMA;
|
return CodegenType.SCHEMA;
|
||||||
@ -192,6 +196,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
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);
|
addSwitch(ADD_JSON_NAME_ANNOTATION, "Append \"json_name\" annotation to message field when the specification name differs from the protobuf field name", addJsonNameAnnotation);
|
||||||
addSwitch(WRAP_COMPLEX_TYPE, "Generate Additional message for complex type", wrapComplexType);
|
addSwitch(WRAP_COMPLEX_TYPE, "Generate Additional message for complex type", wrapComplexType);
|
||||||
|
addSwitch(SUPPORT_MULTIPLE_RESPONSES, "Support multiple responses", supportMultipleResponses);
|
||||||
addOption(AGGREGATE_MODELS_NAME, "Aggregated model filename. If set, all generated models will be combined into this single file.", null);
|
addOption(AGGREGATE_MODELS_NAME, "Aggregated model filename. If set, all generated models will be combined into this single file.", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,6 +244,12 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
this.setAggregateModelsName((String) additionalProperties.get(AGGREGATE_MODELS_NAME));
|
this.setAggregateModelsName((String) additionalProperties.get(AGGREGATE_MODELS_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(this.SUPPORT_MULTIPLE_RESPONSES)) {
|
||||||
|
this.supportMultipleResponses = convertPropertyToBooleanAndWriteBack(SUPPORT_MULTIPLE_RESPONSES);
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(this.SUPPORT_MULTIPLE_RESPONSES, this.supportMultipleResponses);
|
||||||
|
}
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,7 +453,6 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
} else if (ModelUtils.isAnyOf(schema)) {
|
} else if (ModelUtils.isAnyOf(schema)) {
|
||||||
wrapComposedChildren(schema.getAnyOf(), visitedSchema);
|
wrapComposedChildren(schema.getAnyOf(), visitedSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,7 +485,6 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds prefix to the enum allowable values
|
* Adds prefix to the enum allowable values
|
||||||
* NOTE: Enum values use C++ scoping rules, meaning that enum values are siblings of their type, not children of it. Therefore, enum value must be unique
|
* NOTE: Enum values use C++ scoping rules, meaning that enum values are siblings of their type, not children of it. Therefore, enum value must be unique
|
||||||
@ -522,7 +531,9 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
|
|
||||||
if (allowableValues.containsKey("values")) {
|
if (allowableValues.containsKey("values")) {
|
||||||
List<String> values = (List<String>) allowableValues.get("values");
|
List<String> values = (List<String>) allowableValues.get("values");
|
||||||
values.add(0, "UNSPECIFIED");
|
List<String> modifiableValues = new ArrayList<>(values);
|
||||||
|
modifiableValues.add(0, "UNSPECIFIED");
|
||||||
|
allowableValues.put("values", modifiableValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -542,24 +553,28 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
|
|
||||||
public List<CodegenProperty> processOneOfAnyOfItems(List<CodegenProperty> composedSchemasProperty) {
|
public List<CodegenProperty> processOneOfAnyOfItems(List<CodegenProperty> composedSchemasProperty) {
|
||||||
for(CodegenProperty cd: composedSchemasProperty) {
|
for(CodegenProperty cd: composedSchemasProperty) {
|
||||||
if (cd.getTitle() != null) {
|
cd.name = resolveVarName(cd);
|
||||||
cd.name = cd.getTitle();
|
cd.baseName = resolveVarName(cd);
|
||||||
cd.baseName = cd.getTitle();
|
|
||||||
} else{
|
|
||||||
cd.name = getNameFromDataType(cd);
|
|
||||||
cd.baseName = getNameFromDataType(cd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return composedSchemasProperty;
|
return composedSchemasProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String resolveVarName(CodegenProperty property) {
|
||||||
|
if(property.getTitle() != null) {
|
||||||
|
return toVarName(property.getTitle());
|
||||||
|
} else {
|
||||||
|
return getNameFromDataType(property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNameFromDataType(CodegenProperty property) {
|
public String getNameFromDataType(CodegenProperty property) {
|
||||||
if (Boolean.TRUE.equals(property.getIsArray())){
|
if (Boolean.TRUE.equals(property.getIsArray())){
|
||||||
return underscore(property.mostInnerItems.dataType + ARRAY_SUFFIX);
|
return toVarName(property.mostInnerItems.dataType + ARRAY_SUFFIX);
|
||||||
} else if (Boolean.TRUE.equals(property.getIsMap())) {
|
} else if (Boolean.TRUE.equals(property.getIsMap())) {
|
||||||
return underscore(property.mostInnerItems.dataType + MAP_SUFFIX);
|
return toVarName(property.mostInnerItems.dataType + MAP_SUFFIX);
|
||||||
} else {
|
} else {
|
||||||
return underscore(property.dataType);
|
return toVarName(property.dataType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -944,12 +959,41 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.supportMultipleResponses) {
|
||||||
|
int responseIdx = 1;
|
||||||
|
op.vendorExtensions.put("x-grpc-response", op.operationId+"Response");
|
||||||
|
for (CodegenResponse r : op.responses) {
|
||||||
|
if (r.returnProperty == null) {
|
||||||
|
r.vendorExtensions.put("x-oneOf-response-type", "google.protobuf.Empty");
|
||||||
|
r.vendorExtensions.put("x-oneOf-response-name", "empty");
|
||||||
|
} else if (r.isMap && r.additionalProperties != null) {
|
||||||
|
r.vendorExtensions.put("x-oneOf-response-type", r.returnProperty.additionalProperties.dataType);
|
||||||
|
r.vendorExtensions.put("x-oneOf-response-name", resolveVarName(r.returnProperty.additionalProperties));
|
||||||
|
LOGGER.warn("Mapping responses for operations with supportMultipleResponses flag (operation ID: {}) is not currently supported.", op.operationId);
|
||||||
|
} else if (r.isArray && r.items != null) {
|
||||||
|
r.vendorExtensions.put("x-oneOf-response-type", r.returnProperty.items.dataType);
|
||||||
|
r.vendorExtensions.put("x-oneOf-response-name", resolveVarName(r.returnProperty.items));
|
||||||
|
LOGGER.warn("Array responses for operations with supportMultipleResponses flag (operation ID: {}) is not currently supported.", op.operationId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
r.vendorExtensions.put("x-oneOf-response-type", r.returnProperty.dataType);
|
||||||
|
r.vendorExtensions.put("x-oneOf-response-name", resolveVarName(r.returnProperty));
|
||||||
|
}
|
||||||
|
r.vendorExtensions.put("x-oneOf-response-index", responseIdx++);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.aggregateModelsName != null) {
|
if (this.aggregateModelsName != null) {
|
||||||
|
List<Map<String, String>> imports = objs.getImports().stream()
|
||||||
|
.filter(importMap -> !importMap.get("import").startsWith("models/"))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
List<Map<String, String>> aggregate_imports = Collections.singletonList(Collections
|
List<Map<String, String>> aggregate_imports = Collections.singletonList(Collections
|
||||||
.singletonMap(IMPORT, toModelImport(this.aggregateModelsName)));
|
.singletonMap(IMPORT, toModelImport(this.aggregateModelsName)));
|
||||||
objs.setImports(aggregate_imports);
|
imports.addAll(aggregate_imports);
|
||||||
|
objs.setImports(imports);
|
||||||
}
|
}
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
@ -42,5 +42,14 @@ message {{operationId}}Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/vendorExtensions.x-grpc-response}}
|
{{/vendorExtensions.x-grpc-response}}
|
||||||
|
{{#supportMultipleResponses}}
|
||||||
|
message {{operationId}}Response {
|
||||||
|
oneof response {
|
||||||
|
{{#responses}}
|
||||||
|
{{{vendorExtensions.x-oneOf-response-type}}} {{vendorExtensions.x-oneOf-response-name}}_{{code}} = {{vendorExtensions.x-oneOf-response-index}};
|
||||||
|
{{/responses}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{{/supportMultipleResponses}}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
@ -59,7 +59,7 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Pet'
|
$ref: '#/components/schemas/Pet'
|
||||||
'405':
|
'405':
|
||||||
description: Invalid input
|
$ref: '#/components/responses/ErrorResponse'
|
||||||
security:
|
security:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- 'write:pets'
|
- 'write:pets'
|
||||||
@ -83,11 +83,11 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Pet'
|
$ref: '#/components/schemas/Pet'
|
||||||
'400':
|
'400':
|
||||||
description: Invalid ID supplied
|
$ref: '#/components/responses/ErrorResponse'
|
||||||
'404':
|
'404':
|
||||||
description: Pet not found
|
$ref: '#/components/responses/ErrorResponse'
|
||||||
'405':
|
'405':
|
||||||
description: Validation exception
|
$ref: '#/components/responses/ErrorResponse'
|
||||||
security:
|
security:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- 'write:pets'
|
- 'write:pets'
|
||||||
@ -593,6 +593,13 @@ externalDocs:
|
|||||||
description: Find out more about Swagger
|
description: Find out more about Swagger
|
||||||
url: 'http://swagger.io'
|
url: 'http://swagger.io'
|
||||||
components:
|
components:
|
||||||
|
responses:
|
||||||
|
ErrorResponse:
|
||||||
|
description: An error response.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Error'
|
||||||
requestBodies:
|
requestBodies:
|
||||||
UserArray:
|
UserArray:
|
||||||
content:
|
content:
|
||||||
@ -786,3 +793,16 @@ components:
|
|||||||
uniqueItems: true
|
uniqueItems: true
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
|
Error:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- code
|
||||||
|
- message
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
description: Error code.
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
description: Detailed error message.
|
||||||
|
@ -16,7 +16,7 @@ import "google/protobuf/empty.proto";
|
|||||||
import public "models/cat.proto";
|
import public "models/cat.proto";
|
||||||
|
|
||||||
service DefaultService {
|
service DefaultService {
|
||||||
rpc PetsGet (PetsGetRequest) returns (google.protobuf.Empty);
|
rpc PetsGet (PetsGetRequest) returns (PetsGetResponse);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,3 +25,8 @@ message PetsGetRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message PetsGetResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_200 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -56,6 +56,16 @@ message Dog {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Error {
|
||||||
|
|
||||||
|
// Error code.
|
||||||
|
int32 code = 1;
|
||||||
|
|
||||||
|
// Detailed error message.
|
||||||
|
string message = 2;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
message Order {
|
message Order {
|
||||||
|
|
||||||
int64 id = 1;
|
int64 id = 1;
|
||||||
|
@ -3,6 +3,7 @@ models/api_response.proto
|
|||||||
models/cat.proto
|
models/cat.proto
|
||||||
models/category.proto
|
models/category.proto
|
||||||
models/dog.proto
|
models/dog.proto
|
||||||
|
models/error.proto
|
||||||
models/order.proto
|
models/order.proto
|
||||||
models/other_test.proto
|
models/other_test.proto
|
||||||
models/pet.proto
|
models/pet.proto
|
||||||
|
25
samples/config/petstore/protobuf-schema/models/error.proto
Normal file
25
samples/config/petstore/protobuf-schema/models/error.proto
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
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 Error {
|
||||||
|
|
||||||
|
// Error code.
|
||||||
|
int32 code = 3059181;
|
||||||
|
|
||||||
|
// Detailed error message.
|
||||||
|
string message = 418054152;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -17,9 +17,9 @@ import public "models/pets_get_request.proto";
|
|||||||
import public "models/pets_post_request.proto";
|
import public "models/pets_post_request.proto";
|
||||||
|
|
||||||
service DefaultService {
|
service DefaultService {
|
||||||
rpc PetsGet (PetsGetRequest) returns (google.protobuf.Empty);
|
rpc PetsGet (PetsGetRequest) returns (PetsGetResponse);
|
||||||
|
|
||||||
rpc PetsPost (PetsPostRequest) returns (google.protobuf.Empty);
|
rpc PetsPost (PetsPostRequest) returns (PetsPostResponse);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,8 +28,18 @@ message PetsGetRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message PetsGetResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_200 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
message PetsPostRequest {
|
message PetsPostRequest {
|
||||||
PetsPostRequest pets_post_request = 1;
|
PetsPostRequest pets_post_request = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message PetsPostResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_200 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,24 +14,25 @@ package petstore.services.petservice;
|
|||||||
|
|
||||||
import "google/protobuf/empty.proto";
|
import "google/protobuf/empty.proto";
|
||||||
import public "models/api_response.proto";
|
import public "models/api_response.proto";
|
||||||
|
import public "models/error.proto";
|
||||||
import public "models/pet.proto";
|
import public "models/pet.proto";
|
||||||
|
|
||||||
service PetService {
|
service PetService {
|
||||||
rpc AddPet (AddPetRequest) returns (Pet);
|
rpc AddPet (AddPetRequest) returns (AddPetResponse);
|
||||||
|
|
||||||
rpc DeletePet (DeletePetRequest) returns (google.protobuf.Empty);
|
rpc DeletePet (DeletePetRequest) returns (DeletePetResponse);
|
||||||
|
|
||||||
rpc FindPetsByStatus (FindPetsByStatusRequest) returns (FindPetsByStatusResponse);
|
rpc FindPetsByStatus (FindPetsByStatusRequest) returns (FindPetsByStatusResponse);
|
||||||
|
|
||||||
rpc FindPetsByTags (FindPetsByTagsRequest) returns (FindPetsByTagsResponse);
|
rpc FindPetsByTags (FindPetsByTagsRequest) returns (FindPetsByTagsResponse);
|
||||||
|
|
||||||
rpc GetPetById (GetPetByIdRequest) returns (Pet);
|
rpc GetPetById (GetPetByIdRequest) returns (GetPetByIdResponse);
|
||||||
|
|
||||||
rpc UpdatePet (UpdatePetRequest) returns (Pet);
|
rpc UpdatePet (UpdatePetRequest) returns (UpdatePetResponse);
|
||||||
|
|
||||||
rpc UpdatePetWithForm (UpdatePetWithFormRequest) returns (google.protobuf.Empty);
|
rpc UpdatePetWithForm (UpdatePetWithFormRequest) returns (UpdatePetWithFormResponse);
|
||||||
|
|
||||||
rpc UploadFile (UploadFileRequest) returns (ApiResponse);
|
rpc UploadFile (UploadFileRequest) returns (UploadFileResponse);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +42,12 @@ message AddPetRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message AddPetResponse {
|
||||||
|
oneof response {
|
||||||
|
Pet pet_200 = 1;
|
||||||
|
Error error_405 = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
message DeletePetRequest {
|
message DeletePetRequest {
|
||||||
// Pet id to delete
|
// Pet id to delete
|
||||||
int64 pet_id = 1;
|
int64 pet_id = 1;
|
||||||
@ -48,6 +55,11 @@ message DeletePetRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message DeletePetResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_400 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
message FindPetsByStatusRequest {
|
message FindPetsByStatusRequest {
|
||||||
// Status values that need to be considered for filter
|
// Status values that need to be considered for filter
|
||||||
repeated string status = 1;
|
repeated string status = 1;
|
||||||
@ -55,9 +67,11 @@ message FindPetsByStatusRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message FindPetsByStatusResponse {
|
message FindPetsByStatusResponse {
|
||||||
repeated Pet data = 1;
|
oneof response {
|
||||||
|
Pet pet_200 = 1;
|
||||||
|
google.protobuf.Empty empty_400 = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message FindPetsByTagsRequest {
|
message FindPetsByTagsRequest {
|
||||||
// Tags to filter by
|
// Tags to filter by
|
||||||
repeated string tags = 1;
|
repeated string tags = 1;
|
||||||
@ -65,21 +79,38 @@ message FindPetsByTagsRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message FindPetsByTagsResponse {
|
message FindPetsByTagsResponse {
|
||||||
repeated Pet data = 1;
|
oneof response {
|
||||||
|
Pet pet_200 = 1;
|
||||||
|
google.protobuf.Empty empty_400 = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetPetByIdRequest {
|
message GetPetByIdRequest {
|
||||||
// ID of pet to return
|
// ID of pet to return
|
||||||
int64 pet_id = 1;
|
int64 pet_id = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GetPetByIdResponse {
|
||||||
|
oneof response {
|
||||||
|
Pet pet_200 = 1;
|
||||||
|
google.protobuf.Empty empty_400 = 2;
|
||||||
|
google.protobuf.Empty empty_404 = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
message UpdatePetRequest {
|
message UpdatePetRequest {
|
||||||
// Pet object that needs to be added to the store
|
// Pet object that needs to be added to the store
|
||||||
Pet pet = 1;
|
Pet pet = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message UpdatePetResponse {
|
||||||
|
oneof response {
|
||||||
|
Pet pet_200 = 1;
|
||||||
|
Error error_400 = 2;
|
||||||
|
Error error_404 = 3;
|
||||||
|
Error error_405 = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
message UpdatePetWithFormRequest {
|
message UpdatePetWithFormRequest {
|
||||||
// ID of pet that needs to be updated
|
// ID of pet that needs to be updated
|
||||||
int64 pet_id = 1;
|
int64 pet_id = 1;
|
||||||
@ -90,6 +121,11 @@ message UpdatePetWithFormRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message UpdatePetWithFormResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_405 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
message UploadFileRequest {
|
message UploadFileRequest {
|
||||||
// ID of pet to update
|
// ID of pet to update
|
||||||
int64 pet_id = 1;
|
int64 pet_id = 1;
|
||||||
@ -100,3 +136,8 @@ message UploadFileRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message UploadFileResponse {
|
||||||
|
oneof response {
|
||||||
|
ApiResponse api_response_200 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,13 +16,13 @@ import "google/protobuf/empty.proto";
|
|||||||
import public "models/order.proto";
|
import public "models/order.proto";
|
||||||
|
|
||||||
service StoreService {
|
service StoreService {
|
||||||
rpc DeleteOrder (DeleteOrderRequest) returns (google.protobuf.Empty);
|
rpc DeleteOrder (DeleteOrderRequest) returns (DeleteOrderResponse);
|
||||||
|
|
||||||
rpc GetInventory (google.protobuf.Empty) returns (GetInventoryResponse);
|
rpc GetInventory (google.protobuf.Empty) returns (GetInventoryResponse);
|
||||||
|
|
||||||
rpc GetOrderById (GetOrderByIdRequest) returns (Order);
|
rpc GetOrderById (GetOrderByIdRequest) returns (GetOrderByIdResponse);
|
||||||
|
|
||||||
rpc PlaceOrder (PlaceOrderRequest) returns (Order);
|
rpc PlaceOrder (PlaceOrderRequest) returns (PlaceOrderResponse);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,19 +32,39 @@ message DeleteOrderRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetInventoryResponse {
|
message DeleteOrderResponse {
|
||||||
int32 data = 1;
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_400 = 1;
|
||||||
|
google.protobuf.Empty empty_404 = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message GetInventoryResponse {
|
||||||
|
oneof response {
|
||||||
|
int32 int32_200 = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetOrderByIdRequest {
|
message GetOrderByIdRequest {
|
||||||
// ID of pet that needs to be fetched
|
// ID of pet that needs to be fetched
|
||||||
int64 order_id = 1;
|
int64 order_id = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GetOrderByIdResponse {
|
||||||
|
oneof response {
|
||||||
|
Order order_200 = 1;
|
||||||
|
google.protobuf.Empty empty_400 = 2;
|
||||||
|
google.protobuf.Empty empty_404 = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
message PlaceOrderRequest {
|
message PlaceOrderRequest {
|
||||||
// order placed for purchasing the pet
|
// order placed for purchasing the pet
|
||||||
Order order = 1;
|
Order order = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message PlaceOrderResponse {
|
||||||
|
oneof response {
|
||||||
|
Order order_200 = 1;
|
||||||
|
google.protobuf.Empty empty_400 = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,21 +16,21 @@ import "google/protobuf/empty.proto";
|
|||||||
import public "models/user.proto";
|
import public "models/user.proto";
|
||||||
|
|
||||||
service UserService {
|
service UserService {
|
||||||
rpc CreateUser (CreateUserRequest) returns (google.protobuf.Empty);
|
rpc CreateUser (CreateUserRequest) returns (CreateUserResponse);
|
||||||
|
|
||||||
rpc CreateUsersWithArrayInput (CreateUsersWithArrayInputRequest) returns (google.protobuf.Empty);
|
rpc CreateUsersWithArrayInput (CreateUsersWithArrayInputRequest) returns (CreateUsersWithArrayInputResponse);
|
||||||
|
|
||||||
rpc CreateUsersWithListInput (CreateUsersWithListInputRequest) returns (google.protobuf.Empty);
|
rpc CreateUsersWithListInput (CreateUsersWithListInputRequest) returns (CreateUsersWithListInputResponse);
|
||||||
|
|
||||||
rpc DeleteUser (DeleteUserRequest) returns (google.protobuf.Empty);
|
rpc DeleteUser (DeleteUserRequest) returns (DeleteUserResponse);
|
||||||
|
|
||||||
rpc GetUserByName (GetUserByNameRequest) returns (User);
|
rpc GetUserByName (GetUserByNameRequest) returns (GetUserByNameResponse);
|
||||||
|
|
||||||
rpc LoginUser (LoginUserRequest) returns (LoginUserResponse);
|
rpc LoginUser (LoginUserRequest) returns (LoginUserResponse);
|
||||||
|
|
||||||
rpc LogoutUser (google.protobuf.Empty) returns (google.protobuf.Empty);
|
rpc LogoutUser (google.protobuf.Empty) returns (LogoutUserResponse);
|
||||||
|
|
||||||
rpc UpdateUser (UpdateUserRequest) returns (google.protobuf.Empty);
|
rpc UpdateUser (UpdateUserRequest) returns (UpdateUserResponse);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,30 +40,58 @@ message CreateUserRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message CreateUserResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_0 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
message CreateUsersWithArrayInputRequest {
|
message CreateUsersWithArrayInputRequest {
|
||||||
// List of user object
|
// List of user object
|
||||||
repeated User user = 1;
|
repeated User user = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message CreateUsersWithArrayInputResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_0 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
message CreateUsersWithListInputRequest {
|
message CreateUsersWithListInputRequest {
|
||||||
// List of user object
|
// List of user object
|
||||||
repeated User user = 1;
|
repeated User user = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message CreateUsersWithListInputResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_0 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
message DeleteUserRequest {
|
message DeleteUserRequest {
|
||||||
// The name that needs to be deleted
|
// The name that needs to be deleted
|
||||||
string username = 1;
|
string username = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message DeleteUserResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_400 = 1;
|
||||||
|
google.protobuf.Empty empty_404 = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
message GetUserByNameRequest {
|
message GetUserByNameRequest {
|
||||||
// The name that needs to be fetched. Use user1 for testing.
|
// The name that needs to be fetched. Use user1 for testing.
|
||||||
string username = 1;
|
string username = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GetUserByNameResponse {
|
||||||
|
oneof response {
|
||||||
|
User user_200 = 1;
|
||||||
|
google.protobuf.Empty empty_400 = 2;
|
||||||
|
google.protobuf.Empty empty_404 = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
message LoginUserRequest {
|
message LoginUserRequest {
|
||||||
// The user name for login
|
// The user name for login
|
||||||
string username = 1;
|
string username = 1;
|
||||||
@ -73,9 +101,16 @@ message LoginUserRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message LoginUserResponse {
|
message LoginUserResponse {
|
||||||
string data = 1;
|
oneof response {
|
||||||
|
string string_200 = 1;
|
||||||
|
google.protobuf.Empty empty_400 = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message LogoutUserResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_0 = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message UpdateUserRequest {
|
message UpdateUserRequest {
|
||||||
// name that need to be deleted
|
// name that need to be deleted
|
||||||
string username = 1;
|
string username = 1;
|
||||||
@ -84,3 +119,9 @@ message UpdateUserRequest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message UpdateUserResponse {
|
||||||
|
oneof response {
|
||||||
|
google.protobuf.Empty empty_400 = 1;
|
||||||
|
google.protobuf.Empty empty_404 = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user