diff --git a/products/handlers/docs.go b/products/handlers/docs.go index e9d3519..5c7100b 100644 --- a/products/handlers/docs.go +++ b/products/handlers/docs.go @@ -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 diff --git a/products/handlers/routes.go b/products/handlers/routes.go index 258d664..3a1e179 100644 --- a/products/handlers/routes.go +++ b/products/handlers/routes.go @@ -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("./"))) } diff --git a/swagger.yaml b/swagger.yaml index d973d29..ac20936 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -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'