Skip to content
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

Defining Servers Causes 404 from OpenAPI Endpoint #443

Open
derekssmith opened this issue May 17, 2024 · 1 comment
Open

Defining Servers Causes 404 from OpenAPI Endpoint #443

derekssmith opened this issue May 17, 2024 · 1 comment
Labels
question Further information is requested

Comments

@derekssmith
Copy link

When I add servers to the OpenAPI configuration the docs page will not load because the openapi.json call returns a 404.

apiConfig := huma.DefaultConfig("My API V1", "1.0.0")
apiConfig.Info.Description = apiDescription

apiConfig.Servers = append(apiConfig.Servers, &huma.Server{
    URL:         "https://myapi.beta.mydomain.com/v1",
    Description: "Beta Server",
})
@danielgtaylor
Copy link
Owner

@derekssmith this is intended to be used with the route groups and base URL settings as described here:

https://huma.rocks/features/bring-your-own-router/#route-groups-base-urls

Typically you'd set up a route group with the /v1 path and then the docs & OpenAPI will be served from there as well. Huma itself doesn't apply any prefix from the server list because it could happen either at the gateway or within the router itself, and this provides the most flexibility for setting up those various scenarios. Hopefully that helps!

@danielgtaylor danielgtaylor added the question Further information is requested label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants