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

Support deprecated on fields in the OpenAPI conversion #2221

Merged
merged 14 commits into from
Apr 11, 2024
Prev Previous commit
Next Next commit
add another test
miguel-vila committed Apr 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6b44211aceccffcb475f38690121a6b56dcbdf18
Original file line number Diff line number Diff line change
@@ -782,6 +782,32 @@ public void intEnumsCanBeDisabled() {
Node.assertEquals(document.toNode(), expected);
}

@Test
public void supportsDeprecatedTraitOnAStruct() {
StringShape string = StringShape.builder().id("smithy.api#String").build();
StructureShape shape = StructureShape.builder()
.id(ShapeId.from("a.b#C"))
.addMember(
MemberShape.builder().id(ShapeId.from("a.b#C$member"))
.target(string.getId())
.build()
)
.addTrait(DeprecatedTrait.builder().message(
"I'm deprecated"
).since("sinceVersion").build())
.build();
Model model = Model.builder().addShapes(shape, string).build();
JsonSchemaConfig config = new JsonSchemaConfig();
config.setJsonSchemaVersion(JsonSchemaVersion.DRAFT2020_12);
SchemaDocument document = JsonSchemaConverter.builder()
.model(model)
.config(config)
.build()
.convertShape(shape);

assertThat(document.getRootSchema().isDeprecated(), equalTo(true));
}

@Test
public void supportsDeprecatedTraitOnAMember() {
StringShape string = StringShape.builder().id("smithy.api#String").build();