Skip to content

generated client (panics) fails to encode "application/x-www-form-urlencoded" request with nullable property set to nil #55

Open
@mikhalytch

Description

@mikhalytch

kin-openapi (through github.com/oapi-codegen/gin-middleware) and oapi-codegen treat nullable fields differently:

  • former wants it to be nullable: true
  • while latter enables optional functionality with skipping property name from required list

in result, the openapi component looks like

components:
  schemas:

    Filter_Active_Opt:
      properties:
        filter_active:
          type: boolean
          nullable: true

the field is generated in following way

  FilterActive *bool `"json:"filter_active"`

and generated client panics on nil value

panic: reflect: call of reflect.Value.Interface on zero Value
...
github.com/oapi-codegen/runtime/bindform.go:316 

well, since the generated server code works fine with just skipping the property from body, and since there's no common way to encode nil in formdata, I bet this may be skipped in runtime encoder

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions