rswag/test-app/swagger/v1/swagger.json
2019-07-14 17:28:11 -04:00

269 lines
6.1 KiB
JSON

{
"openapi": "3.0.0",
"info": {
"title": "API V1",
"version": "v1"
},
"paths": {
"/blogs": {
"post": {
"summary": "Creates a blog",
"tags": [
"Blogs"
],
"description": "Creates a new blog from provided data",
"operationId": "createBlog",
"requestBody": {
"required": true,
"content": {
"application/json": {
"examples": {
"blog": {
"value": {
"blog": {
"title": "foo",
"content": "bar"
}
}
}
},
"schema": {
"$ref": "#/components/schemas/blog"
}
}
}
},
"parameters": [
],
"responses": {
"201": {
"description": "blog created",
"content": {
"application/json": {
"example": {
"id": 1,
"title": "foo",
"content": "bar",
"thumbnail": null
},
"schema": {
"$ref": "#/components/schemas/blog"
}
}
}
},
"422": {
"description": "invalid request",
"content": {
"application/json": {
"example": {
"errors": {
"content": [
"can't be blank"
]
}
},
"schema": {
"$ref": "#/components/schemas/errors_object"
}
}
}
}
}
},
"get": {
"summary": "Searches blogs",
"tags": [
"Blogs"
],
"description": "Searches blogs by keywords",
"operationId": "searchBlogs",
"parameters": [
{
"name": "keywords",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/blog"
}
}
}
}
},
"406": {
"description": "unsupported accept header"
}
}
}
},
"/blogs/{id}": {
"get": {
"summary": "Retrieves a blog",
"tags": [
"Blogs"
],
"description": "Retrieves a specific blog by id",
"operationId": "getBlog",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "blog found",
"headers": {
"ETag": {
"schema": {
"type": "string"
}
},
"Last-Modified": {
"schema": {
"type": "string"
}
},
"Cache-Control": {
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"example": {
"id": 1,
"title": "Hello world!",
"content": "Hello world and hello universe. Thank you all very much!!!",
"thumbnail": "thumbnail.png"
},
"schema": {
"$ref": "#/components/schemas/blog"
}
}
}
},
"404": {
"description": "blog not found"
}
}
}
},
"/blogs/{id}/upload": {
"put": {
"summary": "Uploads a blog thumbnail",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "file",
"in": "formData",
"required": true,
"schema": {
"type": "file"
}
}
],
"tags": [
"Blogs"
],
"description": "Upload a thumbnail for specific blog by id",
"operationId": "uploadThumbnailBlog",
"responses": {
"200": {
"description": "blog updated"
}
}
}
}
},
"servers": [
{
"url": "https://{defaultHost}",
"variables": {
"defaultHost": {
"default": "www.example.com"
}
}
}
],
"components": {
"schemas": {
"errors_object": {
"type": "object",
"properties": {
"errors": {
"$ref": "#/components/schemas/errors_map"
}
}
},
"errors_map": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"blog": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"title": {
"type": "string"
},
"content": {
"type": "string",
"nullable": true
},
"thumbnail": {
"type": "string"
}
},
"required": [
"id",
"title",
"content",
"thumbnail"
]
}
},
"securitySchemes": {
"basic_auth": {
"type": "http",
"scheme": "basic"
},
"api_key": {
"type": "apiKey",
"name": "api_key",
"in": "query"
}
}
}
}