guardrail icon indicating copy to clipboard operation
guardrail copied to clipboard

Support for cookie parameter

Open kimxogus opened this issue 6 years ago • 3 comments

https://swagger.io/docs/specification/describing-parameters/#cookie-parameters

I generated scala akka-http routes with cookie parameter

      - name: _session
        in: cookie
        required: false
        schema:
          type: string

But cookie parameter is not shown in generated code.

kimxogus avatar May 21 '19 03:05 kimxogus

Hey @kimxogus, thanks for the report!

It's somewhat alarming that this doesn't work, as https://github.com/twilio/guardrail/blob/3066dfd6b456ed2c9964831407cc743a7965b8af/modules/codegen/src/main/scala/com/twilio/guardrail/generators/ScalaParameter.scala#L98-L99 would otherwise suggest that the functionality should be supported. Would you be available to dig in a bit and figure out why this isn't working as designed?

As a workaround, I'd expect

- name: Cookie
  in: header
  schema:
    type: string

and putting s"_session=${cookieEscapedValue}" as the header value would at the very least unblock you

blast-hardcheese avatar May 22 '19 00:05 blast-hardcheese

@blast-hardcheese My guess is this doesn't work because we just don't do anything with the cookie params in the actual code generators. https://github.com/twilio/guardrail/blob/master/modules/codegen/src/main/scala/com/twilio/guardrail/generators/ScalaParameter.scala#L18-L22 suggests that we don't even look at them, and I don't see any specific cookie handling in the codegen.

kelnos avatar May 22 '19 00:05 kelnos

@kelnos Yes, it seems that cookie params are not handled in https://github.com/twilio/guardrail/blob/master/modules/codegen/src/main/scala/com/twilio/guardrail/generators/ScalaParameter.scala#L18-L22 and all generators(akka, https in both java and scala)

kimxogus avatar May 22 '19 02:05 kimxogus