Skip to content

Commit

Permalink
Merge pull request #6 from kubukoz/builtin-io-hints
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Kozłowski committed Dec 23, 2021
2 parents 0f5cfea + 15ecbe5 commit 7c41458
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 24 deletions.
4 changes: 2 additions & 2 deletions modules/codegen/src/smithy4s/codegen/Renderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ private[codegen] class Renderer(compilationUnit: CompilationUnit) { self =>
s"$Endpoint_[${traitName}, ${op.renderAlgParams}]$httpEndpoint$errorable"
)(
s"""def name: String = "${opName}"""",
s"val input: $Schema_[${op.input.render}] = ${op.input.schemaRef}",
s"val output: $Schema_[${op.output.render}] = ${op.output.schemaRef}",
s"val input: $Schema_[${op.input.render}] = ${op.input.schemaRef}.withHints(smithy4s.internals.InputOutput.Input)",
s"val output: $Schema_[${op.output.render}] = ${op.output.schemaRef}.withHints(smithy4s.internals.InputOutput.Output)",
renderStreamingSchemaVal("streamedInput", op.streamedInput),
renderStreamingSchemaVal("streamedOutput", op.streamedOutput),
renderHintsVal(op.hints),
Expand Down
4 changes: 2 additions & 2 deletions modules/example/src/smithy4s/example/FooService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ object FooServiceGen extends smithy4s.Service[FooServiceGen, FooServiceOperation
case class GetFoo() extends FooServiceOperation[Unit, Nothing, GetFooOutput, Nothing, Nothing]
object GetFoo extends smithy4s.Endpoint[FooServiceOperation, Unit, Nothing, GetFooOutput, Nothing, Nothing] with http.HttpEndpoint[Unit] {
def name: String = "GetFoo"
val input: smithy4s.Schema[Unit] = unit
val output: smithy4s.Schema[GetFooOutput] = GetFooOutput.schema
val input: smithy4s.Schema[Unit] = unit.withHints(smithy4s.internals.InputOutput.Input)
val output: smithy4s.Schema[GetFooOutput] = GetFooOutput.schema.withHints(smithy4s.internals.InputOutput.Output)
val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing
val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing
val hints : smithy4s.Hints = smithy4s.Hints(
Expand Down
8 changes: 4 additions & 4 deletions modules/example/src/smithy4s/example/ObjectService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ object ObjectServiceGen extends smithy4s.Service[ObjectServiceGen, ObjectService
case class PutObject(input: PutObjectInput) extends ObjectServiceOperation[PutObjectInput, PutObjectError, Unit, Nothing, Nothing]
object PutObject extends smithy4s.Endpoint[ObjectServiceOperation, PutObjectInput, PutObjectError, Unit, Nothing, Nothing] with http.HttpEndpoint[PutObjectInput] with smithy4s.Errorable[PutObjectError] {
def name: String = "PutObject"
val input: smithy4s.Schema[PutObjectInput] = PutObjectInput.schema
val output: smithy4s.Schema[Unit] = unit
val input: smithy4s.Schema[PutObjectInput] = PutObjectInput.schema.withHints(smithy4s.internals.InputOutput.Input)
val output: smithy4s.Schema[Unit] = unit.withHints(smithy4s.internals.InputOutput.Output)
val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing
val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing
val hints : smithy4s.Hints = smithy4s.Hints(
Expand Down Expand Up @@ -114,8 +114,8 @@ object ObjectServiceGen extends smithy4s.Service[ObjectServiceGen, ObjectService
case class GetObject(input: GetObjectInput) extends ObjectServiceOperation[GetObjectInput, GetObjectError, GetObjectOutput, Nothing, Nothing]
object GetObject extends smithy4s.Endpoint[ObjectServiceOperation, GetObjectInput, GetObjectError, GetObjectOutput, Nothing, Nothing] with http.HttpEndpoint[GetObjectInput] with smithy4s.Errorable[GetObjectError] {
def name: String = "GetObject"
val input: smithy4s.Schema[GetObjectInput] = GetObjectInput.schema
val output: smithy4s.Schema[GetObjectOutput] = GetObjectOutput.schema
val input: smithy4s.Schema[GetObjectInput] = GetObjectInput.schema.withHints(smithy4s.internals.InputOutput.Input)
val output: smithy4s.Schema[GetObjectOutput] = GetObjectOutput.schema.withHints(smithy4s.internals.InputOutput.Output)
val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing
val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing
val hints : smithy4s.Hints = smithy4s.Hints(
Expand Down
8 changes: 4 additions & 4 deletions modules/example/src/smithy4s/example/StreamedObjects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ object StreamedObjectsGen extends smithy4s.Service[StreamedObjectsGen, StreamedO
case class PutStreamedObject(input: PutStreamedObjectInput) extends StreamedObjectsOperation[PutStreamedObjectInput, Nothing, Unit, StreamedBlob, Nothing]
object PutStreamedObject extends smithy4s.Endpoint[StreamedObjectsOperation, PutStreamedObjectInput, Nothing, Unit, StreamedBlob, Nothing] {
def name: String = "PutStreamedObject"
val input: smithy4s.Schema[PutStreamedObjectInput] = PutStreamedObjectInput.schema
val output: smithy4s.Schema[Unit] = unit
val input: smithy4s.Schema[PutStreamedObjectInput] = PutStreamedObjectInput.schema.withHints(smithy4s.internals.InputOutput.Input)
val output: smithy4s.Schema[Unit] = unit.withHints(smithy4s.internals.InputOutput.Output)
val streamedInput : smithy4s.StreamingSchema[StreamedBlob] = smithy4s.StreamingSchema("PutStreamedObjectInput", StreamedBlob.schema)
val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing
val hints : smithy4s.Hints = smithy4s.Hints()
Expand All @@ -61,8 +61,8 @@ object StreamedObjectsGen extends smithy4s.Service[StreamedObjectsGen, StreamedO
case class GetStreamedObject(input: GetStreamedObjectInput) extends StreamedObjectsOperation[GetStreamedObjectInput, Nothing, GetStreamedObjectOutput, Nothing, StreamedBlob]
object GetStreamedObject extends smithy4s.Endpoint[StreamedObjectsOperation, GetStreamedObjectInput, Nothing, GetStreamedObjectOutput, Nothing, StreamedBlob] {
def name: String = "GetStreamedObject"
val input: smithy4s.Schema[GetStreamedObjectInput] = GetStreamedObjectInput.schema
val output: smithy4s.Schema[GetStreamedObjectOutput] = GetStreamedObjectOutput.schema
val input: smithy4s.Schema[GetStreamedObjectInput] = GetStreamedObjectInput.schema.withHints(smithy4s.internals.InputOutput.Input)
val output: smithy4s.Schema[GetStreamedObjectOutput] = GetStreamedObjectOutput.schema.withHints(smithy4s.internals.InputOutput.Output)
val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing
val streamedOutput : smithy4s.StreamingSchema[StreamedBlob] = smithy4s.StreamingSchema("GetStreamedObjectOutput", StreamedBlob.schema)
val hints : smithy4s.Hints = smithy4s.Hints()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import org.http4s.Uri
import org.http4s.client.Client
import schematic.OneOf
import smithy4s.http._
import smithy4s.internals.InputOutput
import smithy4s.syntax._

/**
* A construct that encapsulates interprets and a low-level
Expand Down Expand Up @@ -86,10 +84,9 @@ private[smithy4s] class SmithyHttp4sClientEndpointImpl[F[_], Op[_, _, _, _, _],

private val method: org.http4s.Method = toHttp4sMethod(httpEndpoint.method)

private val inputSchema: Schema[I] =
endpoint.input.withHints(InputOutput.Input)
private val outputSchema: Schema[O] =
endpoint.output.withHints(InputOutput.Output)
private val inputSchema: Schema[I] = endpoint.input
private val outputSchema: Schema[O] = endpoint.output

private val inputMetadataEncoder =
Metadata.Encoder.fromSchema(inputSchema)
private val inputHasBody =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import org.typelevel.ci.CIString
import schematic.OneOf
import smithy4s.http.Metadata
import smithy4s.http._
import smithy4s.internals.InputOutput
import smithy4s.syntax._

/**
* A construct that encapsulates a smithy4s endpoint, and exposes
Expand Down Expand Up @@ -101,10 +99,8 @@ private[smithy4s] class SmithyHttp4sServerEndpointImpl[F[_], Op[_, _, _, _, _],
}
}

private val inputSchema: Schema[I] =
endpoint.input.withHints(InputOutput.Input)
private val outputSchema: Schema[O] =
endpoint.output.withHints(InputOutput.Output)
private val inputSchema: Schema[I] = endpoint.input
private val outputSchema: Schema[O] = endpoint.output

private val inputMetadataDecoder =
Metadata.PartialDecoder.fromSchema(inputSchema)
Expand Down

0 comments on commit 7c41458

Please sign in to comment.