From 30f8cdccc39d6fff6ae3aba25270254401b28c45 Mon Sep 17 00:00:00 2001 From: dylanhitt Date: Tue, 7 Jan 2025 23:09:01 -0500 Subject: [PATCH] chore: update gin-compat example to use engine.OutputOpenAPISpec --- examples/gin-compat/handlers.go | 6 +++--- examples/gin-compat/main.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/gin-compat/handlers.go b/examples/gin-compat/handlers.go index 907b0a1b..f4f09492 100644 --- a/examples/gin-compat/handlers.go +++ b/examples/gin-compat/handlers.go @@ -39,15 +39,15 @@ func fuegoControllerPost(c fuego.ContextWithBody[HelloRequest]) (*HelloResponse, }, nil } -func serveOpenApiJSONDescription(s *fuego.OpenAPI) func(ctx *gin.Context) { +func serveOpenAPISpec(openAPISpec []byte) func(ctx *gin.Context) { return func(ctx *gin.Context) { - ctx.JSON(http.StatusOK, s.Description()) + ctx.Data(http.StatusOK, "application/json", openAPISpec) } } func DefaultOpenAPIHandler(specURL string) gin.HandlerFunc { return func(ctx *gin.Context) { ctx.Header("Content-Type", "text/html; charset=utf-8") - ctx.String(200, fuego.DefaultOpenAPIHTML(specURL)) + ctx.String(http.StatusOK, fuego.DefaultOpenAPIHTML(specURL)) } } diff --git a/examples/gin-compat/main.go b/examples/gin-compat/main.go index 01c136ee..a05e6e77 100644 --- a/examples/gin-compat/main.go +++ b/examples/gin-compat/main.go @@ -81,7 +81,7 @@ func server() (*gin.Engine, *fuego.OpenAPI) { ) // Serve the OpenAPI spec - ginRouter.GET("/openapi.json", serveOpenApiJSONDescription(engine.OpenAPI)) + ginRouter.GET("/openapi.json", serveOpenAPISpec(engine.OutputOpenAPISpec())) ginRouter.GET("/swagger", DefaultOpenAPIHandler("/openapi.json")) return ginRouter, engine.OpenAPI