smithy icon indicating copy to clipboard operation
smithy copied to clipboard

Feature request: SmithyBuildConfig -> Model utility

Open kubukoz opened this issue 1 year ago • 2 comments

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:

  • shell out to the CLI (which is costly, including but not only because of having to start another JVM), or
  • duplicate some of its logic: this is what the LSP seems to be doing at the moment, just like smithy4s / smithy-playground (OSS projects I'm involved with), and some projects I'm involved in at work.

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.

kubukoz avatar May 17 '24 21:05 kubukoz

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?

kstich avatar Jun 04 '24 20:06 kstich

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.

kubukoz avatar Jun 05 '24 16:06 kubukoz