mirror of
https://github.com/Fishwaldo/huma.git
synced 2025-03-15 19:31:27 +00:00
ensure the dom contains the prefixed path to the openapi file
This commit is contained in:
parent
ef83dce725
commit
75d43f149d
1 changed files with 3 additions and 22 deletions
|
@ -267,29 +267,9 @@ func TestRouter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRouterDocsPrefix(t *testing.T) {
|
||||
type EchoResponse struct {
|
||||
Value string `json:"value" description:"The echoed back word"`
|
||||
}
|
||||
|
||||
r := NewTestRouter(t, DocsRoutePrefix("/prefix"))
|
||||
|
||||
r.Resource("/echo",
|
||||
PathParam("word", "The word to echo back"),
|
||||
QueryParam("greet", "Return a greeting", false),
|
||||
ResponseJSON(http.StatusOK, "Successful echo response"),
|
||||
ResponseError(http.StatusBadRequest, "Invalid input"),
|
||||
).Put("Echo back an input word.", func(word string, greet bool) (*EchoResponse, *ErrorModel) {
|
||||
if word == "test" {
|
||||
return nil, &ErrorModel{Detail: "Value not allowed: test"}
|
||||
}
|
||||
|
||||
v := word
|
||||
if greet {
|
||||
v = "Hello, " + word
|
||||
}
|
||||
|
||||
return &EchoResponse{Value: v}, nil
|
||||
})
|
||||
r := NewRouter("api", "v", DocsRoutePrefix("/prefix"))
|
||||
r.Resource("/hello").Get("doc", func() string { return "Hello" })
|
||||
|
||||
// Check spec & docs routes
|
||||
w := httptest.NewRecorder()
|
||||
|
@ -301,6 +281,7 @@ func TestRouterDocsPrefix(t *testing.T) {
|
|||
req, _ = http.NewRequest(http.MethodGet, "/prefix/docs", nil)
|
||||
r.ServeHTTP(w, req)
|
||||
assert.Equal(t, http.StatusOK, w.Code)
|
||||
assert.Contains(t, "prefix/openapi", w.Body.String())
|
||||
}
|
||||
|
||||
func TestRouterRequestBody(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue