Last year I added the basics for an OpenAPI backen...
# development
n
Last year I added the basics for an OpenAPI backend that I was planning to pick up again now that I have a bit more time on my hands. A good way to make sure it’s actually usable is to dogfood it in my day-to-day, and in order to solve one of our use cases I could use some input on
resource
like behaviour --> 🧵
Basically we currently have our OpenAPI documents as
resource
because our Python APIs use them for request and response validation, and thus we want them to be bundled in the PEX. The “problem” is that if my Python code has a dependency on the OpenAPI target(s), those files don’t seem to become part of the PEX itself. So, the question is... How do I get those targets to behave more like
resource
? Ideally I would just add that my
python_source
depends on the
openapi_document
and then the dependency inference would make sure that my PEX contains the
openapi_document
as well as all relevant
openapi_sources
. But... Do I really want those tragets to behave more like
resource
? I mean, I do obviously, but I imagine it’s maybe not something everyone that’s using the OpenAPI backend wants? I could in my repository have both
openapi_source
and
resource
targets, but then I’d have to manage dependencies between
resource
and
openapi_source
manually - missing out on that sweet dependency inference I get if my Python code depends on the
openapi_document
directly. Or... maybe I’m missing something? Help! 🙈
b
I know there has been talk previously of removing the file vs resource distinction. I don’t know where this has ended up (and I’m not the right person to ask), but OpenAPI sources behaving like resources for everyone doesn’t seem at all unreasonable. On the face, I imagine they’d either be used for: • in-code validation etc as you do • code generation with
shell_command
or
adhoc_tool
etc, where the file vs resource distinction doesn’t matter so much, I think
n
Fair enough! Then the follow-up question is, how do I get a target to behave like a resource? 🤔
b
That's a question beyond my knowledge, unfortunately (other than jumping around the codebase to find how
resource
is implemented...)