// Vikunja is a todo-list application to facilitate your life.
// Copyright 2019 Vikunja and contributors. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//lint:file-ignore ST1018 The const below is not ours
package v1
import (
"code.vikunja.io/api/pkg/log"
"github.com/labstack/echo"
"github.com/swaggo/swag"
"net/http"
)
// DocsJSON serves swagger doc json specs
func DocsJSON(c echo.Context) error {
doc, err := swag.ReadDoc()
if err != nil {
log.Log.Error(err.Error())
return echo.NewHTTPError(http.StatusInternalServerError)
}
_, err = c.Response().Write([]byte(doc))
if err != nil {
log.Log.Error(err.Error())
return echo.NewHTTPError(http.StatusInternalServerError)
}
return nil
}
// RedocUI serves everything needed to provide the redoc ui
func RedocUI(c echo.Context) error {
return c.HTML(http.StatusOK, RedocUITemplate)
}
// RedocUITemplate contains the html + js needed for redoc ui
const RedocUITemplate = `