From 0b30d8422696e737787a30c6b9ac1aa4e28eeb37 Mon Sep 17 00:00:00 2001 From: xil Date: Fri, 21 Mar 2025 20:52:30 +0000 Subject: [PATCH] protobuf import format --- bin/configs/protobuf-schema-config.yaml | 6 +++++- bin/configs/protobuf-schema.yaml | 4 ++++ .../codegen/languages/ProtobufSchemaCodegen.java | 6 +++++- .../src/main/resources/protobuf-schema/api.mustache | 2 +- .../src/main/resources/protobuf-schema/model.mustache | 2 +- .../src/test/resources/3_0/protobuf/petstore.yaml | 2 ++ .../petstore/protobuf-schema-config/models/order.proto | 3 +++ samples/config/petstore/protobuf-schema/models/order.proto | 3 +++ 8 files changed, 24 insertions(+), 4 deletions(-) diff --git a/bin/configs/protobuf-schema-config.yaml b/bin/configs/protobuf-schema-config.yaml index 03df6bce30cf..44ae7540fd8a 100644 --- a/bin/configs/protobuf-schema-config.yaml +++ b/bin/configs/protobuf-schema-config.yaml @@ -7,4 +7,8 @@ additionalProperties: addJsonNameAnnotation: true numberedFieldNumberList: true startEnumsWithUnspecified: true - wrapComplexType: false \ No newline at end of file + wrapComplexType: false +typeMappings: + object: "google.protobuf.Struct" +importMappings: + google.protobuf.Struct: "google/protobuf/struct" \ No newline at end of file diff --git a/bin/configs/protobuf-schema.yaml b/bin/configs/protobuf-schema.yaml index 30f606c915f3..c3947e075dca 100644 --- a/bin/configs/protobuf-schema.yaml +++ b/bin/configs/protobuf-schema.yaml @@ -4,3 +4,7 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/protobuf/petstore.ya templateDir: modules/openapi-generator/src/main/resources/protobuf-schema additionalProperties: packageName: petstore +typeMappings: + object: "google.protobuf.Struct" +importMappings: + google.protobuf.Struct: "google/protobuf/struct" diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java index 052d1aa8321b..78938f1cacf8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java @@ -912,7 +912,11 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List