Skip to content

Regression: "required" not respected for query parameters #2403

Description

@mvodanovic

I have this in my openapi.yaml:

parameters:
  - in: query
    name: custom_date
    required: true
    schema:
      type: string
      format: date

The auto-generated handler fails to return an error if the parameter isn't given in the request. This worked fine before, when we were using version 2.6.0, but it doesn't work on 2.7.1.

I think the bug is in runtime/bindparam.go around line 479. The code looks like this:

if !fieldsPresent {
    return nil
}

But it should look like this:

if !fieldsPresent {
    if required {
        return &RequiredParameterError{ParamName: paramName}
    } else {
        return nil
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions