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

Constraint trait precedence for list/map/set's members #1181

Closed
david-perez opened this issue Apr 8, 2022 · 1 comment · Fixed by #1205
Closed

Constraint trait precedence for list/map/set's members #1181

david-perez opened this issue Apr 8, 2022 · 1 comment · Fixed by #1205

Comments

@david-perez
Copy link
Contributor

The section on constraint trait precedence reads:

Some constraints can be applied to shapes as well as structure members. If a constraint of the same type is applied to a structure member and the shape that the member targets, the trait applied to the member takes precedence.

(emphasis mine)

Note that the trait selectors for constraint traits allow them to be applied to arbitrary members. For example, the range trait's selector is :test(number, member > number).

So this example model is accepted:

$version: "1.0"

namespace com.amazonaws.simple

use aws.protocols#restJson1

@restJson1
service SimpleService {
    operations: [
        AnOperation,
    ],
}

@http(uri: "/operation", method: "GET")
operation AnOperation {
    input: AnOperationInputOutput,
    output: AnOperationInputOutput,
}

structure AnOperationInputOutput {
    list: MyList
}

list MyList {
    @range(min: 5)
    member: MyInt
}

@range(min: 1, max: 10)
integer MyInt

Does trait precedence apply in the case of a list member or a map's members, like in the above example?

@mtdowling
Copy link
Member

Yeah this is just an error in the docs. It shouldn’t have the structure qualifier. It’s any member. Would you be able to send a PR to fix this?

mtdowling added a commit that referenced this issue Apr 25, 2022
Constraint traits cascade for non-structure members too.

Closes #1181
mtdowling added a commit that referenced this issue Apr 25, 2022
Constraint traits cascade for non-structure members too.

Closes #1181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants