feat(swagger): Add swagger API doc (#1926)

* makefile(build): add minimal and api build target

* feat(swagger): Add swagger
This commit is contained in:
Ettore Di Giacinto 2024-03-29 22:29:33 +01:00 committed by GitHub
parent ab2f403dd0
commit 123a5a2e16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 2264 additions and 25 deletions

View file

@ -7,6 +7,7 @@ import (
"strings"
"github.com/go-skynet/LocalAI/pkg/utils"
"github.com/gofiber/swagger" // swagger handler
"github.com/go-skynet/LocalAI/core/http/endpoints/elevenlabs"
"github.com/go-skynet/LocalAI/core/http/endpoints/localai"
@ -42,6 +43,20 @@ func readAuthHeader(c *fiber.Ctx) string {
return authHeader
}
// @title LocalAI API
// @version 2.0.0
// @description The LocalAI Rest API.
// @termsOfService
// @contact.name LocalAI
// @contact.url https://localai.io
// @license.name MIT
// @license.url https://raw.githubusercontent.com/mudler/LocalAI/master/LICENSE
// @host localhost:8080
// @BasePath /
// @securityDefinitions.apikey BearerAuth
// @in header
// @name Authorization
func App(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfig *config.ApplicationConfig) (*fiber.App, error) {
// Return errors as JSON responses
app := fiber.New(fiber.Config{
@ -170,6 +185,8 @@ func App(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfig *confi
utils.LoadConfig(appConfig.ConfigsDir, openai.AssistantsConfigFile, &openai.Assistants)
utils.LoadConfig(appConfig.ConfigsDir, openai.AssistantsFileConfigFile, &openai.AssistantFiles)
app.Get("/swagger/*", swagger.HandlerDefault) // default
welcomeRoute(
app,
cl,