| 133 | } |
| 134 | |
| 135 | func TestNewAPI(t *testing.T) { |
| 136 | var api huma.API |
| 137 | _, api = New(t, huma.DefaultConfig("Test", "1.0.0")) |
| 138 | |
| 139 | // Should be able to wrap and call utility methods. |
| 140 | wrapped := Wrap(t, api) |
| 141 | wrapped.Get("/") |
| 142 | wrapped.Post("/") |
| 143 | wrapped.Put("/") |
| 144 | wrapped.Patch("/") |
| 145 | wrapped.Delete("/") |
| 146 | |
| 147 | assert.Panics(t, func() { |
| 148 | // Invalid param type (only string headers and io.Reader bodies are allowed) |
| 149 | wrapped.Post("/", 1234) |
| 150 | }) |
| 151 | } |
| 152 | |
| 153 | func TestDumpBodyError(t *testing.T) { |
| 154 | req := httptest.NewRequest(http.MethodGet, "http://example.com/foo?bar=baz", nil) |