smithy4s icon indicating copy to clipboard operation
smithy4s copied to clipboard

How to generate open api file using the cli tool

Open ShahOdin opened this issue 3 years ago • 7 comments

I'm looking at: https://disneystreaming.github.io/smithy4s/docs/overview/cli and trying to generate the open api from the smithy files. in a custom directory taking the structure introduced in the quick start example as the starting point.

For a service PlaygroundService with multiple operations Choice,CreateCustomer,Hello:

playground % tree -I target

.
└── src
    └── main
        └── smithy
            ├── Choice.smithy
            ├── CreateCustomer.smithy
            ├── Hello.smithy
            └── PlaygroundService.smithy
└── temp
  • I tried the following from the top directory ^:

    smithy4s generate \
    --output ./temp/ \
    --resource-output ./temp \
    --discover-models
    

    I simply get blank files generated under temp/META-INF.

  • I tried cd ing to ./src/main/smithy and re-ran the above. again. nothing.

  • I played around with the -- repositories and -- dependencies options with no luck.

What am I missing? Would be great if you could add a minimal example in the docs as well.

ShahOdin avatar Nov 03 '22 21:11 ShahOdin

I think you need to pass ./src or, to be more precise, ./src/main/smithy, as the positional argument to generate. You also probably don't need --discover-models.

This would be sth like smithy4s generate ./src --output ./temp --resource-output ./temp

kubukoz avatar Nov 03 '22 22:11 kubukoz

D'oh! that does it @kubukoz thank you. :) shall I still keep the issue open for the docs to make this clearer?

ShahOdin avatar Nov 03 '22 22:11 ShahOdin

yeah, I think that's a good idea. Would you like to make that change in the docs?

kubukoz avatar Nov 03 '22 23:11 kubukoz

I saw this and wondered: should the CLI behave as it is right now?

In other words: when given no input:

  • no specs file (positional arguments here)
  • no local jar files (named argument --localJars)
  • no dependencies (named argument --dependencies)

Should we return an error?

daddykotex avatar Nov 22 '22 14:11 daddykotex

probably yes

Baccata avatar Nov 22 '22 15:11 Baccata

I think we should at least log something. An error is fine as long as it's only for CLI usage, not programmatic codegen usage

kubukoz avatar Nov 22 '22 16:11 kubukoz

I closed my PR because in the series/0.17, we have a default dependencies, so my check was always false :/ Maybe a warning we have the model in hand and we realize that it contains no shapes is enough

daddykotex avatar Nov 22 '22 19:11 daddykotex

Is there anything else we want to do here or can the ticket be closed?

kubukoz avatar Jan 17 '23 18:01 kubukoz