-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add custom trait PaginationTruncationMember (#625)
- Loading branch information
Showing
7 changed files
with
124 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...in/kotlin/software/amazon/smithy/swift/codegen/customtraits/PaginationTruncationMember.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package software.amazon.smithy.swift.codegen.customtraits | ||
|
||
import software.amazon.smithy.model.node.Node | ||
import software.amazon.smithy.model.node.ObjectNode | ||
import software.amazon.smithy.model.shapes.ShapeId | ||
import software.amazon.smithy.model.traits.AnnotationTrait | ||
|
||
/** | ||
* Indicates the annotated member is a truncation indicator which conveys a non-standard termination condition for | ||
* pagination. | ||
*/ | ||
class PaginationTruncationMember(node: ObjectNode) : AnnotationTrait(ID, node) { | ||
companion object { | ||
val ID: ShapeId = ShapeId.from("software.amazon.smithy.swift.codegen.synthetic#paginationTruncationMember") | ||
} | ||
|
||
constructor() : this(Node.objectNode()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
smithy-swift-codegen/src/test/resources/pagination-truncation.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
$version: "1.0" | ||
|
||
namespace software.amazon.smithy.swift.codegen.synthetic | ||
|
||
use aws.protocols#restJson1 | ||
|
||
@trait(selector: "*") | ||
structure paginationTruncationMember { } | ||
|
||
service Lambda { | ||
operations: [ListFunctionsTruncated] | ||
} | ||
|
||
list FunctionConfigurationList { | ||
member: FunctionConfiguration | ||
} | ||
|
||
structure FunctionConfiguration { | ||
functionName: String | ||
} | ||
|
||
@paginated( | ||
inputToken: "marker", | ||
outputToken: "nextMarker", | ||
pageSize: "maxItems" | ||
) | ||
@readonly | ||
@http(method: "GET", uri: "/functions/truncated", code: 200) | ||
operation ListFunctionsTruncated { | ||
input: ListFunctionsRequestTruncated, | ||
output: ListFunctionsResponseTruncated | ||
} | ||
|
||
structure ListFunctionsRequestTruncated { | ||
@httpQuery("FunctionVersion") | ||
functionVersion: String, | ||
@httpQuery("Marker") | ||
marker: String, | ||
@httpQuery("MasterRegion") | ||
masterRegion: String, | ||
@httpQuery("MaxItems") | ||
maxItems: Integer, | ||
} | ||
|
||
structure ListFunctionsResponseTruncated { | ||
Functions: FunctionConfigurationList, | ||
@paginationTruncationMember | ||
IsTruncated: Boolean, | ||
nextMarker: String | ||
} |