File tree 5 files changed +19
-16
lines changed
main/kotlin/io/moia/router/proto
5 files changed +19
-16
lines changed Original file line number Diff line number Diff line change 1
- import com.google.protobuf.gradle.protobuf
2
- import com.google.protobuf.gradle.protoc
3
-
4
1
plugins {
5
- id(" com.google.protobuf" ) version " 0.8.19 "
2
+ id(" com.google.protobuf" ) version " 0.9.4 "
6
3
}
7
4
8
5
repositories {
9
6
mavenCentral()
10
7
}
11
8
9
+ val protoVersion = " 4.27.2"
10
+
12
11
dependencies {
13
12
implementation(kotlin(" stdlib" ))
14
13
implementation(kotlin(" reflect" ))
15
14
16
15
implementation(" org.slf4j:slf4j-api:2.0.13" )
17
- api(" com.google.protobuf:protobuf-java:3.25.3 " )
18
- api(" com.google.protobuf:protobuf-java-util:3.25.3 " )
16
+ api(" com.google.protobuf:protobuf-java:$protoVersion " )
17
+ api(" com.google.protobuf:protobuf-java-util:$protoVersion " )
19
18
implementation(" com.google.guava:guava:33.2.1-jre" )
20
19
api(project(" :router" ))
21
20
@@ -27,10 +26,10 @@ dependencies {
27
26
testImplementation(" com.jayway.jsonpath:json-path:2.9.0" )
28
27
}
29
28
30
-
31
29
protobuf {
30
+ // Configure the protoc executable
32
31
protoc {
33
- // The artifact spec for the Protobuf Compiler
34
- artifact = " com.google.protobuf:protoc:3.25.3 "
32
+ // Download from repositories
33
+ artifact = " com.google.protobuf:protoc:$protoVersion "
35
34
}
36
35
}
Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ import com.fasterxml.jackson.databind.JsonNode
4
4
import com.fasterxml.jackson.databind.node.ArrayNode
5
5
import com.fasterxml.jackson.databind.node.ObjectNode
6
6
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
7
- import com.google.protobuf.GeneratedMessageV3
7
+ import com.google.protobuf.GeneratedMessage
8
8
import com.google.protobuf.util.JsonFormat
9
9
10
10
object ProtoBufUtils {
11
- fun toJsonWithoutWrappers (proto : GeneratedMessageV3 ): String {
12
- val message = JsonFormat .printer().omittingInsignificantWhitespace().includingDefaultValueFields ().print (proto)
11
+ fun toJsonWithoutWrappers (proto : GeneratedMessage ): String {
12
+ val message = JsonFormat .printer().omittingInsignificantWhitespace().alwaysPrintFieldsWithNoPresence ().print (proto)
13
13
return removeWrapperObjects(message)
14
14
}
15
15
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class ProtoDeserializationHandler : DeserializationHandler {
19
19
if (input.contentType() == null ) {
20
20
false
21
21
} else {
22
- MediaType .parse(input.contentType()).let { proto.isCompatibleWith(it) || protoStructuredSuffixWildcard.isCompatibleWith(it) }
22
+ MediaType .parse(input.contentType()!! ).let { proto.isCompatibleWith(it) || protoStructuredSuffixWildcard.isCompatibleWith(it) }
23
23
}
24
24
25
25
override fun deserialize (
Original file line number Diff line number Diff line change 1
1
package io.moia.router.proto
2
2
3
3
import com.google.common.net.MediaType
4
- import com.google.protobuf.GeneratedMessageV3
4
+ import com.google.protobuf.GeneratedMessage
5
5
import io.moia.router.SerializationHandler
6
6
import isCompatibleWith
7
7
import java.util.Base64
@@ -13,13 +13,13 @@ class ProtoSerializationHandler : SerializationHandler {
13
13
override fun supports (
14
14
acceptHeader : MediaType ,
15
15
body : Any ,
16
- ): Boolean = body is GeneratedMessageV3
16
+ ): Boolean = body is GeneratedMessage
17
17
18
18
override fun serialize (
19
19
acceptHeader : MediaType ,
20
20
body : Any ,
21
21
): String {
22
- val message = body as GeneratedMessageV3
22
+ val message = body as GeneratedMessage
23
23
return if (json.isCompatibleWith(acceptHeader) || jsonStructuredSuffixWildcard.isCompatibleWith(acceptHeader)) {
24
24
ProtoBufUtils .toJsonWithoutWrappers(message)
25
25
} else {
Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ syntax = "proto3";
2
2
3
3
package io.moia.router.proto.sample ;
4
4
5
+ option java_multiple_files = false ;
6
+ option java_outer_classname = "SampleOuterClass" ;
7
+ option java_package = "io.moia.router.proto.sample" ;
8
+
5
9
import "google/protobuf/wrappers.proto" ;
6
10
7
11
message Sample {
You can’t perform that action at this time.
0 commit comments