Skip to content

Commit

Permalink
Remove allowing true for annotation traits
Browse files Browse the repository at this point in the history
This commit removes the support for setting annotation traits to true
because the previous rationale for supporting that no longer holds true.
The previous rationale was that supporting `true` makes writing the AST
JSON files easier. However, we've already crossed the point where we
don't want humans writing the JSON AST, and we want it to be as easy to
parse as possible.

The AST format now requires that `{}` is provided for annotation traits.
The IDL no longer supports setting a trait to `true` or `null`, as that
was only supported in order to provide isomorphism with the AST support.
We previously didn't persist which model format a pending trait
definition came from, so it was necessary to give them the same feature
set. However, now the Smithy loader maintains a boolean value that tells
the loader whether or not a value is an "annotation", meaning trait with
no value. This isn't a feature used in the AST loader, but is used in
the IDL loader.

Further, the BooleanTrait abstract class was renamed to AnnotationTrait.
This is something I wanted to do for a long time, but never did since it
would cause so much churn, and the name wasn't that far off from what it
represents. However, now that `true` isn't supported for annotation
traits, the name BooleanTrait makes no sense. This commit renames it and
takes the BC hit because it's now worth it.
  • Loading branch information
mtdowling committed Apr 17, 2020
1 parent 2106393 commit c40a385
Show file tree
Hide file tree
Showing 186 changed files with 857 additions and 853 deletions.
2 changes: 1 addition & 1 deletion docs/source/spec/aws/amazon-apigateway.rst
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ operation within the service.
"type": "service",
"version": "2018-03-17",
"traits": {
"aws.protocols#restJson1": true,
"aws.protocols#restJson1": {},
"aws.auth#sigv4": {
"name": "weather"
},
Expand Down
4 changes: 2 additions & 2 deletions docs/source/spec/aws/aws-auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Trait value
"type": "service",
"version": "2018-03-17",
"traits": {
"aws.protocols#restJson1": true,
"aws.protocols#restJson1": {},
"aws.api#service": {
"sdkId": "Some Value"
},
Expand Down Expand Up @@ -127,7 +127,7 @@ operation MUST NOT be used as part of the request signature calculation:
"target": "smithy.example#PutThingsOutput"
},
"traits": {
"aws.auth#unsignedPayload": true
"aws.auth#unsignedPayload": {}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions docs/source/spec/aws/aws-core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ plane unless an operation or resource is marked with the
"target": "smithy.example#PutThingsOutput"
},
"traits": {
"aws.api#controlPlane": true
"aws.api#controlPlane": {}
}
}
}
Expand Down Expand Up @@ -827,7 +827,7 @@ plane unless an operation or resource is marked with the
"target": "smithy.example#PutThingsOutput"
},
"traits": {
"aws.api#dataPlane": true
"aws.api#dataPlane": {}
}
}
}
Expand Down Expand Up @@ -1111,8 +1111,8 @@ using an ``clientEndpointDiscoveryId``.
"Id": {
"target": "smithy.api#String",
"traits": {
"aws.api#clientEndpointDiscoveryId": true,
"smithy.api#required": true
"aws.api#clientEndpointDiscoveryId": {},
"smithy.api#required": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec/aws/aws-ec2-query-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Value type
"type": "service",
"version": "2020-02-05",
"traits": {
"aws.protocols#ec2Query": true
"aws.protocols#ec2Query": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec/aws/aws-iam.rst
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ condition key inference disabled.
}
},
"traits": {
"aws.iam#disableConditionKeyInference": true
"aws.iam#disableConditionKeyInference": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec/aws/aws-json-1_0-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ See
"type": "service",
"version": "2020-02-05",
"traits": {
"aws.protocols#awsJson1_0": true
"aws.protocols#awsJson1_0": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec/aws/aws-json-1_1-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ See
"type": "service",
"version": "2020-02-05",
"traits": {
"aws.protocols#awsJson1_1": true
"aws.protocols#awsJson1_1": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec/aws/aws-query-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ See
"type": "service",
"version": "2020-02-05",
"traits": {
"aws.protocols#awsQuery": true
"aws.protocols#awsQuery": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec/aws/aws-restjson1-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ The following example defines a service that uses ``aws.protocols#restJson1``.
"type": "service",
"version": "2020-04-02",
"traits": {
"aws.protocols#restJson1": true
"aws.protocols#restJson1": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec/aws/aws-restxml-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ See
"type": "service",
"version": "2020-02-05",
"traits": {
"aws.protocols#restXml": true
"aws.protocols#restXml": {}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/source/spec/core/auth-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ The following example defines two operations:
}
],
"traits": {
"smithy.api#httpBasicAuth": true,
"smithy.api#httpDigestAuth": true,
"smithy.api#httpBasicAuth": {},
"smithy.api#httpDigestAuth": {},
"smithy.api#auth": [
"smithy.api#httpBasicAuth"
]
Expand Down
16 changes: 8 additions & 8 deletions docs/source/spec/core/behavior-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ explicitly on the operation.
"target": "smithy.example#GetFoosOutput"
},
"traits": {
"smithy.api#readonly": true,
"smithy.api#collection": true,
"smithy.api#readonly": {},
"smithy.api#collection": {},
"smithy.api#paginated": {
"inputToken": "nextToken",
"outputToken": "nextToken",
Expand Down Expand Up @@ -307,7 +307,7 @@ explicitly on the operation.
"foos": {
"target": "smithy.example#StringList",
"traits": {
"smithy.api#required": true
"smithy.api#required": {}
}
}
}
Expand Down Expand Up @@ -373,8 +373,8 @@ settings from a service.
"target": "smithy.example#GetFoosOutput"
},
"traits": {
"smithy.api#readonly": true,
"smithy.api#collection": true,
"smithy.api#readonly": {},
"smithy.api#collection": {},
"smithy.api#paginated": {
"items": "foos"
}
Expand Down Expand Up @@ -445,7 +445,7 @@ wrapper where the output token and items are referenced by paths.
"target": "smithy.example#GetFoosOutput"
},
"traits": {
"smithy.api#readonly": true,
"smithy.api#readonly": {},
"smithy.api#paginated": {
"inputToken": "nextToken",
"outputToken": "result.nextToken",
Expand All @@ -471,7 +471,7 @@ wrapper where the output token and items are referenced by paths.
"result": {
"target": "smithy.example#ResultWrapper",
"traits": {
"smithy.api#required": true
"smithy.api#required": {}
}
}
}
Expand All @@ -485,7 +485,7 @@ wrapper where the output token and items are referenced by paths.
"foos": {
"target": "smithy.example#StringList",
"traits": {
"smithy.api#required": true
"smithy.api#required": {}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/source/spec/core/constraint-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ contain a valid shape ID that targets an integer shape in the model.
"smithy.example#integerRef": {
"type": "string",
"traits": {
"smithy.api#trait": true,
"smithy.api#trait": {},
"smithy.api#idRef": {
"failWhenMissing": true,
"selector": "integer"
Expand Down Expand Up @@ -547,7 +547,7 @@ in a response.
"foo": {
"target": "smithy.example#FooString",
"traits": {
"smithy.api#required": true
"smithy.api#required": {}
}
}
}
Expand Down Expand Up @@ -591,7 +591,7 @@ Value type
"target": "smithy.api#String"
},
"traits": {
"smithy.api#uniqueItems": true
"smithy.api#uniqueItems": {}
}
}
}
Expand Down
36 changes: 18 additions & 18 deletions docs/source/spec/core/endpoint-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The following example defines an operation that uses a custom endpoint:
"target": "smithy.example#GetStatusOutput"
},
"traits": {
"smithy.api#readonly": true,
"smithy.api#readonly": {},
"smithy.api#endpoint": {
"hostPrefix": "{foo}.data."
}
Expand All @@ -91,8 +91,8 @@ The following example defines an operation that uses a custom endpoint:
"foo": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": true,
"smithy.api#hostLabel": true
"smithy.api#required": {},
"smithy.api#hostLabel": {}
}
}
}
Expand Down Expand Up @@ -145,7 +145,7 @@ Given the following operation,
"target": "smithy.example#GetStatusOutput"
},
"traits": {
"smithy.api#readonly": true,
"smithy.api#readonly": {},
"smithy.api#endpoint": {
"hostPrefix": "{foo}.data."
}
Expand All @@ -157,8 +157,8 @@ Given the following operation,
"foo": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": true,
"smithy.api#hostLabel": true
"smithy.api#required": {},
"smithy.api#hostLabel": {}
}
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ Given the following operation,
"target": "smithy.example#GetStatusOutput"
},
"traits": {
"smithy.api#readonly": true,
"smithy.api#readonly": {},
"smithy.api#endpoint": {
"hostPrefix": "{foo}-{bar}.data."
}
Expand All @@ -226,15 +226,15 @@ Given the following operation,
"foo": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": true,
"smithy.api#hostLabel": true
"smithy.api#required": {},
"smithy.api#hostLabel": {}
}
},
"bar": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": true,
"smithy.api#hostLabel": true
"smithy.api#required": {},
"smithy.api#hostLabel": {}
}
}
}
Expand Down Expand Up @@ -279,7 +279,7 @@ invalid because the ``{foo}`` and ``{bar}`` labels are adjacent:
"target": "smithy.example#GetStatusOutput"
},
"traits": {
"smithy.api#readonly": true,
"smithy.api#readonly": {},
"smithy.api#endpoint": {
"hostPrefix": "{foo}{bar}.data."
}
Expand Down Expand Up @@ -347,7 +347,7 @@ Given the following operation,
"target": "smithy.example#GetStatusOutput"
},
"traits": {
"smithy.api#readonly": true,
"smithy.api#readonly": {},
"smithy.api#endpoint": {
"hostPrefix": "{foo}.data."
},
Expand All @@ -363,8 +363,8 @@ Given the following operation,
"foo": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": true,
"smithy.api#hostLabel": true,
"smithy.api#required": {},
"smithy.api#hostLabel": {},
"smithy.api#httpHeader": "X-Foo"
}
}
Expand Down Expand Up @@ -438,7 +438,7 @@ to an operation marked with the :ref:`endpoint-trait` will be ignored.
"target": "smithy.example#GetStatusOutput"
},
"traits": {
"smithy.api#readonly": true,
"smithy.api#readonly": {},
"smithy.api#endpoint": {
"hostPrefix": "{foo}.data."
}
Expand All @@ -450,8 +450,8 @@ to an operation marked with the :ref:`endpoint-trait` will be ignored.
"foo": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": true,
"smithy.api#hostLabel": true
"smithy.api#required": {},
"smithy.api#hostLabel": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec/core/http-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ and HTTP bindings:
"messages": {
"target": "smithy.example#MessageStream",
"traits": {
"smithy.api#httpPayload": true
"smithy.api#httpPayload": {}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/source/spec/core/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ syntax, similar to:
"foo": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": true
"smithy.api#required": {}
}
},
"baz": {
"target": "smithy.api#Integer",
"traits": {
"smithy.api#deprecated": true
"smithy.api#deprecated": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/spec/core/json-ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ member:
"stringMember": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": true
"smithy.api#required": {}
}
},
"numberMember": {
Expand Down
4 changes: 2 additions & 2 deletions docs/source/spec/core/protocol-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ The following example defines a service that supports both the hypothetical
"type": "service",
"version": "2017-02-11",
"traits": {
"smithy.example#jsonExample": true,
"smithy.example#xmlExample": true
"smithy.example#jsonExample": {},
"smithy.example#xmlExample": {}
}
},
"smithy.example#jsonExample": {
Expand Down
4 changes: 2 additions & 2 deletions docs/source/spec/core/resource-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ to call ``CreateTable`` on a table that already exists will return an error.
"target": "smithy.example#CreateTable"
},
"traits": {
"smithy.api#noReplace": true
"smithy.api#noReplace": {}
}
},
"smithy.example#CreateTable": {
"type": "operation",
"traits": {
"smithy.api#idempotent": true
"smithy.api#idempotent": {}
}
}
}
Expand Down
Loading

0 comments on commit c40a385

Please sign in to comment.