-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
Route groups break docs #684
Comments
@bilus yes I don't think this is supported at the moment. You can get around it by providing your own docs route, for example setting router.Get("/docs", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
w.Write([]byte(`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="referrer" content="same-origin" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Sports API Docs</title>
<!-- Embed elements Elements via Web Component -->
<link href="https://unpkg.com/@stoplight/[email protected]/styles.min.css" rel="stylesheet" />
<script src="https://unpkg.com/@stoplight/[email protected]/web-components.min.js"
integrity="sha256-985sDMZYbGa0LDS8jYmC4VbkVlh7DZ0TWejFv+raZII="
crossorigin="anonymous"></script>
</head>
<body style="height: 100vh;">
<elements-api
apiDescriptionUrl="/v1/sports/openapi.yaml"
router="hash"
layout="sidebar"
tryItCredentialsPolicy="same-origin"
/>
</body>
</html>`))
}) This is copied from https://github.com/danielgtaylor/huma/blob/main/api.go#L451-L489 |
Hi @danielgtaylor thanks for the great library. What is the recommended way to setup the route groups without breaking docs for I'm doing something where I use the same Huma config for the whole API, but have separate structs which take in a
|
I followed the docs about Route Groups & Base URLs to group my API under
/v1/sports
. I'm using Chi and identical structure to the example.The relevant part of my code:
It generates these routes:
The problem is the docs HTML at
/v1/sports/docs
accesses theopenapi.yaml
using the following path:/openapi.yaml
producing:Setting
OpenAPIPath
doesn't help. If I uncomment the following line:...this is the routes it generates:
So now, when I'm accessing
/v1/sports/docs
, the error becomes:It's because it expects the "correct" path based on the following code in
api.go
:The text was updated successfully, but these errors were encountered: