-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add custom trait PaginationTruncationMember #625
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1571d50
add custom trait PaginationTruncationMember
dayaffe f1f9241
lint, add newline
dayaffe 932d1c1
Merge branch 'main' into day/terminate-list-parts
dayaffe 8e68b9f
remove initializing optional variable
dayaffe 9b9b0e6
Merge branch 'main' into day/terminate-list-parts
dayaffe 25d25d8
add back isTruncatedKey
dayaffe b7bd8f4
add back isTruncatedKey to init
dayaffe 4330a4a
change Output to OperationStackOutput
dayaffe a820826
remove trailing whitespace
dayaffe a7dc0c9
remove code duplication
dayaffe 895b4a1
remove unnecessary type specification
dayaffe 586b05b
update tests
dayaffe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than an if-else for the entire return statement, can we construct a smaller string for the
isTruncatedKey:
param that is different whether or not theisTruncated
flag is set?This would save a lot of duplication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah I tried that approach at first with StringBuilder and then reverted when it caused errors, Ill try again