Skip to content
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

Add support for @uniqueItems #2232

Merged
merged 3 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ let result = cache
references = ["smithy-rs#2246"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "ysaito1001"

[[smithy-rs]]
message = "The [`@uniqueItems`](https://smithy.io/2.0/spec/constraint-traits.html#uniqueitems-trait) trait on `list` shapes is now supported in server SDKs."
references = ["smithy-rs#2232", "smithy-rs#1670"]
meta = { "breaking" = false, "tada" = true, "bug" = false, "target" = "server"}
author = "david-perez"
234 changes: 90 additions & 144 deletions codegen-core/common-test-models/constraints.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -227,45 +227,36 @@ structure ConstrainedHttpBoundShapesOperationInputOutput {
// @httpHeader("X-Length-MediaType")
// lengthStringHeaderWithMediaType: MediaTypeLengthString,

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// @httpHeader("X-Length-Set")
// lengthStringSetHeader: SetOfLengthString,
@httpHeader("X-Length-Set")
lengthStringSetHeader: SetOfLengthString,

@httpHeader("X-List-Length-String")
listLengthStringHeader: ListOfLengthString,

@httpHeader("X-Length-List-Pattern-String")
lengthListPatternStringHeader: LengthListOfPatternString,

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// @httpHeader("X-Length-Set-Pattern-String")
// lengthSetPatternStringHeader: LengthSetOfPatternString,

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// @httpHeader("X-Range-Integer-Set")
// rangeIntegerSetHeader: SetOfRangeInteger,
// @httpHeader("X-Range-Short-Set")
// rangeShortSetHeader: SetOfShortInteger,
// @httpHeader("X-Range-Long-Set")
// rangeLongSetHeader: SetOfRangeLong,
// @httpHeader("X-Range-Byte-Set")
// rangeByteSetHeader: SetOfByteInteger,
@httpHeader("X-Length-Set-Pattern-String")
lengthSetPatternStringHeader: LengthSetOfPatternString,

@httpHeader("X-Range-Integer-List")
rangeIntegerListHeader: ListOfRangeInteger,
@httpHeader("X-Range-Byte-Set")
rangeByteSetHeader: SetOfRangeByte,
@httpHeader("X-Range-Short-Set")
rangeShortSetHeader: SetOfRangeShort,
@httpHeader("X-Range-Integer-Set")
rangeIntegerSetHeader: SetOfRangeInteger,
@httpHeader("X-Range-Long-Set")
rangeLongSetHeader: SetOfRangeLong,

@httpHeader("X-Range-Byte-List")
rangeByteListHeader: ListOfRangeByte,
@httpHeader("X-Range-Short-List")
rangeShortListHeader: ListOfRangeShort,

@httpHeader("X-Range-Integer-List")
rangeIntegerListHeader: ListOfRangeInteger,
@httpHeader("X-Range-Long-List")
rangeLongListHeader: ListOfRangeLong,

@httpHeader("X-Range-Byte-List")
rangeByteListHeader: ListOfRangeByte,

// TODO(https://github.com/awslabs/smithy-rs/issues/1431)
// @httpHeader("X-Enum")
//enumStringHeader: EnumString,
Expand All @@ -276,17 +267,15 @@ structure ConstrainedHttpBoundShapesOperationInputOutput {
@httpQuery("lengthString")
lengthStringQuery: LengthString,

@httpQuery("rangeInteger")
rangeIntegerQuery: RangeInteger,

@httpQuery("rangeByte")
rangeByteQuery: RangeByte,
@httpQuery("rangeShort")
rangeShortQuery: RangeShort,

@httpQuery("rangeInteger")
rangeIntegerQuery: RangeInteger,
@httpQuery("rangeLong")
rangeLongQuery: RangeLong,

@httpQuery("rangeByte")
rangeByteQuery: RangeByte,

@httpQuery("enumString")
enumStringQuery: EnumString,
Expand All @@ -297,33 +286,26 @@ structure ConstrainedHttpBoundShapesOperationInputOutput {
@httpQuery("lengthListPatternString")
lengthListPatternStringQuery: LengthListOfPatternString,

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// @httpQuery("lengthStringSet")
// lengthStringSetQuery: SetOfLengthString,

@httpQuery("rangeIntegerList")
rangeIntegerListQuery: ListOfRangeInteger,
@httpQuery("lengthStringSet")
lengthStringSetQuery: SetOfLengthString,

@httpQuery("rangeByteList")
rangeByteListQuery: ListOfRangeByte,
@httpQuery("rangeShortList")
rangeShortListQuery: ListOfRangeShort,

@httpQuery("rangeIntegerList")
rangeIntegerListQuery: ListOfRangeInteger,
@httpQuery("rangeLongList")
rangeLongListQuery: ListOfRangeLong,

@httpQuery("rangeByteList")
rangeByteListQuery: ListOfRangeByte,

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// @httpQuery("rangeIntegerSet")
// rangeIntegerSetQuery: SetOfRangeInteger,
// @httpQuery("rangeShortSet")
// rangeShortSetQuery: SetOfRangeShort,
// @httpQuery("rangeLongSet")
// rangeLongSetQuery: SetOfRangeLong,
// @httpQuery("rangeByteSet")
// rangeByteSetQuery: SetOfRangeByte,
@httpQuery("rangeByteSet")
rangeByteSetQuery: SetOfRangeByte,
@httpQuery("rangeShortSet")
rangeShortSetQuery: SetOfRangeShort,
@httpQuery("rangeIntegerSet")
rangeIntegerSetQuery: SetOfRangeInteger,
@httpQuery("rangeLongSet")
rangeLongSetQuery: SetOfRangeLong,

@httpQuery("enumStringList")
enumStringListQuery: ListOfEnumString,
Expand Down Expand Up @@ -473,9 +455,7 @@ structure ConA {
conBList: ConBList,
lengthList: LengthList,

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// conBSet: ConBSet,
conBSet: ConBSet,

conBMap: ConBMap,
lengthMap: LengthMap,
Expand All @@ -490,9 +470,7 @@ structure ConA {
enumString: EnumString,

listOfLengthString: ListOfLengthString,
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// setOfLengthString: SetOfLengthString,
setOfLengthString: SetOfLengthString,
mapOfLengthString: MapOfLengthString,

listOfLengthBlob: ListOfLengthBlob,
Expand All @@ -502,55 +480,46 @@ structure ConA {
mapOfLengthBlob: MapOfLengthBlob,

listOfRangeInteger: ListOfRangeInteger,
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// setOfRangeInteger: SetOfRangeInteger,
setOfRangeInteger: SetOfRangeInteger,
mapOfRangeInteger: MapOfRangeInteger,

listOfRangeShort: ListOfRangeShort,
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// setOfRangeShort: SetOfRangeShort,
setOfRangeShort: SetOfRangeShort,
mapOfRangeShort: MapOfRangeShort,

listOfRangeLong: ListOfRangeLong,
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// setOfRangeLong: SetOfRangeLong,
setOfRangeLong: SetOfRangeLong,
mapOfRangeLong: MapOfRangeLong,

listOfRangeByte: ListOfRangeByte,
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// setOfRangeByte: SetOfRangeByte,
setOfRangeByte: SetOfRangeByte,
mapOfRangeByte: MapOfRangeByte,

nonStreamingBlob: NonStreamingBlob

patternString: PatternString,
mapOfPatternString: MapOfPatternString,
listOfPatternString: ListOfPatternString,
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// setOfPatternString: SetOfPatternString,
setOfPatternString: SetOfPatternString,

lengthLengthPatternString: LengthPatternString,
mapOfLengthPatternString: MapOfLengthPatternString,
listOfLengthPatternString: ListOfLengthPatternString
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// setOfLengthPatternString: SetOfLengthPatternString,
setOfLengthPatternString: SetOfLengthPatternString,

lengthListOfPatternString: LengthListOfPatternString,
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// lengthSetOfPatternString: LengthSetOfPatternString,
lengthSetOfPatternString: LengthSetOfPatternString,
}

@uniqueItems
list UniqueItemsList {
member: String
}

@sparse
map SparseMap {
key: String,
value: LengthString
value: UniqueItemsList
}

@sparse
Expand Down Expand Up @@ -628,44 +597,33 @@ map MapOfListOfLengthPatternString {

map MapOfSetOfLengthString {
key: LengthString,
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// value: SetOfLengthString,
value: ListOfLengthString
value: SetOfLengthString,
}

map MapOfLengthListOfPatternString {
key: PatternString,
value: LengthListOfPatternString
}

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// map MapOfSetOfRangeInteger {
// key: String,
// value: SetOfRangeInteger,
// }

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// map MapOfSetOfRangeShort {
// key: String,
// value: SetOfRangeShort,
// }

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// map MapOfSetOfRangeLong {
// key: String,
// value: SetOfRangeLong,
// }

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// map MapOfSetOfRangeByte {
// key: String,
// value: SetOfRangeByte,
// }
map MapOfSetOfRangeInteger {
key: String,
value: SetOfRangeInteger,
}

map MapOfSetOfRangeShort {
key: String,
value: SetOfRangeShort,
}

map MapOfSetOfRangeLong {
key: String,
value: SetOfRangeLong,
}

map MapOfSetOfRangeByte {
key: String,
value: SetOfRangeByte,
}

@length(min: 2, max: 8)
list LengthListOfLengthString {
Expand Down Expand Up @@ -767,9 +725,7 @@ union ConstrainedUnion {

constrainedStructure: ConB,
conBList: ConBList,
// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// conBSet: ConBSet,
conBSet: ConBSet,
conBMap: ConBMap,
}

Expand Down Expand Up @@ -814,45 +770,37 @@ list ListOfLengthString {
member: LengthString
}

set SetOfRangeInteger {
member: RangeInteger
}

list ListOfLengthBlob {
member: LengthBlob
}

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// set SetOfRangeInteger {
// member: RangeInteger
// }

list ListOfRangeInteger {
member: RangeInteger
}

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// set SetOfRangeShort {
// member: RangeShort
// }
set SetOfRangeShort {
member: RangeShort
}

list ListOfRangeShort {
member: RangeShort
}

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// set SetOfRangeLong {
// member: RangeLong
// }
set SetOfRangeLong {
member: RangeLong
}

list ListOfRangeLong {
member: RangeLong
}

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// set SetOfRangeByte {
// member: RangeByte
// }
set SetOfRangeByte {
member: RangeByte
}

list ListOfRangeByte {
member: RangeByte
Expand Down Expand Up @@ -918,15 +866,13 @@ list LengthList {
member: String
}

// TODO(https://github.com/awslabs/smithy-rs/issues/1401): a `set` shape is
// just a `list` shape with `uniqueItems`, which hasn't been implemented yet.
// set ConBSet {
// member: ConBSetInner
// }
//
// set ConBSetInner {
// member: String
// }
set ConBSet {
member: ConBSetInner
}

set ConBSetInner {
member: String
}

map MapOfPatternString {
key: PatternString,
Expand Down
Loading