feat(openapi): declare json schema dialect

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-02 03:09:28 +00:00
parent e8d54797bf
commit c3143a5029
2 changed files with 7 additions and 1 deletions

View file

@ -46,6 +46,8 @@ type preparedRouteGroup struct {
descs []RouteDescription
}
const openAPIDialect = "https://spec.openapis.org/oas/3.1/dialect/base"
// Build generates the complete OpenAPI 3.1 JSON spec.
// Groups implementing DescribableGroup contribute endpoint documentation.
// Other groups are listed as tags only.
@ -57,7 +59,8 @@ func (sb *SpecBuilder) Build(groups []RouteGroup) ([]byte, error) {
prepared := prepareRouteGroups(groups)
spec := map[string]any{
"openapi": "3.1.0",
"openapi": "3.1.0",
"jsonSchemaDialect": openAPIDialect,
"info": map[string]any{
"title": sb.Title,
"description": sb.Description,

View file

@ -113,6 +113,9 @@ func TestSpecBuilder_Good_EmptyGroups(t *testing.T) {
if spec["openapi"] != "3.1.0" {
t.Fatalf("expected openapi=3.1.0, got %v", spec["openapi"])
}
if spec["jsonSchemaDialect"] != "https://spec.openapis.org/oas/3.1/dialect/base" {
t.Fatalf("expected jsonSchemaDialect to use the OpenAPI 3.1 base dialect, got %v", spec["jsonSchemaDialect"])
}
// Verify /health path exists.
paths := spec["paths"].(map[string]any)