Skip to content

Instantly share code, notes, and snippets.

@wwj718
Last active May 23, 2017 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwj718/d2d017b9f27b1e241b1c7a2b7b6f2f7f to your computer and use it in GitHub Desktop.
Save wwj718/d2d017b9f27b1e241b1c7a2b7b6f2f7f to your computer and use it in GitHub Desktop.
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "blog",
"description": "# blog API documentation\n\n这篇文档描述了的blog(article)的api接口\n"
},
"schemes": [
"https",
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/": {
"get": {
"summary": "Service root",
"description": "列出所有api的描述信息.",
"operationId": "root",
"responses": {
"200": {
"description": "Success"
}
},
"security": []
}
},
"/articles": {
"get": {
"summary": "list all articles",
"operationId": "list_all_articles",
"responses": {
"200": {
"description": "Annotation successfully created",
"schema": {
"$ref": "#/definitions/ArticleList"
}
},
"400": {
"description": "Could not create article from your request",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"post": {
"summary": "Create a new Article",
"operationId": "createArticle",
"parameters": [
{
"name": "Article",
"in": "body",
"description": "article to be created",
"required": true,
"schema": {
"$ref": "#/definitions/NewArticle"
}
}
],
"responses": {
"200": {
"description": "article successfully created",
"schema": {
"$ref": "#/definitions/Article"
}
},
"400": {
"description": "Could not create article from your request",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/articles/{id}": {
"get": {
"summary": "Fetch an Article",
"operationId": "fetchArticle",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of article to return",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/Article"
}
},
"404": {
"description": "article not found or no permission to view",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"patch": {
"summary": "Update an Article",
"description": "This endpoint is available under both the `PATCH` and `PUT`\nrequest methods. Both endpoints have PATCH-characteristics\nas defined in [RFC5789](https://tools.ietf.org/html/rfc5789#section-1),\nmeaning the request body does not have to include the whole Article\nobject.\n\nNew implementations should use the `PATCH` request method, and existing\nimplementations continue to work under `PUT` but should switch to `PATCH`.\n",
"operationId": "updateArticle",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of article to return",
"required": true,
"type": "string"
},
{
"name": "Article",
"in": "body",
"description": "Updated article body",
"required": true,
"schema": {
"$ref": "#/definitions/NewArticle"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/Article"
}
},
"400": {
"description": "Could not create article from your request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "article not found or no permission to update",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"delete": {
"summary": "Delete an Article",
"operationId": "deleteArticle",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of article to return",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "object",
"required": [
"deleted",
"id"
],
"properties": {
"deleted": {
"type": "boolean",
"enum": [
true
]
},
"id": {
"type": "string"
}
}
}
},
"404": {
"description": "article not found or no permission to delete",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/search": {
"get": {
"summary": "Search for annotations",
"operationId": "search",
"parameters": [
{
"name": "limit",
"in": "query",
"description": "The maximum number of annotations to return.",
"required": false,
"type": "integer",
"minimum": 0,
"maximum": 200,
"default": 20
},
{
"name": "offset",
"in": "query",
"description": "The minimum number of initial annotations to skip. This is used for pagination.\n",
"required": false,
"type": "integer",
"default": 0,
"minimum": 0
},
{
"name": "sort",
"in": "query",
"description": "The field by which annotations should be sorted.",
"required": false,
"type": "string",
"default": "updated"
}
],
"responses": {
"200": {
"description": "Search results",
"schema": {
"$ref": "#/definitions/SearchResults"
}
}
}
}
}
},
"definitions": {
"NewArticle": {
"type": "object",
"properties": {
"userid": {
"type": "string"
},
"title": {
"type": "string"
},
"content": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"Article": {
"allOf": [
{
"$ref": "#/definitions/NewArticle"
},
{
"required": [
"id"
],
"properties": {
"id": {
"type": "string"
}
}
}
]
},
"Error": {
"type": "object",
"required": [
"status"
],
"properties": {
"status": {
"type": "string",
"enum": [
"failure"
]
},
"reason": {
"type": "string",
"description": "A human-readable description of the reason(s) for failure."
}
}
},
"SearchResults": {
"type": "object",
"required": [
"rows",
"total"
],
"properties": {
"rows": {
"type": "array",
"items": {
"$ref": "#/definitions/Article"
}
},
"total": {
"description": "Total number of results matching query.",
"type": "integer"
}
}
},
"ArticleList": {
"type": "object",
"required": [
"rows",
"total"
],
"properties": {
"rows": {
"type": "array",
"items": {
"$ref": "#/definitions/Article"
}
},
"total": {
"description": "Total number of results matching query.",
"type": "integer"
}
}
}
},
"host": "virtserver.swaggerhub.com",
"basePath": "/pwnote/blog/1.0.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment