Hacker News new | ask | show | jobs
by jorgebucaran 1868 days ago
What's the difference between the bracketed syntax, e.g. [City] and `list`?
2 comments

Smithy is very focused on codegen, so the model is highly normalized. So for example, defining a list of something needs to be done using a `list` shape. This kind of list is something you'd see directly serialized and sent over the wire. For example:

list Messages { member: Messages }

Then you can reference Messages from other places in the model, like from a structure:

structure Something { messages: Messages }

In contrast, the `[City]` syntax is used in other places in the IDL to define a relationship to a shape. This isn't something that gets sent over the wire, it's just used to form essentially a relationship in the service graph from a service to resources, a resource to operations, an operation to errors, etc. For example:

service Weather { resources: [City, Sensors] }

I think, from reading around the examples/spec a bit, collections of items use brackets to bound the collection. The examples are collections of a single item though, so it's slightly confusing at first glance. One hint at that is the keys defining those collections seems to be pluralized in all the cases I've seen so far.