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

Start work towards version 1.1 of the IDL #776

Merged
merged 1 commit into from
Apr 21, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public final class Model implements ToSmithyBuilder<Model> {

/** Specifies the highest supported version of the IDL. */
public static final String MODEL_VERSION = "1.0";
public static final String MODEL_VERSION = "1.1";

/** The map of metadata keys to their "node" values. */
private final Map<String, Node> metadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ static void checkForAdditionalProperties(
* @return Returns true if this is a supported model version.
*/
static boolean isVersionSupported(String versionString) {
return versionString.equals("1") || versionString.equals("1.0");
return versionString.equals("1")
|| versionString.equals("1.0")
|| versionString.equals("1.1");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static ModelFile load(
// is then used to delegate loading to different versions of the
// Smithy JSON AST format.
//
// This loader supports version 1.0. Support for 0.5 and 0.4 was removed in 0.10.
// This loader supports version 1.0 and 1.1. Support for 0.5 and 0.4 was removed in 0.10.
static ModelFile loadParsedNode(TraitFactory traitFactory, Node node) {
ObjectNode model = node.expectObjectNode("Smithy documents must be an object. Found {type}.");
StringNode version = model.expectStringMember(SMITHY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private void shapeWithMembers(Shape shape, List<MemberShape> members) {
codeWriter.openBlock("$L $L {", shape.getType(), shape.getId().getName());
for (MemberShape member : members) {
serializeTraits(member);
codeWriter.write("$L: $I,", member.getMemberName(), member.getTarget());
codeWriter.write("$L: $I", member.getMemberName(), member.getTarget());
}
codeWriter.closeBlock("}").write("");
}
Expand Down Expand Up @@ -425,13 +425,13 @@ public Void unionShape(UnionShape shape) {
public Void serviceShape(ServiceShape shape) {
serializeTraits(shape);
codeWriter.openBlock("service $L {", shape.getId().getName())
.write("version: $S,", shape.getVersion());
.write("version: $S", shape.getVersion());
codeWriter.writeOptionalIdList("operations", shape.getOperations());
codeWriter.writeOptionalIdList("resources", shape.getResources());
if (!shape.getRename().isEmpty()) {
codeWriter.openBlock("rename: {", "}", () -> {
for (Map.Entry<ShapeId, String> entry : shape.getRename().entrySet()) {
codeWriter.write("$S: $S,", entry.getKey(), entry.getValue());
codeWriter.write("$S: $S", entry.getKey(), entry.getValue());
}
});
}
Expand All @@ -448,16 +448,16 @@ public Void resourceShape(ResourceShape shape) {
shape.getIdentifiers().entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.forEach(entry -> codeWriter.write(
"$L: $I,", entry.getKey(), entry.getValue()));
codeWriter.closeBlock("},");
"$L: $I", entry.getKey(), entry.getValue()));
codeWriter.closeBlock("}");
}

shape.getPut().ifPresent(shapeId -> codeWriter.write("put: $I,", shapeId));
shape.getCreate().ifPresent(shapeId -> codeWriter.write("create: $I,", shapeId));
shape.getRead().ifPresent(shapeId -> codeWriter.write("read: $I,", shapeId));
shape.getUpdate().ifPresent(shapeId -> codeWriter.write("update: $I,", shapeId));
shape.getDelete().ifPresent(shapeId -> codeWriter.write("delete: $I,", shapeId));
shape.getList().ifPresent(shapeId -> codeWriter.write("list: $I,", shapeId));
shape.getPut().ifPresent(shapeId -> codeWriter.write("put: $I", shapeId));
shape.getCreate().ifPresent(shapeId -> codeWriter.write("create: $I", shapeId));
shape.getRead().ifPresent(shapeId -> codeWriter.write("read: $I", shapeId));
shape.getUpdate().ifPresent(shapeId -> codeWriter.write("update: $I", shapeId));
shape.getDelete().ifPresent(shapeId -> codeWriter.write("delete: $I", shapeId));
shape.getList().ifPresent(shapeId -> codeWriter.write("list: $I", shapeId));
codeWriter.writeOptionalIdList("operations", shape.getOperations());
codeWriter.writeOptionalIdList("collectionOperations", shape.getCollectionOperations());
codeWriter.writeOptionalIdList("resources", shape.getResources());
Expand All @@ -476,8 +476,8 @@ public Void operationShape(OperationShape shape) {
}

codeWriter.openBlock("operation $L {", shape.getId().getName());
shape.getInput().ifPresent(shapeId -> codeWriter.write("input: $I,", shapeId));
shape.getOutput().ifPresent(shapeId -> codeWriter.write("output: $I,", shapeId));
shape.getInput().ifPresent(shapeId -> codeWriter.write("input: $I", shapeId));
shape.getOutput().ifPresent(shapeId -> codeWriter.write("output: $I", shapeId));
codeWriter.writeOptionalIdList("errors", shape.getErrors());
codeWriter.closeBlock("}");
codeWriter.write("");
Expand Down Expand Up @@ -593,7 +593,6 @@ private void serializeArray(ArrayNode node, Shape shape) {
codeWriter.write("");
codeWriter.writeIndent();
serialize(element, member);
codeWriter.writeInline(",");
}
codeWriter.write("");

Expand Down Expand Up @@ -651,7 +650,6 @@ private void serializeKeyValuePairs(ObjectNode node, Shape shape) {

codeWriter.writeInline("\n$K: ", name.getValue());
serialize(value, member);
codeWriter.writeInline(",");
});
codeWriter.write("");
}
Expand Down Expand Up @@ -769,8 +767,8 @@ private SmithyCodeWriter writeOptionalIdList(String textBeforeList, Collection<S
}

openBlock("$L: [", textBeforeList);
shapeIds.stream().sorted().forEach(shapeId -> write("$I,", shapeId));
closeBlock("],");
shapeIds.stream().sorted().forEach(shapeId -> write("$I", shapeId));
closeBlock("]");

return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$version: "1.0"
$version: "1.1"

namespace ns.foo

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
$version: "1.0"
$version: "1.1"

namespace ns.foo

@trait
list ListTrait {
member: String,
member: String
}

@trait
set SetTrait {
member: String,
member: String
}

@ListTrait([])
@SetTrait([])
string Bar

@ListTrait([
"first",
"second",
"first"
"second"
])
@SetTrait([
"first",
"second",
"first"
"second"
])
string Foo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$version: "1.0"
$version: "1.1"

namespace ns.foo

Expand All @@ -9,12 +9,12 @@ document DocumentTrait
string Boolean

@DocumentTrait([
"foo",
"foo"
])
string List

@DocumentTrait(
foo: "bar",
foo: "bar"
)
string Map

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$version: "1.0"
$version: "1.1"

namespace ns.foo

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
$version: "1.0"
$version: "1.1"

metadata CaseSensitive = true
metadata bool2 = false
metadata caseSensitive = true
metadata "example.array" = [
10,
true,
"hello",
10
true
"hello"
]
metadata "example.bool1" = true
metadata "key must be quoted" = true
metadata null = null
metadata number = 10
metadata object = {
foo: "baz",
foo: "baz"
}
metadata string = "hello there"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$version: "1.0"
$version: "1.1"

namespace ns.foo

Expand Down
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
$version: "1.0"
$version: "1.1"

namespace ns.foo

@trait
map MapTrait {
key: String,
value: String,
key: String
value: String
}

@trait
structure StructureTrait {
collectionMember: StringList,
nestedMember: NestedMember,
shapeIdMember: ShapeId,
staticMember: String,
collectionMember: StringList
nestedMember: NestedMember
shapeIdMember: ShapeId
staticMember: String
}

@trait
union UnionTrait {
boolean: Boolean,
string: String,
boolean: Boolean
string: String
}

structure NestedMember {
shapeIds: ShapeIdList,
shapeIds: ShapeIdList
}

list ShapeIdList {
member: ShapeId,
member: ShapeId
}

list StringList {
member: String,
member: String
}

@MapTrait
@StructureTrait
string EmptyBody

@MapTrait(
bar: "baz",
foo: "bar",
"must be quoted": "bam1",
"must.be.quoted": "bam2",
"must.be#quoted": "bam3",
"must.be#quoted$too": "bam4",
bar: "baz"
foo: "bar"
"must be quoted": "bam1"
"must.be.quoted": "bam2"
"must.be#quoted": "bam3"
"must.be#quoted$too": "bam4"
)
@StructureTrait(
collectionMember: [
"foo",
"bar",
],
"foo"
"bar"
]
nestedMember: {
shapeIds: [
String,
EmptyBody,
],
},
shapeIdMember: UnionTrait,
staticMember: "Foo",
String
EmptyBody
]
}
shapeIdMember: UnionTrait
staticMember: "Foo"
)
@UnionTrait(
boolean: false,
boolean: false
)
string NonEmptyBody

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
$version: "1.0"
$version: "1.1"

namespace ns.foo

structure Structure {
localWithConflict: String,
prelude: Blob,
preludeWithConflict: smithy.api#String,
localWithConflict: String
prelude: Blob
preludeWithConflict: smithy.api#String
}

string String
Loading