Skip to content

Commit 99f24d4

Browse files
author
Amine Afia
authored
Add Swagger JSON endpoint (#87)
### TL;DR Added a new endpoint to serve Swagger JSON file. ### What changed? - Introduced a new GET route `/json` in the API. - This route serves the `swagger.json` file located in the `./docs` directory. ### How to test? 1. Start the API server. 2. Make a GET request to `http://your-api-host/json`. 3. Verify that the response is the contents of the `swagger.json` file. ### Why make this change? This change allows direct access to the Swagger JSON file, which can be useful for: - Integrating with external tools that consume Swagger/OpenAPI specifications. - Enabling developers to easily download and use the API documentation offline. - Facilitating automated testing or documentation generation processes that require the raw Swagger JSON.
1 parent 61d5b68 commit 99f24d4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cmd/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func RunApi(cmd *cobra.Command, args []string) {
4242

4343
// Add Swagger route
4444
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
45+
// Add Swagger JSON endpoint
46+
r.GET("/json", func(c *gin.Context) {
47+
c.File("./docs/swagger.json")
48+
})
4549

4650
root := r.Group("/:chainId")
4751
{

0 commit comments

Comments
 (0)