mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-28 01:48:51 +05:00
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:
@@ -37,8 +37,16 @@ func (h *DocsHandler) GetOpenAPISpec(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *DocsHandler) ServeDocs(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{
|
htmlContent, err := scalar.ApiReferenceHTML(&scalar.Options{
|
||||||
SpecURL: "/openapi.json",
|
SpecContent: string(specJSON),
|
||||||
CustomOptions: scalar.CustomOptions{
|
CustomOptions: scalar.CustomOptions{
|
||||||
PageTitle: "Neo Movies API Documentation",
|
PageTitle: "Neo Movies API Documentation",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user