Files
go-worm/lib/openapi/spec_test.go
T

32 lines
794 B
Go
Raw Normal View History

package openapi
import "testing"
func TestSpec(t *testing.T) {
spec := Spec()
if spec["openapi"] != "3.0.3" {
t.Fatalf("openapi version = %v", spec["openapi"])
}
paths, ok := spec["paths"].(map[string]any)
if !ok || len(paths) < 12 {
t.Fatalf("expected at least 12 paths, got %d", len(paths))
}
if _, ok := paths["/api/v1/status"]; !ok {
t.Fatal("missing /api/v1/status")
}
if _, ok := spec["security"]; !ok {
t.Fatal("missing security")
}
components, ok := spec["components"].(map[string]any)
if !ok {
t.Fatal("missing components")
}
if _, ok := components["securitySchemes"]; !ok {
t.Fatal("missing securitySchemes")
}
schemas, ok := components["schemas"].(map[string]any)
if !ok || len(schemas) < 10 {
t.Fatalf("expected schemas, got %d", len(schemas))
}
}