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

1.12.0+ Required Query Params parsing fails #856

Closed
FloppyNotFound opened this issue Nov 14, 2022 · 2 comments
Closed

1.12.0+ Required Query Params parsing fails #856

FloppyNotFound opened this issue Nov 14, 2022 · 2 comments

Comments

@FloppyNotFound
Copy link

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

@schoenenberg
Copy link

schoenenberg commented Nov 26, 2022

Had the same issue. Upgrading to newest version fixed it for me (see also #864 and #857).

@FloppyNotFound
Copy link
Author

Can confirm that this issue seems to be fixed in version v1.12.3

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

2 participants