fix: Generate OpenAPI spec inline instead of file reference

- Use SpecContent with marshaled JSON instead of SpecURL
- Prevents 'open /openapi.json: no such file or directory' error
- Documentation now loads properly on all domains
This commit is contained in:
2025-10-18 21:35:34 +00:00
parent 31165ceeac
commit 4a50bfd96d

View File

@@ -37,8 +37,16 @@ func (h *DocsHandler) GetOpenAPISpec(w http.ResponseWriter, r *http.Request) {
}
func (h *DocsHandler) ServeDocs(w http.ResponseWriter, r *http.Request) {
spec := getOpenAPISpecWithURL("/")
specJSON, err := json.Marshal(spec)
if err != nil {
fmt.Printf("Error marshaling OpenAPI spec: %v", err)
http.Error(w, fmt.Sprintf("Error marshaling spec: %v", err), http.StatusInternalServerError)
return
}
htmlContent, err := scalar.ApiReferenceHTML(&scalar.Options{
SpecURL: "/openapi.json",
SpecContent: string(specJSON),
CustomOptions: scalar.CustomOptions{
PageTitle: "Neo Movies API Documentation",
},