{"id":28075242,"url":"https://github.com/yoketh/gofiber-scalar","last_synced_at":"2026-02-16T03:24:03.335Z","repository":{"id":292880835,"uuid":"982245745","full_name":"yokeTH/gofiber-scalar","owner":"yokeTH","description":"scalar alternative to swagger for gofiber","archived":false,"fork":false,"pushed_at":"2025-10-05T21:19:21.000Z","size":7682,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T22:24:17.488Z","etag":null,"topics":["gofiber","golang","openapi","scalar","swagger"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yokeTH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-12T15:32:26.000Z","updated_at":"2025-10-05T21:19:21.000Z","dependencies_parsed_at":"2025-05-13T00:55:39.204Z","dependency_job_id":"a327777c-c269-4835-a2a0-72f2ecbdfc1c","html_url":"https://github.com/yokeTH/gofiber-scalar","commit_stats":null,"previous_names":["yoketh/gofiber-scalar"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/yokeTH/gofiber-scalar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokeTH%2Fgofiber-scalar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokeTH%2Fgofiber-scalar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokeTH%2Fgofiber-scalar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokeTH%2Fgofiber-scalar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yokeTH","download_url":"https://codeload.github.com/yokeTH/gofiber-scalar/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokeTH%2Fgofiber-scalar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278778968,"owners_count":26044256,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gofiber","golang","openapi","scalar","swagger"],"created_at":"2025-05-13T00:55:35.767Z","updated_at":"2026-02-01T21:12:54.896Z","avatar_url":"https://github.com/yokeTH.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!NOTE]\n\u003e Fiber v3 is currently in development and in the release candidate (RC) stage. Since gofiber-scalar follows the same release cycle, it is also in RC. If you’re using Fiber v3, install it with: `go get -u github.com/yokeTH/gofiber-scalar/scalar/v3`\n\u003e The stable version of Fiber v3 will be released next week. GoFiber-Scalar The primary branch will be v3, and v2 will no longer be maintained.\n\n# Gofiber Scalar\n\nScalar middleware for [Fiber](https://github.com/gofiber/fiber). The middleware handles Scalar UI.\n\n**Note: Requires Go 1.23.0 and above**\n\n### Table of Contents\n- [Signatures](#signatures)\n- [Installation](#installation)\n- [Examples](#examples)\n- [Config](#config)\n- [Default Config](#default-config)\n- [Constants](#Constants)\n\n### Signatures\n```go\nfunc New(config ...scalar.Config) fiber.Handler\n```\n\n### Installation\nScalar is tested on the latest [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:\n```bash\ngo mod init github.com/\u003cuser\u003e/\u003crepo\u003e\n```\nAnd then install the Scalar middleware:\n```bash\ngo get -u github.com/yokeTH/gofiber-scalar/scalar/v2\n```\n\n### Examples\nUsing swaggo to generate documents default output path is `(root)/docs`:\n```bash\nswag init\n# if you use swag-v2\nswag init -v3.1\n```\n\nImport the middleware package and generated docs\n```go\nimport (\n  _ \"YOUR_MODULE/docs\"\n\n  \"github.com/gofiber/fiber/v2\"\n  \"github.com/yokeTH/gofiber-scalar/scalar/v2\"\n)\n```\n\nAfter Imported:\n\n\u003e For v2, you do not need to register Swag docs manually.\n\n#### Using the default config:\n```go\napp.Get(\"/docs/*\", scalar.New())\n```\nNow you can access scalar API documentation UI at `{HOSTNAME}/docs` and JSON documentation at `{HOSTNAME}/docs/doc.json`. Additionally, you can modify the path by configuring the middleware to suit your application's requirements.\n\nUsing as the handler: for an example `localhost:8080/yourpath`\n\n```go\napp.Get(\"/yourpath/*\", scalar.New(scalar.Config{\n\tPath:     \"/yourpath\",\n}))\n```\n\n#### Use program data for Swagger content:\n```go\ncfg := scalar.Config{\n    BasePath:          \"/\",\n    FileContentString: jsonString,\n    Path:              \"/scalar\",\n    Title:             \"Scalar API Docs\",\n}\n\napp.Get(\"/scalar/*\",scalar.New(cfg))\n```\n\n#### Use scalar prepared theme\n```go\ncfg := scalar.Config{\n    Theme:    scalar.ThemeMars,\n}\n\napp.Get(\"/docs/*\",scalar.New(cfg))\n```\n\n#### Path based reverse proxy\n\nAssuming `/api` is your reverse path, the configuration will use the following order to determine the path:\n\n1. `X-Forwarded-Prefix`\n2. `X-Forwarded-Path`\n3. `BasePath` (fallback if the headers are not set)\n\nIf you cannot configure the headers, you can use `BasePath` as a fallback. Note that this may break in a localhost environment. Example implementation:\n\n```go\ncfg = scalar.Config{}\nif os.Getenv(\"APP_ENV\") == \"PROD\" {\n    cfg.BasePath = \"/api\"\n}\n```\n\n\n### Config\n```go\ntype Config struct {\n\t// BasePath for the UI path\n\t//\n\t// Optional. Default: /\n\tBasePath string\n\n\t// FileContent for the content of the swagger.json or swagger.yaml file.\n\t//\n\t// Optional. Default: nil\n\tFileContentString string\n\n\t// Path combines with BasePath for the full UI path\n\t//\n\t// Optional. Default: docs\n\tPath string\n\n\t// Title for the documentation site\n\t//\n\t// Optional. Default: Fiber API documentation\n\tTitle string\n\n\t// CacheAge defines the max-age for the Cache-Control header in seconds.\n\t//\n\t// Optional. Default: 1 min\n\tCacheAge int\n\n\t// Scalar theme\n\t//\n\t// Optional. Default: ThemeNone\n\tTheme Theme\n\n\t// Custom Scalar Style\n\t// Ref: https://github.com/scalar/scalar/blob/main/packages/themes/src/variables.css\n\t// Optional. Default: \"\"\n\tCustomStyle template.CSS\n\n\t// Proxy to avoid CORS issues\n\t// Optional.\n\tProxyUrl string\n\n\t// Raw Space Url\n\t// Optional. Default: doc.json\n\tRawSpecUrl string\n\n\t// ForceOffline\n\t// Optional: Default: ForceOfflineTrue\n\tForceOffline *bool\n\n\t// Fallback scalar cache\n\t//\n\t// Optional. Default: 86400 (1 Days)\n\tFallbackCacheAge int\n}\n```\n\n### Default Config\n```go\nvar configDefault = Config{\n\tBasePath:         \"/\",\n\tPath:             \"docs\",\n\tTitle:            \"Fiber API documentation\",\n\tCacheAge:         60,\n\tTheme:            ThemeNone,\n\tRawSpecUrl:       \"doc.json\",\n\tForceOffline:     ForceOfflineTrue,\n\tFallbackCacheAge: 86400,\n}\n```\n\n### Constants\nTheme\n```go\nconst (\n\tThemeAlternate  Theme = \"alternate\"\n\tThemeDefault    Theme = \"default\"\n\tThemeMoon       Theme = \"moon\"\n\tThemePurple     Theme = \"purple\"\n\tThemeSolarized  Theme = \"solarized\"\n\tThemeBluePlanet Theme = \"bluePlanet\"\n\tThemeSaturn     Theme = \"saturn\"\n\tThemeKepler     Theme = \"kepler\"\n\tThemeMars       Theme = \"mars\"\n\tThemeDeepSpace  Theme = \"deepSpace\"\n\tThemeLaserwave  Theme = \"laserwave\"\n\tThemeNone       Theme = \"none\"\n)\n\nvar (\n\tForceOfflineTrue  = ptr(true)\n\tForceOfflineFalse = ptr(false)\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoketh%2Fgofiber-scalar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoketh%2Fgofiber-scalar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoketh%2Fgofiber-scalar/lists"}