Skip to content

Commit

Permalink
Merge pull request #1272 from disneystreaming/explicit-type-annotations
Browse files Browse the repository at this point in the history
Render more explicit type annotations
  • Loading branch information
Baccata authored Oct 23, 2023
2 parents 59c8a14 + df840e2 commit b35e401
Show file tree
Hide file tree
Showing 34 changed files with 300 additions and 293 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

* Fixing AwsInstanceMetadata codec in [#1266](https://github.com/disneystreaming/smithy4s/pull/1266)

Resolves an issue in which AWS credentials would be decoded using the wrong timestamp format, affecting AWS clients on EC2/ECS.

* Render explicit type annotations for some methods that were missing them in [#1272](https://github.com/disneystreaming/smithy4s/pull/1272)

This resolves a problem in which type inference would have different results between Scala 2.13 and 3.x, causing an error on Scala 2.13 under the `-Xsource:3` flag.

# 0.18.2

## Expose UrlForm.parse and UrlFormDecodeError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,32 +103,32 @@ sealed trait DynamoDBOperation[Input, Err, Output, StreamedInput, StreamedOutput
object DynamoDBOperation {

object reified extends DynamoDBGen[DynamoDBOperation] {
def describeEndpoints() = DescribeEndpoints(DescribeEndpointsRequest())
def listTables(exclusiveStartTableName: Option[TableName] = None, limit: Option[ListTablesInputLimit] = None) = ListTables(ListTablesInput(exclusiveStartTableName, limit))
def describeEndpoints(): DescribeEndpoints = DescribeEndpoints(DescribeEndpointsRequest())
def listTables(exclusiveStartTableName: Option[TableName] = None, limit: Option[ListTablesInputLimit] = None): ListTables = ListTables(ListTablesInput(exclusiveStartTableName, limit))
}
class Transformed[P[_, _, _, _, _], P1[_ ,_ ,_ ,_ ,_]](alg: DynamoDBGen[P], f: PolyFunction5[P, P1]) extends DynamoDBGen[P1] {
def describeEndpoints() = f[DescribeEndpointsRequest, Nothing, DescribeEndpointsResponse, Nothing, Nothing](alg.describeEndpoints())
def listTables(exclusiveStartTableName: Option[TableName] = None, limit: Option[ListTablesInputLimit] = None) = f[ListTablesInput, DynamoDBOperation.ListTablesError, ListTablesOutput, Nothing, Nothing](alg.listTables(exclusiveStartTableName, limit))
def describeEndpoints(): P1[DescribeEndpointsRequest, Nothing, DescribeEndpointsResponse, Nothing, Nothing] = f[DescribeEndpointsRequest, Nothing, DescribeEndpointsResponse, Nothing, Nothing](alg.describeEndpoints())
def listTables(exclusiveStartTableName: Option[TableName] = None, limit: Option[ListTablesInputLimit] = None): P1[ListTablesInput, DynamoDBOperation.ListTablesError, ListTablesOutput, Nothing, Nothing] = f[ListTablesInput, DynamoDBOperation.ListTablesError, ListTablesOutput, Nothing, Nothing](alg.listTables(exclusiveStartTableName, limit))
}

def toPolyFunction[P[_, _, _, _, _]](impl: DynamoDBGen[P]): PolyFunction5[DynamoDBOperation, P] = new PolyFunction5[DynamoDBOperation, P] {
def apply[I, E, O, SI, SO](op: DynamoDBOperation[I, E, O, SI, SO]): P[I, E, O, SI, SO] = op.run(impl)
}
final case class DescribeEndpoints(input: DescribeEndpointsRequest) extends DynamoDBOperation[DescribeEndpointsRequest, Nothing, DescribeEndpointsResponse, Nothing, Nothing] {
def run[F[_, _, _, _, _]](impl: DynamoDBGen[F]): F[DescribeEndpointsRequest, Nothing, DescribeEndpointsResponse, Nothing, Nothing] = impl.describeEndpoints()
def ordinal = 0
def ordinal: Int = 0
def endpoint: smithy4s.Endpoint[DynamoDBOperation,DescribeEndpointsRequest, Nothing, DescribeEndpointsResponse, Nothing, Nothing] = DescribeEndpoints
}
object DescribeEndpoints extends smithy4s.Endpoint[DynamoDBOperation,DescribeEndpointsRequest, Nothing, DescribeEndpointsResponse, Nothing, Nothing] {
val schema: OperationSchema[DescribeEndpointsRequest, Nothing, DescribeEndpointsResponse, Nothing, Nothing] = Schema.operation(ShapeId("com.amazonaws.dynamodb", "DescribeEndpoints"))
.withInput(DescribeEndpointsRequest.schema.addHints(smithy4s.internals.InputOutput.Input.widen))
.withOutput(DescribeEndpointsResponse.schema.addHints(smithy4s.internals.InputOutput.Output.widen))
.withHints(smithy.api.Documentation("<p>Returns the regional endpoint information.</p>"))
def wrap(input: DescribeEndpointsRequest) = DescribeEndpoints(input)
def wrap(input: DescribeEndpointsRequest): DescribeEndpoints = DescribeEndpoints(input)
}
final case class ListTables(input: ListTablesInput) extends DynamoDBOperation[ListTablesInput, DynamoDBOperation.ListTablesError, ListTablesOutput, Nothing, Nothing] {
def run[F[_, _, _, _, _]](impl: DynamoDBGen[F]): F[ListTablesInput, DynamoDBOperation.ListTablesError, ListTablesOutput, Nothing, Nothing] = impl.listTables(input.exclusiveStartTableName, input.limit)
def ordinal = 1
def ordinal: Int = 1
def endpoint: smithy4s.Endpoint[DynamoDBOperation,ListTablesInput, DynamoDBOperation.ListTablesError, ListTablesOutput, Nothing, Nothing] = ListTables
}
object ListTables extends smithy4s.Endpoint[DynamoDBOperation,ListTablesInput, DynamoDBOperation.ListTablesError, ListTablesOutput, Nothing, Nothing] {
Expand All @@ -137,7 +137,7 @@ object DynamoDBOperation {
.withError(ListTablesError.errorSchema)
.withOutput(ListTablesOutput.schema.addHints(smithy4s.internals.InputOutput.Output.widen))
.withHints(aws.api.ClientDiscoveredEndpoint(required = false), smithy.api.Documentation("<p>Returns an array of table names associated with the current account and endpoint. The output\n from <code>ListTables</code> is paginated, with each page returning a maximum of 100 table\n names.</p>"), smithy.api.Paginated(inputToken = Some(smithy.api.NonEmptyString("ExclusiveStartTableName")), outputToken = Some(smithy.api.NonEmptyString("LastEvaluatedTableName")), items = Some(smithy.api.NonEmptyString("TableNames")), pageSize = Some(smithy.api.NonEmptyString("Limit"))))
def wrap(input: ListTablesInput) = ListTables(input)
def wrap(input: ListTablesInput): ListTables = ListTables(input)
}
sealed trait ListTablesError extends scala.Product with scala.Serializable { self =>
@inline final def widen: ListTablesError = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,40 +61,40 @@ sealed trait BenchmarkServiceOperation[Input, Err, Output, StreamedInput, Stream
object BenchmarkServiceOperation {

object reified extends BenchmarkServiceGen[BenchmarkServiceOperation] {
def createObject(key: String, bucketName: String, payload: S3Object) = CreateObject(CreateObjectInput(key, bucketName, payload))
def sendString(key: String, bucketName: String, body: String) = SendString(SendStringInput(key, bucketName, body))
def createObject(key: String, bucketName: String, payload: S3Object): CreateObject = CreateObject(CreateObjectInput(key, bucketName, payload))
def sendString(key: String, bucketName: String, body: String): SendString = SendString(SendStringInput(key, bucketName, body))
}
class Transformed[P[_, _, _, _, _], P1[_ ,_ ,_ ,_ ,_]](alg: BenchmarkServiceGen[P], f: PolyFunction5[P, P1]) extends BenchmarkServiceGen[P1] {
def createObject(key: String, bucketName: String, payload: S3Object) = f[CreateObjectInput, Nothing, Unit, Nothing, Nothing](alg.createObject(key, bucketName, payload))
def sendString(key: String, bucketName: String, body: String) = f[SendStringInput, Nothing, Unit, Nothing, Nothing](alg.sendString(key, bucketName, body))
def createObject(key: String, bucketName: String, payload: S3Object): P1[CreateObjectInput, Nothing, Unit, Nothing, Nothing] = f[CreateObjectInput, Nothing, Unit, Nothing, Nothing](alg.createObject(key, bucketName, payload))
def sendString(key: String, bucketName: String, body: String): P1[SendStringInput, Nothing, Unit, Nothing, Nothing] = f[SendStringInput, Nothing, Unit, Nothing, Nothing](alg.sendString(key, bucketName, body))
}

def toPolyFunction[P[_, _, _, _, _]](impl: BenchmarkServiceGen[P]): PolyFunction5[BenchmarkServiceOperation, P] = new PolyFunction5[BenchmarkServiceOperation, P] {
def apply[I, E, O, SI, SO](op: BenchmarkServiceOperation[I, E, O, SI, SO]): P[I, E, O, SI, SO] = op.run(impl)
}
final case class CreateObject(input: CreateObjectInput) extends BenchmarkServiceOperation[CreateObjectInput, Nothing, Unit, Nothing, Nothing] {
def run[F[_, _, _, _, _]](impl: BenchmarkServiceGen[F]): F[CreateObjectInput, Nothing, Unit, Nothing, Nothing] = impl.createObject(input.key, input.bucketName, input.payload)
def ordinal = 0
def ordinal: Int = 0
def endpoint: smithy4s.Endpoint[BenchmarkServiceOperation,CreateObjectInput, Nothing, Unit, Nothing, Nothing] = CreateObject
}
object CreateObject extends smithy4s.Endpoint[BenchmarkServiceOperation,CreateObjectInput, Nothing, Unit, Nothing, Nothing] {
val schema: OperationSchema[CreateObjectInput, Nothing, Unit, Nothing, Nothing] = Schema.operation(ShapeId("smithy4s.benchmark", "CreateObject"))
.withInput(CreateObjectInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen))
.withOutput(unit.addHints(smithy4s.internals.InputOutput.Output.widen))
.withHints(smithy.api.Http(method = smithy.api.NonEmptyString("POST"), uri = smithy.api.NonEmptyString("/complex/{bucketName}/{key}"), code = 200))
def wrap(input: CreateObjectInput) = CreateObject(input)
def wrap(input: CreateObjectInput): CreateObject = CreateObject(input)
}
final case class SendString(input: SendStringInput) extends BenchmarkServiceOperation[SendStringInput, Nothing, Unit, Nothing, Nothing] {
def run[F[_, _, _, _, _]](impl: BenchmarkServiceGen[F]): F[SendStringInput, Nothing, Unit, Nothing, Nothing] = impl.sendString(input.key, input.bucketName, input.body)
def ordinal = 1
def ordinal: Int = 1
def endpoint: smithy4s.Endpoint[BenchmarkServiceOperation,SendStringInput, Nothing, Unit, Nothing, Nothing] = SendString
}
object SendString extends smithy4s.Endpoint[BenchmarkServiceOperation,SendStringInput, Nothing, Unit, Nothing, Nothing] {
val schema: OperationSchema[SendStringInput, Nothing, Unit, Nothing, Nothing] = Schema.operation(ShapeId("smithy4s.benchmark", "SendString"))
.withInput(SendStringInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen))
.withOutput(unit.addHints(smithy4s.internals.InputOutput.Output.widen))
.withHints(smithy.api.Http(method = smithy.api.NonEmptyString("POST"), uri = smithy.api.NonEmptyString("/simple/{bucketName}/{key}"), code = 200))
def wrap(input: SendStringInput) = SendString(input)
def wrap(input: SendStringInput): SendString = SendString(input)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,26 @@ sealed trait BrandServiceOperation[Input, Err, Output, StreamedInput, StreamedOu
object BrandServiceOperation {

object reified extends BrandServiceGen[BrandServiceOperation] {
def addBrands(brands: Option[List[String]] = None) = AddBrands(AddBrandsInput(brands))
def addBrands(brands: Option[List[String]] = None): AddBrands = AddBrands(AddBrandsInput(brands))
}
class Transformed[P[_, _, _, _, _], P1[_ ,_ ,_ ,_ ,_]](alg: BrandServiceGen[P], f: PolyFunction5[P, P1]) extends BrandServiceGen[P1] {
def addBrands(brands: Option[List[String]] = None) = f[AddBrandsInput, Nothing, Unit, Nothing, Nothing](alg.addBrands(brands))
def addBrands(brands: Option[List[String]] = None): P1[AddBrandsInput, Nothing, Unit, Nothing, Nothing] = f[AddBrandsInput, Nothing, Unit, Nothing, Nothing](alg.addBrands(brands))
}

def toPolyFunction[P[_, _, _, _, _]](impl: BrandServiceGen[P]): PolyFunction5[BrandServiceOperation, P] = new PolyFunction5[BrandServiceOperation, P] {
def apply[I, E, O, SI, SO](op: BrandServiceOperation[I, E, O, SI, SO]): P[I, E, O, SI, SO] = op.run(impl)
}
final case class AddBrands(input: AddBrandsInput) extends BrandServiceOperation[AddBrandsInput, Nothing, Unit, Nothing, Nothing] {
def run[F[_, _, _, _, _]](impl: BrandServiceGen[F]): F[AddBrandsInput, Nothing, Unit, Nothing, Nothing] = impl.addBrands(input.brands)
def ordinal = 0
def ordinal: Int = 0
def endpoint: smithy4s.Endpoint[BrandServiceOperation,AddBrandsInput, Nothing, Unit, Nothing, Nothing] = AddBrands
}
object AddBrands extends smithy4s.Endpoint[BrandServiceOperation,AddBrandsInput, Nothing, Unit, Nothing, Nothing] {
val schema: OperationSchema[AddBrandsInput, Nothing, Unit, Nothing, Nothing] = Schema.operation(ShapeId("smithy4s.example", "AddBrands"))
.withInput(AddBrandsInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen))
.withOutput(unit.addHints(smithy4s.internals.InputOutput.Output.widen))
.withHints(smithy.api.Http(method = smithy.api.NonEmptyString("POST"), uri = smithy.api.NonEmptyString("/brands"), code = 200))
def wrap(input: AddBrandsInput) = AddBrands(input)
def wrap(input: AddBrandsInput): AddBrands = AddBrands(input)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ sealed trait DeprecatedServiceOperation[Input, Err, Output, StreamedInput, Strea
object DeprecatedServiceOperation {

object reified extends DeprecatedServiceGen[DeprecatedServiceOperation] {
def deprecatedOperation() = DeprecatedOperation()
def deprecatedOperation(): DeprecatedOperation = DeprecatedOperation()
}
class Transformed[P[_, _, _, _, _], P1[_ ,_ ,_ ,_ ,_]](alg: DeprecatedServiceGen[P], f: PolyFunction5[P, P1]) extends DeprecatedServiceGen[P1] {
def deprecatedOperation() = f[Unit, Nothing, Unit, Nothing, Nothing](alg.deprecatedOperation())
def deprecatedOperation(): P1[Unit, Nothing, Unit, Nothing, Nothing] = f[Unit, Nothing, Unit, Nothing, Nothing](alg.deprecatedOperation())
}

def toPolyFunction[P[_, _, _, _, _]](impl: DeprecatedServiceGen[P]): PolyFunction5[DeprecatedServiceOperation, P] = new PolyFunction5[DeprecatedServiceOperation, P] {
def apply[I, E, O, SI, SO](op: DeprecatedServiceOperation[I, E, O, SI, SO]): P[I, E, O, SI, SO] = op.run(impl)
}
final case class DeprecatedOperation() extends DeprecatedServiceOperation[Unit, Nothing, Unit, Nothing, Nothing] {
def run[F[_, _, _, _, _]](impl: DeprecatedServiceGen[F]): F[Unit, Nothing, Unit, Nothing, Nothing] = impl.deprecatedOperation()
def ordinal = 0
def ordinal: Int = 0
def input: Unit = ()
def endpoint: smithy4s.Endpoint[DeprecatedServiceOperation,Unit, Nothing, Unit, Nothing, Nothing] = DeprecatedOperation
}
Expand All @@ -83,7 +83,7 @@ object DeprecatedServiceOperation {
.withInput(unit.addHints(smithy4s.internals.InputOutput.Input.widen))
.withOutput(unit.addHints(smithy4s.internals.InputOutput.Output.widen))
.withHints(smithy.api.Deprecated(message = None, since = None))
def wrap(input: Unit) = DeprecatedOperation()
def wrap(input: Unit): DeprecatedOperation = DeprecatedOperation()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,26 @@ sealed trait DiscriminatedServiceOperation[Input, Err, Output, StreamedInput, St
object DiscriminatedServiceOperation {

object reified extends DiscriminatedServiceGen[DiscriminatedServiceOperation] {
def testDiscriminated(key: String) = TestDiscriminated(TestDiscriminatedInput(key))
def testDiscriminated(key: String): TestDiscriminated = TestDiscriminated(TestDiscriminatedInput(key))
}
class Transformed[P[_, _, _, _, _], P1[_ ,_ ,_ ,_ ,_]](alg: DiscriminatedServiceGen[P], f: PolyFunction5[P, P1]) extends DiscriminatedServiceGen[P1] {
def testDiscriminated(key: String) = f[TestDiscriminatedInput, Nothing, TestDiscriminatedOutput, Nothing, Nothing](alg.testDiscriminated(key))
def testDiscriminated(key: String): P1[TestDiscriminatedInput, Nothing, TestDiscriminatedOutput, Nothing, Nothing] = f[TestDiscriminatedInput, Nothing, TestDiscriminatedOutput, Nothing, Nothing](alg.testDiscriminated(key))
}

def toPolyFunction[P[_, _, _, _, _]](impl: DiscriminatedServiceGen[P]): PolyFunction5[DiscriminatedServiceOperation, P] = new PolyFunction5[DiscriminatedServiceOperation, P] {
def apply[I, E, O, SI, SO](op: DiscriminatedServiceOperation[I, E, O, SI, SO]): P[I, E, O, SI, SO] = op.run(impl)
}
final case class TestDiscriminated(input: TestDiscriminatedInput) extends DiscriminatedServiceOperation[TestDiscriminatedInput, Nothing, TestDiscriminatedOutput, Nothing, Nothing] {
def run[F[_, _, _, _, _]](impl: DiscriminatedServiceGen[F]): F[TestDiscriminatedInput, Nothing, TestDiscriminatedOutput, Nothing, Nothing] = impl.testDiscriminated(input.key)
def ordinal = 0
def ordinal: Int = 0
def endpoint: smithy4s.Endpoint[DiscriminatedServiceOperation,TestDiscriminatedInput, Nothing, TestDiscriminatedOutput, Nothing, Nothing] = TestDiscriminated
}
object TestDiscriminated extends smithy4s.Endpoint[DiscriminatedServiceOperation,TestDiscriminatedInput, Nothing, TestDiscriminatedOutput, Nothing, Nothing] {
val schema: OperationSchema[TestDiscriminatedInput, Nothing, TestDiscriminatedOutput, Nothing, Nothing] = Schema.operation(ShapeId("smithy4s.example", "TestDiscriminated"))
.withInput(TestDiscriminatedInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen))
.withOutput(TestDiscriminatedOutput.schema.addHints(smithy4s.internals.InputOutput.Output.widen))
.withHints(smithy.api.Http(method = smithy.api.NonEmptyString("GET"), uri = smithy.api.NonEmptyString("/test/{key}"), code = 200), smithy.api.Readonly())
def wrap(input: TestDiscriminatedInput) = TestDiscriminated(input)
def wrap(input: TestDiscriminatedInput): TestDiscriminated = TestDiscriminated(input)
}
}

Loading

0 comments on commit b35e401

Please sign in to comment.