Skip to content

1.12.0+ Required Query Params parsing fails #856

@FloppyNotFound

Description

@FloppyNotFound

Starting from v1.12.0, generation fails, if the YAML includes required query params.

Example YAML:

openapi: "3.0.0"

info:
  version: 1.0.0
  title: Lorem Ipsum

paths:
  /lorem-ipsum:
    get:
      summary: Lorem Ipsum
      parameters:
        - in: query
          name: amount
          required: true
          schema:
            type: number
      responses:
        200:
          description: Success

Example calls:

./oapi-codegen -generate types -o api/api.types.gen.go -package api my.api.yaml
./oapi-codegen -generate gin,spec -o api/api.gen.go -package api my.api.yaml

Error message:
api\api.gen.go:150:7: siw.ErrorHandler(c, fmt.Errorf("Query argument amount is required, but not found: %s", err), http.StatusBadRequest) (no value) used as value

Environment:
$ go version
go version go1.18.6 windows/amd64

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