diff --git a/docs/source-2.0/spec/documentation-traits.rst b/docs/source-2.0/spec/documentation-traits.rst index 58182ee19ea..b7a27c326fe 100644 --- a/docs/source-2.0/spec/documentation-traits.rst +++ b/docs/source-2.0/spec/documentation-traits.rst @@ -386,7 +386,7 @@ tags trait are arbitrary and up to the model author. =============== Summary - Defines a proper name for a service or resource shape. This title can be + Defines a proper name for a shape. This title can be used in automatically generated documentation and other contexts to provide a user friendly name for a shape. Trait selector diff --git a/smithy-jsonschema/src/main/java/software/amazon/smithy/jsonschema/JsonSchemaShapeVisitor.java b/smithy-jsonschema/src/main/java/software/amazon/smithy/jsonschema/JsonSchemaShapeVisitor.java index 070a5b4f293..bab5a66bfef 100644 --- a/smithy-jsonschema/src/main/java/software/amazon/smithy/jsonschema/JsonSchemaShapeVisitor.java +++ b/smithy-jsonschema/src/main/java/software/amazon/smithy/jsonschema/JsonSchemaShapeVisitor.java @@ -267,9 +267,13 @@ public Schema enumShape(EnumShape shape) { MemberShape member = entry.getValue(); Schema enumSchema = Schema.builder() .constValue(StringNode.from(enumValues.get(memberName))) + .title(member.getTrait(TitleTrait.class) + .map(TitleTrait::getValue) + .orElse(null)) .description(member.getTrait(DocumentationTrait.class) .map(DocumentationTrait::getValue) .orElse(null)) + .build(); schemas.add(enumSchema); diff --git a/smithy-jsonschema/src/test/resources/software/amazon/smithy/jsonschema/string-enums-one-of.jsonschema.v07.json b/smithy-jsonschema/src/test/resources/software/amazon/smithy/jsonschema/string-enums-one-of.jsonschema.v07.json index 2bda54d8eeb..8be1443cb0a 100644 --- a/smithy-jsonschema/src/test/resources/software/amazon/smithy/jsonschema/string-enums-one-of.jsonschema.v07.json +++ b/smithy-jsonschema/src/test/resources/software/amazon/smithy/jsonschema/string-enums-one-of.jsonschema.v07.json @@ -17,7 +17,8 @@ "description": "it really does foo" }, { - "const": "Bar" + "const": "Bar", + "title": "TestEnum Bar" } ] } diff --git a/smithy-jsonschema/src/test/resources/software/amazon/smithy/jsonschema/string-enums.smithy b/smithy-jsonschema/src/test/resources/software/amazon/smithy/jsonschema/string-enums.smithy index 798281d6558..73edad433be 100644 --- a/smithy-jsonschema/src/test/resources/software/amazon/smithy/jsonschema/string-enums.smithy +++ b/smithy-jsonschema/src/test/resources/software/amazon/smithy/jsonschema/string-enums.smithy @@ -10,5 +10,6 @@ structure Foo { enum TestEnum { @documentation("it really does foo") FOO = "Foo" + @title("TestEnum Bar") BAR = "Bar" } diff --git a/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy b/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy index d433b85e72c..a91842c7bc9 100644 --- a/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy +++ b/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy @@ -666,11 +666,11 @@ list tags { member: String } -/// Defines a proper name for a service or resource shape. +/// Defines a proper name for a shape. /// /// This title can be used in automatically generated documentation -/// and other contexts to provide a user friendly for shapes. -@trait(selector: ":not(member)") +/// and other contexts to provide a user-friendly for shapes. +@trait string title /// Constrains the acceptable values of a string to a fixed set