disneystreaming / smithy4s

https://disneystreaming.github.io/smithy4s/
Other
339 stars 68 forks source link

Change / allow customization of `specs/` directory? #1467

Closed kubukoz closed 3 months ago

kubukoz commented 3 months ago

It appears that specs/ is a hardcoded prefix for OpenAPI files in the http4s-swagger module. My org currently stores these files in a path that's more concrete (has openapi in the name, at least). I'm asking for guidance / opinions on having more flexibility in that area.

The choices, as far as I can see, are:

What would you recommend / be willing to accept?

Baccata commented 3 months ago

change the implementation to allow passing the prefix as a parameter (low-cost and hopefully/likely binary compatible). This would be my preference.

This. We're already allowing to configure a few things via this construct, just need to add another method.

kubukoz commented 3 months ago

I apologize, the problem we were seeing was not related to the specs/ prefix: it was a bit of a mix-up. The prefix is only used for the URI used to serve the given JSON file, it's not actually part of the directory structure in the jar resources. In the jar, the openapi files just land on the top level.

That said, we're facing another problem: the JSON files are part of the codegen's source jar (where the smithy files lie), and for them to be discoverable at runtime we'd have to... well, put these files on the classpath. I see a couple options:

kubukoz commented 3 months ago

We're going with the former: removing the % Smithy4s qualifier keeps the codegen running and puts everything onto the runtime classpath, so for the short-term this is good enough for most apps. There'll likely be a build tool plugin sometime soon that'll do this in a more principled way.