guardrail-dev / guardrail

Principled code generation from OpenAPI specifications
https://guardrail.dev
MIT License
523 stars 132 forks source link

Support for cookie parameter #298

Open kimxogus opened 5 years ago

kimxogus commented 5 years ago

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.

blast-hardcheese commented 5 years ago

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

kelnos commented 5 years ago

@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.

kimxogus commented 5 years ago

@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)