265 lines
8.4 KiB
JSON
265 lines
8.4 KiB
JSON
|
{
|
||
|
"swagger": "2.0",
|
||
|
"info": {
|
||
|
"description": "This is a sample server celler server.",
|
||
|
"title": "Swagger Example API",
|
||
|
"termsOfService": "http://swagger.io/terms/",
|
||
|
"contact": {
|
||
|
"name": "API Support",
|
||
|
"url": "http://www.swagger.io/support",
|
||
|
"email": "support@swagger.io"
|
||
|
},
|
||
|
"license": {
|
||
|
"name": "Apache 2.0",
|
||
|
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||
|
},
|
||
|
"version": "1.0"
|
||
|
},
|
||
|
"host": "localhost:9000",
|
||
|
"basePath": "/api/v1",
|
||
|
"paths": {
|
||
|
"/products": {
|
||
|
"get": {
|
||
|
"description": "get Products",
|
||
|
"consumes": [
|
||
|
"application/json"
|
||
|
],
|
||
|
"produces": [
|
||
|
"application/json"
|
||
|
],
|
||
|
"tags": [
|
||
|
"Products"
|
||
|
],
|
||
|
"summary": "List Products",
|
||
|
"parameters": [
|
||
|
{
|
||
|
"type": "string",
|
||
|
"format": "email",
|
||
|
"description": "name search by q",
|
||
|
"name": "q",
|
||
|
"in": "query"
|
||
|
}
|
||
|
],
|
||
|
"responses": {
|
||
|
"200": {
|
||
|
"description": "OK",
|
||
|
"schema": {
|
||
|
"type": "array",
|
||
|
"items": {
|
||
|
"$ref": "#/definitions/entity.ProductDisplay"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"400": {
|
||
|
"description": "Bad Request",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
},
|
||
|
"500": {
|
||
|
"description": "Internal Server Error",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/products/{id}": {
|
||
|
"get": {
|
||
|
"description": "get string by ID",
|
||
|
"consumes": [
|
||
|
"application/json"
|
||
|
],
|
||
|
"produces": [
|
||
|
"application/json"
|
||
|
],
|
||
|
"tags": [
|
||
|
"Products"
|
||
|
],
|
||
|
"summary": "Show an product",
|
||
|
"parameters": [
|
||
|
{
|
||
|
"type": "integer",
|
||
|
"description": "product ID",
|
||
|
"name": "id",
|
||
|
"in": "path",
|
||
|
"required": true
|
||
|
}
|
||
|
],
|
||
|
"responses": {
|
||
|
"200": {
|
||
|
"description": "OK",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/entity.ProductDisplay"
|
||
|
}
|
||
|
},
|
||
|
"404": {
|
||
|
"description": "Not Found",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
},
|
||
|
"500": {
|
||
|
"description": "Internal Server Error",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"put": {
|
||
|
"description": "update Product by ID",
|
||
|
"consumes": [
|
||
|
"application/json"
|
||
|
],
|
||
|
"produces": [
|
||
|
"application/json"
|
||
|
],
|
||
|
"tags": [
|
||
|
"Products"
|
||
|
],
|
||
|
"summary": "Update an product",
|
||
|
"parameters": [
|
||
|
{
|
||
|
"type": "integer",
|
||
|
"description": "product ID",
|
||
|
"name": "id",
|
||
|
"in": "path",
|
||
|
"required": true
|
||
|
}
|
||
|
],
|
||
|
"responses": {
|
||
|
"200": {
|
||
|
"description": "OK",
|
||
|
"schema": {
|
||
|
"type": "string"
|
||
|
}
|
||
|
},
|
||
|
"400": {
|
||
|
"description": "Bad Request",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
},
|
||
|
"404": {
|
||
|
"description": "Not Found",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
},
|
||
|
"500": {
|
||
|
"description": "Internal Server Error",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"delete": {
|
||
|
"description": "Delete Product by ID",
|
||
|
"consumes": [
|
||
|
"application/json"
|
||
|
],
|
||
|
"produces": [
|
||
|
"application/json"
|
||
|
],
|
||
|
"tags": [
|
||
|
"Products"
|
||
|
],
|
||
|
"summary": "Delete an product",
|
||
|
"parameters": [
|
||
|
{
|
||
|
"type": "integer",
|
||
|
"description": "product ID",
|
||
|
"name": "id",
|
||
|
"in": "path",
|
||
|
"required": true
|
||
|
}
|
||
|
],
|
||
|
"responses": {
|
||
|
"200": {
|
||
|
"description": "OK",
|
||
|
"schema": {
|
||
|
"type": "string"
|
||
|
}
|
||
|
},
|
||
|
"400": {
|
||
|
"description": "Bad Request",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
},
|
||
|
"404": {
|
||
|
"description": "Not Found",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
},
|
||
|
"500": {
|
||
|
"description": "Internal Server Error",
|
||
|
"schema": {
|
||
|
"$ref": "#/definitions/httputil.HTTPError"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"definitions": {
|
||
|
"entity.ProductDisplay": {
|
||
|
"type": "object",
|
||
|
"properties": {
|
||
|
"created_at": {
|
||
|
"type": "string"
|
||
|
},
|
||
|
"description": {
|
||
|
"type": "string"
|
||
|
},
|
||
|
"id": {
|
||
|
"type": "integer"
|
||
|
},
|
||
|
"name": {
|
||
|
"type": "string"
|
||
|
},
|
||
|
"original_price": {
|
||
|
"type": "number"
|
||
|
},
|
||
|
"price": {
|
||
|
"type": "number"
|
||
|
},
|
||
|
"quantity": {
|
||
|
"type": "integer"
|
||
|
},
|
||
|
"status": {
|
||
|
"type": "boolean"
|
||
|
},
|
||
|
"updated_at": {
|
||
|
"type": "string"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"httputil.HTTPError": {
|
||
|
"type": "object",
|
||
|
"properties": {
|
||
|
"code": {
|
||
|
"type": "integer",
|
||
|
"example": 400
|
||
|
},
|
||
|
"message": {
|
||
|
"type": "string",
|
||
|
"example": "status bad request"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"securityDefinitions": {
|
||
|
"BasicAuth": {
|
||
|
"type": "basic"
|
||
|
}
|
||
|
},
|
||
|
"externalDocs": {
|
||
|
"description": "OpenAPI",
|
||
|
"url": "https://swagger.io/resources/open-api/"
|
||
|
}
|
||
|
}
|