smithy-lang / smithy

Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
https://smithy.io
Apache License 2.0
1.7k stars 201 forks source link

Feature request: SmithyBuildConfig -> Model utility #2292

Open kubukoz opened 1 month ago

kubukoz commented 1 month ago

There are a lot of tools that could be built on top of Smithy, which would use smithy-build.json as the source of information about a model.

Currently, in order to do so they would have to either:

I think it would be beneficial for the ecosystem to have more out-of-the-box support for loading a build config into a model. Presumably, this would have to be part of smithy-build.

kstich commented 3 weeks ago

Are you looking for more than what's exposed in the SmithyBuildConfig class? If so, can you elaborate on what differences you're looking for?

kubukoz commented 3 weeks ago

yes, I looked at the class, and it's useful as a way of reading the build files, but one still has to implement the loading of such a build config into a model - that's the missing part (as far as I can tell).

so, in pseudocode:

Path file = ...;
SmithyBuildConfig bc = SmithyBuildConfig.load(file);

// we don't have this
Model model = Model.fromBuildConfig(bc).assemble().unwrap();
// alternative syntax
Model model = bc.load().assemble().unwrap();
// another one
Model model = SmithyBuildConfig.load(bc).assemble().unwrap()
// also, the methods currently are shown to return ModelAssembler, but maybe it makes sense to return a ValidatedResult<Model> instead.