Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes protoTimestampFormat not being considered when applied on union members #245

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_}": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumping alloy/smithy has had the side effect of fixing false-positive validation errors we were actually counting on to test. So I'm injecting new errors to keep the tests working.

"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
Loading