guardrail icon indicating copy to clipboard operation
guardrail copied to clipboard

Support templating in server base URL

Open fancywriter opened this issue 6 years ago • 3 comments

If I try to generate code from openapi 3.0.0 with server templating https://swagger.io/docs/specification/api-host-and-base-path/ I am getting URISyntaxException from guardrail.

Seems that templating is not supported yet. Would be great to do.

fancywriter avatar Apr 16 '20 10:04 fancywriter

I can confirm this feature is not supported yet, I've been recently trying to use it too. Looking forward to it!

francescopellegrini avatar Apr 16 '20 13:04 francescopellegrini

Exposing these as parameters seems like it would be fairly straightforward, and considering the interpolation would just be named the same as what's in the spec, we can use the same techniques we use to avoid name conflicts for parameters.

I believe it would be sufficient to add another classification of parameter here, then make the requisite changes here in order to interpolate those parameters.

This will require dealing with the URL parser logic, written in atto, which may seem particularly tricky at first, but you'll only need to alter how the base path, the initial case before anything else is interpolated, is handled, so it should be easier than having to modify how the parser works more broadly.

If someone is interested in picking this up, I'm happy to provide some more guidance in how best to handle the parametricity. (It may be useful, for example, to establish an enumeration of possible static parameters that have their own arguments, if applicable. Getting the ergonomics for how this would both look and be most stable over time is paramount)

blast-hardcheese avatar Feb 09 '21 02:02 blast-hardcheese

Work has started on this in support of closing modeling gaps before the 1.0.0 release.

(working branch: blast-hardcheese/proper-server-handling)

blast-hardcheese avatar Dec 18 '23 08:12 blast-hardcheese