Skip to content

Commit

Permalink
Updated smithy to 1.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Baccata committed Jan 5, 2022
1 parent 031b89b commit 7061c19
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ lazy val Dependencies = new {
)

val Smithy = new {
val smithyVersion = "1.15.0"
val smithyVersion = "1.16.0"
val model = "software.amazon.smithy" % "smithy-model" % smithyVersion
val awsTraits =
"software.amazon.smithy" % "smithy-aws-traits" % smithyVersion
Expand Down
17 changes: 9 additions & 8 deletions modules/codegen/src/smithy4s/codegen/SmithyToIR.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,20 @@ private[codegen] class SmithyToIR(model: Model, namespace: String) {
.map(model.getShape(_).asScala)
.collect { case Some(S.Operation(op)) =>
val inputType =
op.getInput().asScala.flatMap(_.tpe).getOrElse(Type.unit)
op.getInputShape().tpe.getOrElse(Type.unit)

val params =
op.getInput()
.asScala
.flatMap(_.shape)
op.getInputShape()
.shape
.toList
.flatMap(_.fields)

def streamedMember(shapeId: ShapeId) =
shapeId.shape
.map(_.members().asScala.toList)
.flatMap(_.collectFirstSome(streamingField))
val streamedInput = op.getInput().asScala.flatMap(streamedMember)
val streamedOutput = op.getOutput().asScala.flatMap(streamedMember)
val streamedInput = streamedMember(op.getInputShape())
val streamedOutput = streamedMember(op.getOutputShape())

val errorTypes = (generalErrors ++ op
.getErrors()
Expand All @@ -138,7 +137,7 @@ private[codegen] class SmithyToIR(model: Model, namespace: String) {
.toList).distinct

val outputType =
op.getOutput().asScala.flatMap(_.tpe).getOrElse(Type.unit)
op.getOutputShape().tpe.getOrElse(Type.unit)

Operation(
op.name,
Expand Down Expand Up @@ -331,7 +330,9 @@ private[codegen] class SmithyToIR(model: Model, namespace: String) {
}

def structureShape(x: StructureShape): Option[Type] =
Type.Ref(x.namespace, x.name).some
if (x.getId() == ShapeId.fromParts("smithy.api", "Unit"))
Some(Type.unit)
else Type.Ref(x.namespace, x.name).some

def unionShape(x: UnionShape): Option[Type] =
Type.Ref(x.namespace, x.name).some
Expand Down
3 changes: 3 additions & 0 deletions modules/example/resources/smithy4s.example.ObjectService.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
}
],
"responses": {
"200": {
"description": "PutObject 200 response"
},
"500": {
"description": "ServerError 500 response",
"content": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ abstract class Smithy4sAbstractRestProtocol[T <: Trait]
val result = new util.TreeMap[String, ResponseObject]
val operationIndex = OperationIndex.of(updatedModel)
operationIndex
.getOutput(operation)
.getOutputShape(operation)
.asScala
.foreach((output: StructureShape) => {
updateResponsesMapWithResponseStatusAndObject(
Expand Down

0 comments on commit 7061c19

Please sign in to comment.