Convert enumValue to a document trait
This commit is contained in:
parent
2f9ef31249
commit
f04b6221cf
|
@ -53,16 +53,16 @@ member name. The string representation can be customized by applying the
|
|||
|
||||
```
|
||||
enum Suit {
|
||||
@enumValue(string: "diamond")
|
||||
@enumValue("diamond")
|
||||
DIAMOND
|
||||
|
||||
@enumValue(string: "club")
|
||||
@enumValue("club")
|
||||
CLUB
|
||||
|
||||
@enumValue(string: "heart")
|
||||
@enumValue("heart")
|
||||
HEART
|
||||
|
||||
@enumValue(string: "spade")
|
||||
@enumValue("spade")
|
||||
SPADE
|
||||
}
|
||||
```
|
||||
|
@ -89,16 +89,16 @@ enum Suit {
|
|||
@enumDefault
|
||||
UNKNOWN
|
||||
|
||||
@enumValue(string: "diamond")
|
||||
@enumValue("diamond")
|
||||
DIAMOND
|
||||
|
||||
@enumValue(string: "club")
|
||||
@enumValue("club")
|
||||
CLUB
|
||||
|
||||
@enumValue(string: "heart")
|
||||
@enumValue("heart")
|
||||
HEART
|
||||
|
||||
@enumValue(string: "spade")
|
||||
@enumValue("spade")
|
||||
SPADE
|
||||
}
|
||||
```
|
||||
|
@ -133,19 +133,19 @@ integer value. The following example defines an intEnum shape:
|
|||
|
||||
```
|
||||
intEnum FaceCard {
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
JACK
|
||||
|
||||
@enumValue(int: 2)
|
||||
@enumValue(2)
|
||||
QUEEN
|
||||
|
||||
@enumValue(int: 3)
|
||||
@enumValue(3)
|
||||
KING
|
||||
|
||||
@enumValue(int: 4)
|
||||
@enumValue(4)
|
||||
ACE
|
||||
|
||||
@enumValue(int: 5)
|
||||
@enumValue(5)
|
||||
JOKER
|
||||
}
|
||||
```
|
||||
|
@ -170,19 +170,19 @@ intEnum FaceCard {
|
|||
@enumDefault
|
||||
UNKNOWN
|
||||
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
JACK
|
||||
|
||||
@enumValue(int: 2)
|
||||
@enumValue(2)
|
||||
QUEEN
|
||||
|
||||
@enumValue(int: 3)
|
||||
@enumValue(3)
|
||||
KING
|
||||
|
||||
@enumValue(int: 4)
|
||||
@enumValue(4)
|
||||
ACE
|
||||
|
||||
@enumValue(int: 5)
|
||||
@enumValue(5)
|
||||
JOKER
|
||||
}
|
||||
```
|
||||
|
|
|
@ -221,33 +221,25 @@
|
|||
"AWS": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "aws"
|
||||
}
|
||||
"smithy.api#enumValue": "aws"
|
||||
}
|
||||
},
|
||||
"AWS_PROXY": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "aws_proxy"
|
||||
}
|
||||
"smithy.api#enumValue": "aws_proxy"
|
||||
}
|
||||
},
|
||||
"HTTP": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "http"
|
||||
}
|
||||
"smithy.api#enumValue": "http"
|
||||
}
|
||||
},
|
||||
"HTTP_PROXY": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "http_proxy"
|
||||
}
|
||||
"smithy.api#enumValue": "http_proxy"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -302,17 +294,13 @@
|
|||
"INTERNET": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "INTERNET"
|
||||
}
|
||||
"smithy.api#enumValue": "INTERNET"
|
||||
}
|
||||
},
|
||||
"VPC_LINK": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "VPC_LINK"
|
||||
}
|
||||
"smithy.api#enumValue": "VPC_LINK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -323,25 +311,19 @@
|
|||
"WHEN_NO_TEMPLATES": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "when_no_templates"
|
||||
}
|
||||
"smithy.api#enumValue": "when_no_templates"
|
||||
}
|
||||
},
|
||||
"WHEN_NO_MATCH": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "when_no_match"
|
||||
}
|
||||
"smithy.api#enumValue": "when_no_match"
|
||||
}
|
||||
},
|
||||
"NEVER": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "never"
|
||||
}
|
||||
"smithy.api#enumValue": "never"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -356,17 +338,13 @@
|
|||
"CONVERT_TO_TEXT": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "CONVERT_TO_TEXT"
|
||||
}
|
||||
"smithy.api#enumValue": "CONVERT_TO_TEXT"
|
||||
}
|
||||
},
|
||||
"CONVERT_TO_BINARY": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "CONVERT_TO_BINARY"
|
||||
}
|
||||
"smithy.api#enumValue": "CONVERT_TO_BINARY"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -46,27 +46,27 @@ enum cfnMutability {
|
|||
/// member does not have any mutability restrictions, meaning that it
|
||||
/// can be specified by the user and returned in a `read` or `list`
|
||||
/// request.
|
||||
@enumValue(string: "full")
|
||||
@enumValue("full")
|
||||
FULL
|
||||
|
||||
/// Indicates that the CloudFormation property generated from this
|
||||
/// member can be specified only during resource creation and can be
|
||||
/// returned in a `read` or `list` request.
|
||||
@enumValue(string: "create-and-read")
|
||||
@enumValue("create-and-read")
|
||||
CREATE_AND_READ
|
||||
|
||||
/// Indicates that the CloudFormation property generated from this
|
||||
/// member can be specified only during resource creation and cannot
|
||||
/// be returned in a `read` or `list` request. MUST NOT be set if the
|
||||
/// member is also marked with the `@additionalIdentifier` trait.
|
||||
@enumValue(string: "create")
|
||||
@enumValue("create")
|
||||
CREATE
|
||||
|
||||
|
||||
/// Indicates that the CloudFormation property generated from this
|
||||
/// member can be returned by a `read` or `list` request, but
|
||||
/// cannot be set by the user.
|
||||
@enumValue(string: "read")
|
||||
@enumValue("read")
|
||||
READ
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ enum cfnMutability {
|
|||
/// member can be specified by the user, but cannot be returned by a
|
||||
/// `read` or `list` request. MUST NOT be set if the member is also
|
||||
/// marked with the `@additionalIdentifier` trait.
|
||||
@enumValue(string: "write")
|
||||
@enumValue("write")
|
||||
WRITE
|
||||
}
|
||||
|
||||
|
|
|
@ -127,105 +127,79 @@
|
|||
"ARN": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "ARN"
|
||||
}
|
||||
"smithy.api#enumValue": "ARN"
|
||||
}
|
||||
},
|
||||
"ARRAY_OF_ARN": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "ArrayOfARN"
|
||||
}
|
||||
"smithy.api#enumValue": "ArrayOfARN"
|
||||
}
|
||||
},
|
||||
"BINARY": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "Binary"
|
||||
}
|
||||
"smithy.api#enumValue": "Binary"
|
||||
}
|
||||
},
|
||||
"ARRAY_OF_BINARY": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "ArrayOfBinary"
|
||||
}
|
||||
"smithy.api#enumValue": "ArrayOfBinary"
|
||||
}
|
||||
},
|
||||
"STRING": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "String"
|
||||
}
|
||||
"smithy.api#enumValue": "String"
|
||||
}
|
||||
},
|
||||
"ARRAY_OF_STRING": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "ArrayOfString"
|
||||
}
|
||||
"smithy.api#enumValue": "ArrayOfString"
|
||||
}
|
||||
},
|
||||
"NUMERIC": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "Numeric"
|
||||
}
|
||||
"smithy.api#enumValue": "Numeric"
|
||||
}
|
||||
},
|
||||
"DATE": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "Date"
|
||||
}
|
||||
"smithy.api#enumValue": "Date"
|
||||
}
|
||||
},
|
||||
"ARRAY_OF_DATE": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "ArrayOfDate"
|
||||
}
|
||||
"smithy.api#enumValue": "ArrayOfDate"
|
||||
}
|
||||
},
|
||||
"BOOL": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "Bool"
|
||||
}
|
||||
"smithy.api#enumValue": "Bool"
|
||||
}
|
||||
},
|
||||
"ARRAY_OF_BOOL": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "ArrayOfBool"
|
||||
}
|
||||
"smithy.api#enumValue": "ArrayOfBool"
|
||||
}
|
||||
},
|
||||
"IP_ADDRESS": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "IPAddress"
|
||||
}
|
||||
"smithy.api#enumValue": "IPAddress"
|
||||
}
|
||||
},
|
||||
"ARRAY_OF_IP_ADDRESS": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "ArrayOfIPAddress"
|
||||
}
|
||||
"smithy.api#enumValue": "ArrayOfIPAddress"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -240,33 +214,25 @@
|
|||
"ROOT": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "Root"
|
||||
}
|
||||
"smithy.api#enumValue": "Root"
|
||||
}
|
||||
},
|
||||
"IAM_USER": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "IAMUser"
|
||||
}
|
||||
"smithy.api#enumValue": "IAMUser"
|
||||
}
|
||||
},
|
||||
"IAM_ROLE": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "IAMRole"
|
||||
}
|
||||
"smithy.api#enumValue": "IAMRole"
|
||||
}
|
||||
},
|
||||
"FEDERATED_USER": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "FederatedUser"
|
||||
}
|
||||
"smithy.api#enumValue": "FederatedUser"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -98,24 +98,24 @@ structure RetryConfig {
|
|||
|
||||
/// Controls the S3 addressing bucket style.
|
||||
enum S3AddressingStyle {
|
||||
@enumValue(string: "auto")
|
||||
@enumValue("auto")
|
||||
AUTO
|
||||
|
||||
@enumValue(string: "path")
|
||||
@enumValue("path")
|
||||
PATH
|
||||
|
||||
@enumValue(string: "virtual")
|
||||
@enumValue("virtual")
|
||||
VIRTUAL
|
||||
}
|
||||
|
||||
/// Controls the strategy used for retries.
|
||||
enum RetryMode {
|
||||
@enumValue(string: "legacy")
|
||||
@enumValue("legacy")
|
||||
LEGACY
|
||||
|
||||
@enumValue(string: "standard")
|
||||
@enumValue("standard")
|
||||
STANDARD
|
||||
|
||||
@enumValue(string: "adaptive")
|
||||
@enumValue("adaptive")
|
||||
ADAPTIVE
|
||||
}
|
||||
|
|
|
@ -136,10 +136,10 @@ map ScoreValuePerLabelMap {
|
|||
}
|
||||
|
||||
enum DetailsAttributes {
|
||||
@enumValue(string: "PredictiveModelType")
|
||||
@enumValue("PredictiveModelType")
|
||||
PREDICTIVE_MODEL_TYPE
|
||||
|
||||
@enumValue(string: "Algorithm")
|
||||
@enumValue("Algorithm")
|
||||
ALGORITHM
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ structure EnumPayloadInput {
|
|||
}
|
||||
|
||||
enum StringEnum {
|
||||
@enumValue(string: "enumvalue")
|
||||
@enumValue("enumvalue")
|
||||
V
|
||||
}
|
||||
|
||||
|
|
|
@ -192,10 +192,10 @@ structure MalformedEnumInput {
|
|||
}
|
||||
|
||||
enum EnumString {
|
||||
@enumValue(string: "abc")
|
||||
@enumValue("abc")
|
||||
ABC
|
||||
|
||||
@enumValue(string: "def")
|
||||
@enumValue("def")
|
||||
DEF
|
||||
}
|
||||
|
||||
|
|
|
@ -86,10 +86,10 @@ structure RecursiveStructuresInput {
|
|||
}
|
||||
|
||||
enum RecursiveEnumString {
|
||||
@enumValue(string: "abc")
|
||||
@enumValue("abc")
|
||||
ABC
|
||||
|
||||
@enumValue(string: "def")
|
||||
@enumValue("def")
|
||||
DEF
|
||||
}
|
||||
|
||||
|
|
|
@ -460,6 +460,6 @@ string Token
|
|||
|
||||
enum BucketLocationConstraint {
|
||||
@suppress(["EnumShape"])
|
||||
@enumValue(string: "us-west-2")
|
||||
@enumValue("us-west-2")
|
||||
us_west_2
|
||||
}
|
||||
|
|
|
@ -77,19 +77,19 @@ list TimestampList {
|
|||
}
|
||||
|
||||
enum FooEnum {
|
||||
@enumValue(string: "Foo")
|
||||
@enumValue("Foo")
|
||||
FOO
|
||||
|
||||
@enumValue(string: "Baz")
|
||||
@enumValue("Baz")
|
||||
BAZ
|
||||
|
||||
@enumValue(string: "Bar")
|
||||
@enumValue("Bar")
|
||||
BAR
|
||||
|
||||
@enumValue(string: "1")
|
||||
@enumValue("1")
|
||||
ONE
|
||||
|
||||
@enumValue(string: "0")
|
||||
@enumValue("0")
|
||||
ZERO
|
||||
}
|
||||
|
||||
|
|
|
@ -84,45 +84,35 @@
|
|||
"CUSTOMER_CONTENT": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "content"
|
||||
},
|
||||
"smithy.api#enumValue": "content",
|
||||
"smithy.api#documentation": "Customer content means any software (including machine images), data, text, audio, video or images that customers or any customer end user transfers to AWS for processing, storage or hosting by AWS services in connection with the customer\u2019s accounts and any computational results that customers or any customer end user derive from the foregoing through their use of AWS services."
|
||||
}
|
||||
},
|
||||
"CUSTOMER_ACCOUNT_INFORMATION": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "account"
|
||||
},
|
||||
"smithy.api#enumValue": "account",
|
||||
"smithy.api#documentation": "Account information means information about customers that customers provide to AWS in connection with the creation or administration of customers\u2019 accounts."
|
||||
}
|
||||
},
|
||||
"SERVICE_ATTRIBUTES": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "usage"
|
||||
},
|
||||
"smithy.api#enumValue": "usage",
|
||||
"smithy.api#documentation": "Service Attributes means service usage data related to a customer\u2019s account, such as resource identifiers, metadata tags, security and access roles, rules, usage policies, permissions, usage statistics, logging data, and analytics."
|
||||
}
|
||||
},
|
||||
"TAG_DATA": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "tagging"
|
||||
},
|
||||
"smithy.api#enumValue": "tagging",
|
||||
"smithy.api#documentation": "Designates metadata tags applied to AWS resources."
|
||||
}
|
||||
},
|
||||
"PERMISSIONS_DATA": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "permissions"
|
||||
},
|
||||
"smithy.api#enumValue": "permissions",
|
||||
"smithy.api#documentation": "Designates security and access roles, rules, usage policies, and permissions."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,33 +286,25 @@
|
|||
"CRC32C": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "CRC32C"
|
||||
}
|
||||
"smithy.api#enumValue": "CRC32C"
|
||||
}
|
||||
},
|
||||
"CRC32": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "CRC32"
|
||||
}
|
||||
"smithy.api#enumValue": "CRC32"
|
||||
}
|
||||
},
|
||||
"SHA1": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "SHA1"
|
||||
}
|
||||
"smithy.api#enumValue": "SHA1"
|
||||
}
|
||||
},
|
||||
"SHA256": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "SHA256"
|
||||
}
|
||||
"smithy.api#enumValue": "SHA256"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -20,7 +20,6 @@ import software.amazon.smithy.model.SourceException;
|
|||
import software.amazon.smithy.model.node.ExpectationNotMetException;
|
||||
import software.amazon.smithy.model.node.Node;
|
||||
import software.amazon.smithy.model.node.NumberNode;
|
||||
import software.amazon.smithy.model.node.ObjectNode;
|
||||
import software.amazon.smithy.model.node.StringNode;
|
||||
import software.amazon.smithy.model.shapes.ShapeId;
|
||||
import software.amazon.smithy.utils.SmithyBuilder;
|
||||
|
@ -97,13 +96,12 @@ public final class EnumValueTrait extends AbstractTrait implements ToSmithyBuild
|
|||
@Override
|
||||
public Trait createTrait(ShapeId target, Node value) {
|
||||
Builder builder = builder().sourceLocation(value);
|
||||
ObjectNode objectNode = value.expectObjectNode();
|
||||
objectNode.getMember("string")
|
||||
.map(v -> v.expectStringNode().getValue())
|
||||
.ifPresent(builder::stringValue);
|
||||
objectNode.getMember("int")
|
||||
.map(v -> v.expectNumberNode().getValue().intValue())
|
||||
.ifPresent(builder::intValue);
|
||||
value.asStringNode().ifPresent(node -> builder.stringValue(node.getValue()));
|
||||
value.asNumberNode().ifPresent(node -> {
|
||||
if (node.isNaturalNumber()) {
|
||||
builder.intValue(node.getValue().intValue());
|
||||
}
|
||||
});
|
||||
EnumValueTrait result = builder.build();
|
||||
result.setNodeCache(value);
|
||||
return result;
|
||||
|
@ -112,11 +110,12 @@ public final class EnumValueTrait extends AbstractTrait implements ToSmithyBuild
|
|||
|
||||
@Override
|
||||
protected Node createNode() {
|
||||
return ObjectNode.builder()
|
||||
.sourceLocation(getSourceLocation())
|
||||
.withOptionalMember("string", getStringValue().map(StringNode::from))
|
||||
.withOptionalMember("int", getIntValue().map(NumberNode::from))
|
||||
.build();
|
||||
if (getIntValue().isPresent()) {
|
||||
return new NumberNode(integer, getSourceLocation());
|
||||
} else {
|
||||
return new StringNode(string, getSourceLocation());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -135,11 +135,11 @@ string TraitChangeSeverity
|
|||
@private
|
||||
enum StructurallyExclusive {
|
||||
/// Only a single member of a shape can be marked with the trait.
|
||||
@enumValue(string: "member")
|
||||
@enumValue("member")
|
||||
MEMBER
|
||||
|
||||
/// Only a single member of a shape can target a shape marked with this trait.
|
||||
@enumValue(string: "target")
|
||||
@enumValue("target")
|
||||
TARGET
|
||||
}
|
||||
|
||||
|
@ -277,10 +277,10 @@ structure default {}
|
|||
|
||||
@private
|
||||
enum HttpApiKeyLocations {
|
||||
@enumValue(string: "header")
|
||||
@enumValue("header")
|
||||
HEADER
|
||||
|
||||
@enumValue(string: "query")
|
||||
@enumValue("query")
|
||||
QUERY
|
||||
}
|
||||
|
||||
|
@ -329,10 +329,10 @@ structure ExampleError {
|
|||
breakingChanges: [{change: "any"}]
|
||||
)
|
||||
enum error {
|
||||
@enumValue(string: "client")
|
||||
@enumValue("client")
|
||||
CLIENT
|
||||
|
||||
@enumValue(string: "server")
|
||||
@enumValue("server")
|
||||
SERVER
|
||||
}
|
||||
|
||||
|
@ -583,13 +583,7 @@ string EnumConstantBodyName
|
|||
|
||||
/// Defines the value of an enum member.
|
||||
@trait(selector: ":is(enum, intEnum) > member")
|
||||
union enumValue {
|
||||
/// The value for the enum entry if it is a string.
|
||||
string: String
|
||||
|
||||
/// The value for the enum entry if it is an integer.
|
||||
int: Integer
|
||||
}
|
||||
document enumValue
|
||||
|
||||
/// Sets an enum member as the default value member.
|
||||
@trait(
|
||||
|
@ -913,18 +907,18 @@ enum timestampFormat {
|
|||
|
||||
/// Date time as defined by the date-time production in RFC3339 section 5.6
|
||||
/// with no UTC offset (for example, 1985-04-12T23:20:50.52Z).
|
||||
@enumValue(string: "date-time")
|
||||
@enumValue("date-time")
|
||||
DATE_TIME
|
||||
|
||||
/// Also known as Unix time, the number of seconds that have elapsed since
|
||||
/// 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970,
|
||||
/// with decimal precision (for example, 1515531081.1234).
|
||||
@enumValue(string: "epoch-seconds")
|
||||
@enumValue("epoch-seconds")
|
||||
EPOCH_SECONDS
|
||||
|
||||
/// An HTTP date as defined by the IMF-fixdate production in
|
||||
/// RFC 7231#section-7.1.1.1 (for example, Tue, 29 Apr 2014 18:30:38 GMT).
|
||||
@enumValue(string: "http-date")
|
||||
@enumValue("http-date")
|
||||
HTTP_DATE
|
||||
}
|
||||
|
||||
|
|
|
@ -5,19 +5,19 @@ namespace ns.foo
|
|||
enum StringEnum {
|
||||
IMPLICIT_VALUE
|
||||
|
||||
@enumValue(string: "explicit")
|
||||
@enumValue("explicit")
|
||||
EXPLICIT_VALUE
|
||||
|
||||
@enumValue(string: "")
|
||||
@enumValue("")
|
||||
EMPTY_STRING
|
||||
|
||||
@enumDefault
|
||||
DEFAULT_VALUE
|
||||
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
INT_VALUE
|
||||
|
||||
@enumValue(string: "explicit")
|
||||
@enumValue("explicit")
|
||||
DUPLICATE_VALUE
|
||||
|
||||
undesirableName
|
||||
|
@ -41,28 +41,28 @@ enum MultipleDefaults {
|
|||
|
||||
enum DefaultWithExplicitValue {
|
||||
@enumDefault
|
||||
@enumValue(string: "foo")
|
||||
@enumValue("foo")
|
||||
DEFAULT
|
||||
}
|
||||
|
||||
intEnum IntEnum {
|
||||
IMPLICIT_VALUE
|
||||
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
EXPLICIT_VALUE
|
||||
|
||||
@enumValue(int: 0)
|
||||
@enumValue(0)
|
||||
ZERO
|
||||
|
||||
@enumDefault
|
||||
DEFAULT_VALUE
|
||||
|
||||
@enumValue(string: "foo")
|
||||
@enumValue("foo")
|
||||
STRING_VALUE
|
||||
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
DUPLICATE_VALUE
|
||||
|
||||
@enumValue(int: 99)
|
||||
@enumValue(99)
|
||||
undesirableName
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[ERROR] smithy.example#IntEnum$FLOAT: Error creating trait `enumValue`: Either a string value or an integer value must be set for the enumValue trait. | Model
|
||||
[ERROR] smithy.example#IntEnum$ARRAY: Error creating trait `enumValue`: Either a string value or an integer value must be set for the enumValue trait. | Model
|
||||
[ERROR] smithy.example#IntEnum$MAP: Error creating trait `enumValue`: Either a string value or an integer value must be set for the enumValue trait. | Model
|
||||
[ERROR] smithy.example#IntEnum$NULL: Error creating trait `enumValue`: Either a string value or an integer value must be set for the enumValue trait. | Model
|
||||
[ERROR] smithy.example#IntEnum$BOOLEAN: Error creating trait `enumValue`: Either a string value or an integer value must be set for the enumValue trait. | Model
|
|
@ -0,0 +1,20 @@
|
|||
$version: "2.0"
|
||||
|
||||
namespace smithy.example
|
||||
|
||||
intEnum IntEnum {
|
||||
@enumValue(1.1)
|
||||
FLOAT
|
||||
|
||||
@enumValue([1])
|
||||
ARRAY
|
||||
|
||||
@enumValue({"foo": "bar"})
|
||||
MAP
|
||||
|
||||
@enumValue(null)
|
||||
NULL
|
||||
|
||||
@enumValue(true)
|
||||
BOOLEAN
|
||||
}
|
|
@ -4,9 +4,9 @@ $version: "1.0"
|
|||
namespace ns.foo
|
||||
|
||||
intEnum IntEnum {
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
FOO
|
||||
|
||||
@enumValue(int: 2)
|
||||
@enumValue(2)
|
||||
BAR
|
||||
}
|
||||
|
|
|
@ -7,25 +7,19 @@
|
|||
"FOO": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "FOO"
|
||||
}
|
||||
"smithy.api#enumValue": "FOO"
|
||||
}
|
||||
},
|
||||
"BAR": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "BAR"
|
||||
}
|
||||
"smithy.api#enumValue": "BAR"
|
||||
}
|
||||
},
|
||||
"BAZ": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "BAZ"
|
||||
}
|
||||
"smithy.api#enumValue": "BAZ"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,25 +30,19 @@
|
|||
"FOO": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "foo"
|
||||
}
|
||||
"smithy.api#enumValue": "foo"
|
||||
}
|
||||
},
|
||||
"BAR": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "bar"
|
||||
}
|
||||
"smithy.api#enumValue": "bar"
|
||||
}
|
||||
},
|
||||
"BAZ": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "baz"
|
||||
}
|
||||
"smithy.api#enumValue": "baz"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,25 +64,19 @@
|
|||
"FOO": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"int": 1
|
||||
}
|
||||
"smithy.api#enumValue": 1
|
||||
}
|
||||
},
|
||||
"BAR": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"int": 2
|
||||
}
|
||||
"smithy.api#enumValue": 2
|
||||
}
|
||||
},
|
||||
"BAZ": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"int": 3
|
||||
}
|
||||
"smithy.api#enumValue": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,13 @@ enum EnumWithoutValueTraits {
|
|||
}
|
||||
|
||||
enum EnumWithValueTraits {
|
||||
@enumValue(string: "foo")
|
||||
@enumValue("foo")
|
||||
FOO
|
||||
|
||||
@enumValue(string: "bar")
|
||||
@enumValue("bar")
|
||||
BAR
|
||||
|
||||
@enumValue(string: "baz")
|
||||
@enumValue("baz")
|
||||
BAZ
|
||||
}
|
||||
|
||||
|
@ -25,13 +25,13 @@ enum EnumWithDefaultBound {
|
|||
}
|
||||
|
||||
intEnum IntEnum {
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
FOO
|
||||
|
||||
@enumValue(int: 2)
|
||||
@enumValue(2)
|
||||
BAR
|
||||
|
||||
@enumValue(int: 3)
|
||||
@enumValue(3)
|
||||
BAZ
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ enum MixedEnum {
|
|||
@sensitive
|
||||
@private
|
||||
intEnum MixedIntEnum {
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
FOO
|
||||
|
||||
/// Docs
|
||||
@enumValue(int: 2)
|
||||
@enumValue(2)
|
||||
BAR
|
||||
|
||||
@enumValue(int: 3)
|
||||
@enumValue(3)
|
||||
BAZ
|
||||
}
|
||||
|
|
|
@ -7,17 +7,13 @@
|
|||
"FOO": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "FOO"
|
||||
}
|
||||
"smithy.api#enumValue": "FOO"
|
||||
}
|
||||
},
|
||||
"BAR": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "BAR"
|
||||
},
|
||||
"smithy.api#enumValue": "BAR",
|
||||
"smithy.api#documentation": "Documentation"
|
||||
}
|
||||
}
|
||||
|
@ -40,9 +36,7 @@
|
|||
"BAZ": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "BAZ"
|
||||
}
|
||||
"smithy.api#enumValue": "BAZ"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -60,17 +54,13 @@
|
|||
"FOO": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"int": 1
|
||||
}
|
||||
"smithy.api#enumValue": 1
|
||||
}
|
||||
},
|
||||
"BAR": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"int": 2
|
||||
},
|
||||
"smithy.api#enumValue": 2,
|
||||
"smithy.api#documentation": "Documentation"
|
||||
}
|
||||
}
|
||||
|
@ -93,9 +83,7 @@
|
|||
"BAZ": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"int": 3
|
||||
}
|
||||
"smithy.api#enumValue": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -24,11 +24,11 @@ enum MixedEnum with [BaseEnum] {
|
|||
@mixin
|
||||
@private
|
||||
intEnum BaseIntEnum {
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
FOO
|
||||
|
||||
/// Documentation
|
||||
@enumValue(int: 2)
|
||||
@enumValue(2)
|
||||
BAR
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,6 @@ intEnum MixedIntEnum with [BaseIntEnum] {
|
|||
/// Docs
|
||||
BAR
|
||||
|
||||
@enumValue(int: 3)
|
||||
@enumValue(3)
|
||||
BAZ
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ enum Enum {
|
|||
string String
|
||||
|
||||
intEnum IntEnum {
|
||||
@enumValue(int: 1)
|
||||
@enumValue(1)
|
||||
FOO
|
||||
}
|
||||
|
||||
|
|
|
@ -7,17 +7,13 @@
|
|||
"FOO": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "foo"
|
||||
}
|
||||
"smithy.api#enumValue": "foo"
|
||||
}
|
||||
},
|
||||
"BAR": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"string": "bar"
|
||||
}
|
||||
"smithy.api#enumValue": "bar"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -29,17 +25,13 @@
|
|||
"FOO": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"int": 1
|
||||
}
|
||||
"smithy.api#enumValue": 1
|
||||
}
|
||||
},
|
||||
"BAR": {
|
||||
"target": "smithy.api#Unit",
|
||||
"traits": {
|
||||
"smithy.api#enumValue": {
|
||||
"int": 2
|
||||
}
|
||||
"smithy.api#enumValue": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,9 @@ $version: "2.0"
|
|||
namespace ns.foo
|
||||
|
||||
intEnum IntEnum {
|
||||
@enumValue(
|
||||
int: 1
|
||||
)
|
||||
@enumValue(1)
|
||||
FOO
|
||||
@enumValue(
|
||||
int: 2
|
||||
)
|
||||
@enumValue(2)
|
||||
BAR
|
||||
}
|
||||
|
||||
|
@ -19,12 +15,8 @@ enum StringEnum {
|
|||
}
|
||||
|
||||
enum StringEnumWithExplicitValues {
|
||||
@enumValue(
|
||||
string: "foo"
|
||||
)
|
||||
@enumValue("foo")
|
||||
FOO
|
||||
@enumValue(
|
||||
string: "bar"
|
||||
)
|
||||
@enumValue("bar")
|
||||
BAR
|
||||
}
|
||||
|
|
|
@ -52,31 +52,31 @@ structure RejectedError {
|
|||
}
|
||||
|
||||
enum RejectedErrorCode {
|
||||
@enumValue(string: "InvalidTopic")
|
||||
@enumValue("InvalidTopic")
|
||||
INVALID_TOPIC
|
||||
|
||||
@enumValue(string: "InvalidJson")
|
||||
@enumValue("InvalidJson")
|
||||
INVALID_JSON
|
||||
|
||||
@enumValue(string: "InvalidRequest")
|
||||
@enumValue("InvalidRequest")
|
||||
INVALID_REQUEST
|
||||
|
||||
@enumValue(string: "InvalidStateTransition")
|
||||
@enumValue("InvalidStateTransition")
|
||||
INVALID_STATE_TRANSITION
|
||||
|
||||
@enumValue(string: "ResourceNotFound")
|
||||
@enumValue("ResourceNotFound")
|
||||
RESOURCE_NOT_FOUND
|
||||
|
||||
@enumValue(string: "VersionMismatch")
|
||||
@enumValue("VersionMismatch")
|
||||
VERSION_MISMATCH
|
||||
|
||||
@enumValue(string: "InternalError")
|
||||
@enumValue("InternalError")
|
||||
INTERNAL_ERROR
|
||||
|
||||
@enumValue(string: "RequestThrottled")
|
||||
@enumValue("RequestThrottled")
|
||||
REQUEST_THROTTLED
|
||||
|
||||
@enumValue(string: "TerminalStateReached")
|
||||
@enumValue("TerminalStateReached")
|
||||
TERMINAL_STATE_REACHED
|
||||
}
|
||||
|
||||
|
|
|
@ -274,11 +274,11 @@ string NonEmptyString
|
|||
@private
|
||||
enum AppliesTo {
|
||||
/// The test only applies to client implementations.
|
||||
@enumValue(string: "client")
|
||||
@enumValue("client")
|
||||
CLIENT
|
||||
|
||||
/// The test only applies to server implementations.
|
||||
@enumValue(string: "server")
|
||||
@enumValue("server")
|
||||
SERVER
|
||||
}
|
||||
|
||||
|
|
|
@ -72,17 +72,17 @@ structure Acceptor {
|
|||
enum AcceptorState {
|
||||
/// The waiter successfully finished waiting. This is a terminal
|
||||
/// state that causes the waiter to stop.
|
||||
@enumValue(string: "success")
|
||||
@enumValue("success")
|
||||
SUCCESS
|
||||
|
||||
/// The waiter failed to enter into the desired state. This is a
|
||||
/// terminal state that causes the waiter to stop.
|
||||
@enumValue(string: "failure")
|
||||
@enumValue("failure")
|
||||
FAILURE
|
||||
|
||||
/// The waiter will retry the operation. This state transition is
|
||||
/// implicit if no accepter causes a state transition.
|
||||
@enumValue(string: "retry")
|
||||
@enumValue("retry")
|
||||
RETRY
|
||||
}
|
||||
|
||||
|
@ -136,19 +136,19 @@ structure PathMatcher {
|
|||
@private
|
||||
enum PathComparator {
|
||||
/// Matches if the return value is a string that is equal to the expected string.
|
||||
@enumValue(string: "stringEquals")
|
||||
@enumValue("stringEquals")
|
||||
STRING_EQUALS
|
||||
|
||||
/// Matches if the return value is a boolean that is equal to the string literal 'true' or 'false'.
|
||||
@enumValue(string: "booleanEquals")
|
||||
@enumValue("booleanEquals")
|
||||
BOOLEAN_EQUALS
|
||||
|
||||
/// Matches if all values in the list matches the expected string.
|
||||
@enumValue(string: "allStringEquals")
|
||||
@enumValue("allStringEquals")
|
||||
ALL_STRING_EQUALS
|
||||
|
||||
/// Matches if any value in the list matches the expected string.
|
||||
@enumValue(string: "anyStringEquals")
|
||||
@enumValue("anyStringEquals")
|
||||
ANY_STRING_EQUALS
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue