Skip to content

Commit

Permalink
Merge pull request #245 from disneystreaming/proto-fixes
Browse files Browse the repository at this point in the history
Fixes protoTimestampFormat not being considered when applied on union members
  • Loading branch information
Baccata authored May 30, 2024
2 parents 0a904c3 + 2113caa commit 910db26
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
4 changes: 2 additions & 2 deletions buildDeps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mill.define._
import mill.scalalib._

object alloy {
val alloyVersion = "0.3.4"
val alloyVersion = "0.3.9"
val core =
ivy"com.disneystreaming.alloy:alloy-core:$alloyVersion"
val protobuf =
Expand All @@ -25,7 +25,7 @@ object swagger {
)
}
object smithy {
val smithyVersion = "1.41.1"
val smithyVersion = "1.49.0"
val model = ivy"software.amazon.smithy:smithy-model:$smithyVersion"
val build = ivy"software.amazon.smithy:smithy-build:$smithyVersion"
val diff = ivy"software.amazon.smithy:smithy-diff:$smithyVersion"
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi/tests/resources/issue-23.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"paths": {
"/Testers/{id}": {
"/Testers/{id_}": {
"get": {
"tags": ["Testers"],
"summary": "Testers_GetTest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,16 @@ private[proto3] class Compiler(model: Model, allShapes: Boolean) {
val isMap = targetShape.isMapShape()
memberHasWrapped || targetHasWrapped || isList || isMap
}
val maybeTimestampFormat = extractTimestampFormat(m)
val fieldType =
targetShape
.accept(typeVisitor(isWrapped = isWrapped, numType))
.accept(
typeVisitor(
isWrapped = isWrapped,
numType,
maybeTimestampFormat
)
)
.get
val isDeprecated = m.hasTrait(classOf[DeprecatedTrait])
Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,36 @@ class CompilerRendererSuite extends FunSuite {
convertCheck(source, Map("com/example/example.proto" -> expected))
}

test("top level - union with timestamp formats") {
val source = """|namespace com.example
|
|use alloy.proto#protoTimestampFormat
|
|union MyUnion {
| one: Timestamp
| @protoTimestampFormat("EPOCH_MILLIS")
| two: Timestamp
|}
|""".stripMargin

val expected = """|syntax = "proto3";
|
|package com.example;
|
|import "google/protobuf/timestamp.proto";
|
|import "alloy/protobuf/types.proto";
|
|message MyUnion {
| oneof definition {
| google.protobuf.Timestamp one = 1;
| alloy.protobuf.EpochMillisTimestamp two = 2;
| }
|}
|""".stripMargin
convertCheck(source, Map("com/example/example.proto" -> expected))
}

test("@protoInlinedOneOf union - used within only one data structure") {
val source = """|namespace com.example
|
Expand Down

0 comments on commit 910db26

Please sign in to comment.