Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for header:"..." struct tags so request headers can be bound into handler input structs and emitted as OpenAPI parameters (with header-tagged fields excluded from request-body schemas).
Changes:
- Parse request headers into input structs via a new
parseHeaderParamsstep inparseInput. - Generate OpenAPI parameters for
header-tagged fields and exclude them from request-body schema generation. - Add tests and update examples/dependency metadata to demonstrate header parameters.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| header_params_test.go | Adds coverage for header binding + OpenAPI parameter generation (including pointer-type schema expectations). |
| fiberoapi.go | Excludes header-tagged fields from request body schema generation. |
| common.go | Adds header parsing and OpenAPI extraction for header tags. |
| _examples/simple/main.go | Demonstrates using a required header parameter in an example route. |
| _examples/simple/go.mod | Updates example module metadata and adds a local replace for development. |
| _examples/simple/go.sum | Updates example dependency checksums after module changes. |
| _examples/auto_params/go.mod | Dependency version bumps in example module. |
| _examples/auto_params/go.sum | Dependency checksum updates for example module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
common.go:53
parseInputbinds header params before callingc.BodyParser(&input). BecauseBodyParserruns afterwards, a request body can overwrite fields that are meant to come from headers (and can even satisfyvalidate:"required"without the header being present). This also conflicts with the OpenAPI generation which now excludesheader-tagged fields from the request-body schema. Consider preventing body parsing from touchingpath/query/header-tagged fields (e.g., custom unmarshal that skips them), or parsing the body into a separate struct and then overlaying path/query/header values with presence checks for required header fields.
// Parse header parameters
err = parseHeaderParams(c, &input)
if err != nil {
return input, err
}
// Parse body for POST/PUT methods only if there's content
method := c.Method()
if method == "POST" || method == "PUT" || method == "PATCH" {
// Check if there's content in the body
bodyLength := len(c.Body())
contentType := c.Get("Content-Type")
// Parse the body if there's content OR if it's a POST/PUT/PATCH with specified Content-Type
if bodyLength > 0 || strings.Contains(contentType, "application/json") || strings.Contains(contentType, "application/x-www-form-urlencoded") {
err = c.BodyParser(&input)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Enhance input handling by adding support for header parameters