mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-09 02:47:29 +02:00
35 lines
515 B
Go
35 lines
515 B
Go
|
|
package api
|
||
|
|
|
||
|
|
import (
|
||
|
|
_ "embed"
|
||
|
|
"encoding/json"
|
||
|
|
"sync"
|
||
|
|
)
|
||
|
|
|
||
|
|
//go:embed bundled/openapi.json
|
||
|
|
var specJSON []byte
|
||
|
|
|
||
|
|
//go:embed bundled/openapi.yaml
|
||
|
|
var specYAML []byte
|
||
|
|
|
||
|
|
func SpecJSON() []byte {
|
||
|
|
return specJSON
|
||
|
|
}
|
||
|
|
|
||
|
|
func SpecYAML() []byte {
|
||
|
|
return specYAML
|
||
|
|
}
|
||
|
|
|
||
|
|
var specVersion = sync.OnceValue(func() string {
|
||
|
|
var doc struct {
|
||
|
|
Info struct {
|
||
|
|
Version string `json:"version"`
|
||
|
|
} `json:"info"`
|
||
|
|
}
|
||
|
|
_ = json.Unmarshal(SpecJSON(), &doc)
|
||
|
|
return doc.Info.Version
|
||
|
|
})
|
||
|
|
|
||
|
|
func SpecVersion() string {
|
||
|
|
return specVersion()
|
||
|
|
}
|