Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mikhalytch opened this issue Dec 26, 2024 · 0 comments

Comments

@mikhalytch
Copy link

mikhalytch commented Dec 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant