GitHub Raw JSON API

eddycjy / go-gin-example

7,186 Go

An example of gin

Golang Gin API Specification

Located in docs/swagger.json on branch HEAD

2.0 JSON 7 Endpoints 18.8 KB

Operations & Route Endpoints (12)

GET /api/v1/articles
Get multiple articles
POST /api/v1/articles
Add article
GET /api/v1/articles/{id}
Get a single article
PUT /api/v1/articles/{id}
Update article
DELETE /api/v1/articles/{id}
Delete article
GET /api/v1/tags
Get multiple article tags
POST /api/v1/tags
Add article tag
POST /api/v1/tags/export
Export article tag
POST /api/v1/tags/import
Import Image
PUT /api/v1/tags/{id}
Update article tag
DELETE /api/v1/tags/{id}
Delete article tag
GET /auth
Get Auth
Raw JSON Specification
{
  "swagger": "2.0",
  "info": {
    "description": "An example of gin",
    "title": "Golang Gin API",
    "termsOfService": "https://github.com/EDDYCJY/go-gin-example",
    "contact": {},
    "license": {
      "name": "MIT",
      "url": "https://github.com/EDDYCJY/go-gin-example/blob/master/LICENSE"
    },
    "version": "1.0"
  },
  "paths": {
    "/api/v1/articles": {
      "get": {
        "produces": [
          "application/json"
        ],
        "summary": "Get multiple articles",
        "parameters": [
          {
            "description": "TagID",
            "name": "tag_id",
            "in": "body",
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "State",
            "name": "state",
            "in": "body",
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "CreatedBy",
            "name": "created_by",
            "in": "body",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      },
      "post": {
        "produces": [
          "application/json"
        ],
        "summary": "Add article",
        "parameters": [
          {
            "description": "TagID",
            "name": "tag_id",
            "in": "body",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Title",
            "name": "title",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Desc",
            "name": "desc",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Content",
            "name": "content",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "CreatedBy",
            "name": "created_by",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "State",
            "name": "state",
            "in": "body",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      }
    },
    "/api/v1/articles/{id}": {
      "get": {
        "produces": [
          "application/json"
        ],
        "summary": "Get a single article",
        "parameters": [
          {
            "type": "integer",
            "description": "ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      },
      "put": {
        "produces": [
          "application/json"
        ],
        "summary": "Update article",
        "parameters": [
          {
            "type": "integer",
            "description": "ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "TagID",
            "name": "tag_id",
            "in": "body",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Title",
            "name": "title",
            "in": "body",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Desc",
            "name": "desc",
            "in": "body",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Content",
            "name": "content",
            "in": "body",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "ModifiedBy",
            "name": "modified_by",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "State",
            "name": "state",
            "in": "body",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      },
      "delete": {
        "produces": [
          "application/json"
        ],
        "summary": "Delete article",
        "parameters": [
          {
            "type": "integer",
            "description": "ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      }
    },
    "/api/v1/tags": {
      "get": {
        "produces": [
          "application/json"
        ],
        "summary": "Get multiple article tags",
        "parameters": [
          {
            "type": "string",
            "description": "Name",
            "name": "name",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "State",
            "name": "state",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      },
      "post": {
        "produces": [
          "application/json"
        ],
        "summary": "Add article tag",
        "parameters": [
          {
            "description": "Name",
            "name": "name",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "State",
            "name": "state",
            "in": "body",
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "CreatedBy",
            "name": "created_by",
            "in": "body",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      }
    },
    "/api/v1/tags/export": {
      "post": {
        "produces": [
          "application/json"
        ],
        "summary": "Export article tag",
        "parameters": [
          {
            "description": "Name",
            "name": "name",
            "in": "body",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "State",
            "name": "state",
            "in": "body",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      }
    },
    "/api/v1/tags/import": {
      "post": {
        "produces": [
          "application/json"
        ],
        "summary": "Import Image",
        "parameters": [
          {
            "type": "file",
            "description": "Image File",
            "name": "image",
            "in": "formData",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      }
    },
    "/api/v1/tags/{id}": {
      "put": {
        "produces": [
          "application/json"
        ],
        "summary": "Update article tag",
        "parameters": [
          {
            "type": "integer",
            "description": "ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Name",
            "name": "name",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "State",
            "name": "state",
            "in": "body",
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "ModifiedBy",
            "name": "modified_by",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      },
      "delete": {
        "produces": [
          "application/json"
        ],
        "summary": "Delete article tag",
        "parameters": [
          {
            "type": "integer",
            "description": "ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      }
    },
    "/auth": {
      "get": {
        "produces": [
          "application/json"
        ],
        "summary": "Get Auth",
        "parameters": [
          {
            "type": "string",
            "description": "userName",
            "name": "username",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "password",
            "name": "password",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/app.Response"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "app.Response": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer"
        },
        "data": {
          "type": "object"
        },
        "msg": {
          "type": "string"
        }
      }
    }
  }
}