Add OpenAPI specification support to the agent. Implement a new endpoint for serving OpenAPI documentation and refactor the existing handler to utilize the new specification. Add tests to ensure the correctness of the OpenAPI spec generation.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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")
|
||||
}
|
||||
components, ok := spec["components"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("missing components")
|
||||
}
|
||||
schemas, ok := components["schemas"].(map[string]any)
|
||||
if !ok || len(schemas) < 10 {
|
||||
t.Fatalf("expected schemas, got %d", len(schemas))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user