MCPcopy
hub / github.com/superplanehq/superplane / RegisterOpenAPIHandler

Method RegisterOpenAPIHandler

pkg/public/server.go:484–507  ·  view source on GitHub ↗

RegisterOpenAPIHandler adds handlers to serve the OpenAPI specification and Swagger UI

()

Source from the content-addressed store, hash-verified

482
483// RegisterOpenAPIHandler adds handlers to serve the OpenAPI specification and Swagger UI
484func (s *Server) RegisterOpenAPIHandler() {
485 swaggerFilesPath := os.Getenv("SWAGGER_BASE_PATH")
486 if swaggerFilesPath == "" {
487 log.Errorf("SWAGGER_BASE_PATH is not set")
488 return
489 }
490
491 if _, err := os.Stat(swaggerFilesPath); os.IsNotExist(err) {
492 log.Errorf("API documentation directory %s does not exist", swaggerFilesPath)
493 return
494 }
495
496 s.Router.HandleFunc(s.BasePath+"/docs", func(w http.ResponseWriter, r *http.Request) {
497 http.ServeFile(w, r, swaggerFilesPath+"/swagger-ui.html")
498 })
499
500 s.Router.HandleFunc(s.BasePath+"/docs/superplane.swagger.json", func(w http.ResponseWriter, r *http.Request) {
501 http.ServeFile(w, r, swaggerFilesPath+"/superplane.swagger.json")
502 })
503
504 log.Infof("OpenAPI specification available at %s", swaggerFilesPath)
505 log.Infof("Swagger UI available at %s", swaggerFilesPath)
506 log.Infof("Raw API JSON available at %s", swaggerFilesPath+"/superplane.swagger.json")
507}
508
509func (s *Server) RegisterWebRoutes(webBasePath string) {
510 log.Infof("Registering web routes with base path: %s", webBasePath)

Callers 2

Test__OpenAPIEndpointsFunction · 0.95
startPublicAPIFunction · 0.95

Calls 2

ErrorfMethod · 0.80
InfofMethod · 0.80

Tested by 1

Test__OpenAPIEndpointsFunction · 0.76