LiveRamp / reslang

A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.
Apache License 2.0
23 stars 7 forks source link

Cannot return resources when performing actions #53

Closed lr-conrs closed 4 years ago

lr-conrs commented 4 years ago

During iteration, noticed what may be a problem with Reslang.

As a response to an action, I wish to return a resource. Thus, the response is defined:

            "Created" 201
                TheResourceName

However, the OpenApi generated apparently generates a schema for TheResourceNameOutput but not TheResourceName. Thus, this structure generates an invalid open API spec. Attempting to change the above code snippet to TheResourceNameOutput, however, will cause Reslang to complain.

liveandrew commented 4 years ago

working on it. tbh i'd never even though to do this, it's a very innovative use of reslang ;-P i love it when i see people using it in unusual and clever ways

lr-conrs commented 4 years ago

Haha, yeah, it was an attempt at a solution where we wanted to create a resource, but its return structure was substantially different than its request payload. So output, or even introducing the concept of input wouldn't work. Plus, they felt sort of like a cheat anyway. I might even go so far as to advocate for its removal or linting against using it more than N times in a structure)

That said, as we iterate on our modelling, we might not actually end up returning the resource here, could always return a custom structure instead that happens to contain the ID for the created resource anyway.

liveandrew commented 4 years ago

fixed in 0edd270d552572ac55cdb85775c4c0790b0d5d90

lr-conrs commented 4 years ago

Thanks Andrew! Sorry I couldn't help on this one, too many plates to juggle 😅

liveandrew commented 4 years ago

no worried at all, it relied on some deep internals that i haven't explained yet, so it's all good