Skip to content

Commit

Permalink
function to find if operation payload is union
Browse files Browse the repository at this point in the history
  • Loading branch information
0marperez committed Nov 10, 2023
1 parent 3e649eb commit cae26c5
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ val Shape.isSparse: Boolean
val Shape.isStreaming: Boolean
get() = hasTrait<StreamingTrait>()

/**
* Returns boolean indicating if operation input is union shaped
*/
fun OperationShape.payloadIsUnionShape(model: Model): Boolean {
val requestShape = model.expectShape<StructureShape>(input.get())
val payload = requestShape.findMemberWithTrait<HttpPayloadTrait>(model)?.targetOrSelf(model)
return payload is UnionShape
}

/**
* Test if a member targets an event stream
*/
Expand Down

0 comments on commit cae26c5

Please sign in to comment.