mirror of
https://github.com/rjNemo/go-microservices-tuto
synced 2026-06-06 02:16:46 +00:00
148 lines
3.6 KiB
YAML
148 lines
3.6 KiB
YAML
basePath: /
|
|
consumes:
|
|
- application/json
|
|
definitions:
|
|
Product:
|
|
description: Product defines the structure of a product
|
|
properties:
|
|
description:
|
|
description: the description for this poduct
|
|
maxLength: 10000
|
|
type: string
|
|
x-go-name: Description
|
|
id:
|
|
description: the id for this product
|
|
format: int64
|
|
minimum: 1
|
|
type: integer
|
|
x-go-name: ID
|
|
name:
|
|
description: the name for this poduct
|
|
maxLength: 255
|
|
type: string
|
|
x-go-name: Name
|
|
price:
|
|
description: the price for the product
|
|
format: float
|
|
minimum: 0.01
|
|
type: number
|
|
x-go-name: Price
|
|
sku:
|
|
description: the SKU for the product
|
|
pattern: '[a-z]+-[a-z]+-[a-z]+'
|
|
type: string
|
|
x-go-name: SKU
|
|
required:
|
|
- id
|
|
- name
|
|
- price
|
|
- sku
|
|
type: object
|
|
x-go-package: github.com/rjNemo/go-micro/products/models
|
|
info:
|
|
description: Documentation for Product API
|
|
title: Product API
|
|
version: 1.0.0
|
|
paths:
|
|
/products:
|
|
get:
|
|
description: Return a list of products from the database
|
|
operationId: listProducts
|
|
responses:
|
|
"200":
|
|
$ref: '#/responses/productsResponse'
|
|
tags:
|
|
- products
|
|
post:
|
|
description: Create a new product
|
|
operationId: createProduct
|
|
responses:
|
|
"200":
|
|
$ref: '#/responses/productResponse'
|
|
"422":
|
|
$ref: '#/responses/errorValidation'
|
|
"501":
|
|
$ref: '#/responses/errorResponse'
|
|
tags:
|
|
- products
|
|
/products/{id}:
|
|
delete:
|
|
description: Update a products details
|
|
operationId: deleteProduct
|
|
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:
|
|
"204":
|
|
$ref: '#/responses/noContent'
|
|
"404":
|
|
$ref: '#/responses/errorResponse'
|
|
"501":
|
|
$ref: '#/responses/errorResponse'
|
|
tags:
|
|
- products
|
|
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'
|
|
"404":
|
|
$ref: '#/responses/errorResponse'
|
|
tags:
|
|
- products
|
|
put:
|
|
description: Update a products details
|
|
operationId: updateProduct
|
|
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:
|
|
"204":
|
|
$ref: '#/responses/noContent'
|
|
"404":
|
|
$ref: '#/responses/errorResponse'
|
|
"422":
|
|
$ref: '#/responses/errorValidation'
|
|
tags:
|
|
- products
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
errorResponse:
|
|
description: Generic error message returned as a string
|
|
errorValidation:
|
|
description: Validation errors defined as an array of strings
|
|
noContent:
|
|
description: empty response
|
|
productResponse:
|
|
description: product in the response.
|
|
schema:
|
|
$ref: '#/definitions/Product'
|
|
productsResponse:
|
|
description: list of products in the response.
|
|
schema:
|
|
items:
|
|
$ref: '#/definitions/Product'
|
|
type: array
|
|
schemes:
|
|
- http
|
|
swagger: "2.0"
|