Skip to content

Commit

Permalink
Stoplight docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Raajheer1 committed Oct 9, 2024
1 parent 950a2d4 commit e2cb791
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions external/docs/docs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VATUSA API Docs</title>
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">

<style>
/* Set the body and html to use full height */
html, body {
margin: 0;
padding: 0;
height: 100%;
}

/* Ensure the elements-api component takes up full height */
elements-api {
display: block;
height: 100%;
}
</style>
</head>
<body>
<!-- The API component will take up the entire screen -->
<elements-api
apiDescriptionUrl="/swagger/doc.json"
router="hash"
/>
</body>
</html>
5 changes: 5 additions & 0 deletions external/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/VATUSA/primary-api/pkg/config"
"github.com/go-chi/chi/v5"
httpSwagger "github.com/swaggo/http-swagger"
"net/http"
"strings"
)

Expand Down Expand Up @@ -43,4 +44,8 @@ func Router(r chi.Router, cfg *config.Config) {
r.Get("/swagger/*", httpSwagger.Handler(
httpSwagger.URL(fmt.Sprintf("%s/swagger/doc.json", config.Cfg.API.BaseURL)),
))

r.Get("/docs", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "./external/docs/docs.html")
})
}

0 comments on commit e2cb791

Please sign in to comment.