Skip to content

Commit b4b6b8c

Browse files
authored
feat: add isStreaming function and additional comment strings (#784)
1 parent 941cfe3 commit b4b6b8c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Sources/SmithyHTTPAPI/HTTPResponse.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ public class HTTPResponse: HTTPURLResponse, ResponseMessage {
4646
self._statusCode = statusCode
4747
self.headers = headers
4848
}
49+
50+
/**
51+
* Replace the response body
52+
*/
53+
public func copy(
54+
headers: Headers? = nil,
55+
body: ByteStream? = nil,
56+
statusCode: HTTPStatusCode? = nil,
57+
reason: String? = nil
58+
) -> HTTPResponse {
59+
return HTTPResponse(
60+
headers: headers ?? self.headers,
61+
body: body ?? self.body,
62+
statusCode: statusCode ?? self.statusCode,
63+
reason: reason ?? self.reason
64+
)
65+
}
4966
}
5067

5168
extension HTTPResponse: CustomDebugStringConvertible {

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/model/ShapeExt.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,30 @@ fun ServiceShape.hasIdempotentTokenMember(model: Model) =
6363
val Shape.isDeprecated: Boolean
6464
get() = hasTrait<DeprecatedTrait>()
6565

66+
/**
67+
* Test if a shape represents a string enumeration shape
68+
*/
6669
val Shape.isEnum: Boolean
6770
get() = isStringShape && hasTrait<EnumTrait>()
6871

72+
/**
73+
* Test if a shape is an error.
74+
*/
6975
val Shape.isError: Boolean
7076
get() = hasTrait<ErrorTrait>()
7177

78+
/**
79+
* Test if a shape represents a Kotlin number type
80+
*/
7281
val Shape.isNumberShape: Boolean
7382
get() = this is NumberShape
7483

84+
/**
85+
* Test if a shape has the streaming trait applied.
86+
*/
87+
val Shape.isStreaming: Boolean
88+
get() = hasTrait<StreamingTrait>()
89+
7590
fun Shape.toUpperCamelCase(): String {
7691
return this.id.name.toUpperCamelCase()
7792
}

0 commit comments

Comments
 (0)