Smithy traits
Smithy comes with a powerful annotation system. Annotations in smithy are called traits.
These traits let you associate protocol-specific details to your data models and services.
For instance, an operation can be labelled as compatible with http semantics using the http traits:
namespace foo
@http(method: "GET", uri: "/hello/{name}")
operation Greet {
input: GreetInput,
output: GreetOutput,
errors: [BadInput]
}
structure GreetInput {
// Matches the {name} hole in the uri path above
@httpLabel
name: String
}
structure GreetOutput {
@httpPayload
message: String
}
@error("client")
@httpError(400)
structure BadInput {
@jsonName("oops")
message: String
}
Creating your own traits
Smithy makes it really easy to create your own traits:
namespace foo
@trait(selector: ":is(structure)")
string customThing
@customThing("hello")
structure MyStructure {
}
Regarding Smithy4s handling of traits
Smithy4s automatically creates corresponding values in the generated Scala code, for all the annotations it finds, whether defined in the smithy prelude, or defined by users.
These values can be retrieved via some interfaces that will be documented in a near future.