Reference

This guide will show you how to document your API using your OpenAPI specification and the Scalar Web UI.

Serve a Scalar Web UI

Simply use app.Reference to serve the Scalar Web UI.

package main

import (
  "github.com/abyanmajid/matcha"
  "github.com/abyanmajid/matcha/openapi"
  "github.com/abyanmajid/matcha/reference"
)

func main() {
  app := matcha.New()

  app.Documentation("/docs", openapi.Meta{
    OpenAPI:        "3.0.0",
    PackageName:    "My API",
    PackageVersion: "0.1.0",
  })

  app.Reference("/reference", &reference.Options{
    Source: "/docs",
  })

  // Register your resources here
  // ...

  app.Serve(":8080")
}

Optional Configurations

FieldTypeDefault Value
PageTitlestring"API Reference"
CDNstringDefaultCDN
Theme"default", "alternate", "moon", "purple", "solarized", "bluePlanet", "deepSpace", "saturn", "kepler", "mars", "none", """kepler"
Layout"modern", "classic""classic"
Sourcestring""
SpecContentinterface{}nil
Proxystring""
IsEditableboolfalse
ShowSidebarbooltrue
HideModelsboolfalse
HideDownloadButtonboolfalse
DarkModebooltrue
SearchHotKeystring"/"
MetaDatastring""
HiddenClients[]stringnil
CustomCssstring""
Authenticationstring""
PathRoutingstring""
BaseServerURLstring""
WithDefaultFontsboolfalse