mirror of
https://github.com/rjNemo/go-microservices-tuto
synced 2026-06-10 20:36:40 +00:00
handle docs route at the router level
This commit is contained in:
parent
13a6e80ce2
commit
270de58204
3 changed files with 11 additions and 3 deletions
|
|
@ -32,7 +32,7 @@ type productResponse struct {
|
|||
Body models.Product
|
||||
}
|
||||
|
||||
// swagger:parameters deleteProduct updateProduct
|
||||
// swagger:parameters deleteProduct updateProduct getProduct
|
||||
type productIDParameter struct {
|
||||
// The ID of a product in the database
|
||||
// in: path
|
||||
|
|
|
|||
|
|
@ -28,6 +28,6 @@ func (p *Products) RegisterRoutes(m *mux.Router, path string) {
|
|||
// swagger docs
|
||||
opts := middleware.RedocOpts{SpecURL: "/swagger.yaml"}
|
||||
swaggerHandler := middleware.Redoc(opts, nil)
|
||||
getRouter.Handle("/docs", swaggerHandler)
|
||||
getRouter.Handle("/swagger.yaml", http.FileServer(http.Dir("./")))
|
||||
m.Handle("/docs", swaggerHandler).Methods(http.MethodGet)
|
||||
m.Handle("/swagger.yaml", http.FileServer(http.Dir("./")))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,14 @@ paths:
|
|||
get:
|
||||
description: Return a list of products from the database
|
||||
operationId: getProduct
|
||||
parameters:
|
||||
- description: The ID of a product in the database
|
||||
format: int64
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
x-go-name: ID
|
||||
responses:
|
||||
"200":
|
||||
$ref: '#/responses/productResponse'
|
||||
|
|
|
|||
Loading…
Reference in a new issue