Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaspopp-wbd committed Nov 20, 2024
1 parent d86c7a2 commit 9c28010
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions huma_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,12 @@ Content of example2.txt.
func TestOpenAPI(t *testing.T) {
r, api := humatest.New(t, huma.DefaultConfig("Features Test API", "1.0.0"))

type PaginationHeaders struct {
Link string `header:"link"`
}

type Resp struct {
PaginationHeaders
Body struct {
Greeting string `json:"greeting"`
}
Expand Down Expand Up @@ -1964,6 +1969,16 @@ func TestOpenAPI(t *testing.T) {

assert.Equal(t, 200, w.Code, w.Body.String())
}

t.Run("ignore-anonymous-header-structs", func(t *testing.T) {
req, _ := http.NewRequest(http.MethodGet, "/openapi.yaml", nil)
w := httptest.NewRecorder()
r.ServeHTTP(w, req)

openapiBody := w.Body.String()
assert.Equal(t, 200, w.Code, openapiBody)
assert.NotContains(t, openapiBody, "PaginationHeaders")
})
}

type IntNot3 int
Expand Down

0 comments on commit 9c28010

Please sign in to comment.