ttuan
8/22/2018 - 3:06 PM

Swagger UI json file

Swagger UI json file

{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "API Sample App",
    "description": "API Sample App",
    "contact": {
      "name": "@kymmt90"
    },
    "license": {
      "name": "MIT"
    }
  },
  "basePath": "/",
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "parameters": {
    "user_id": {
      "in": "path",
      "description": "User ID",
      "required": true,
      "type": "integer",
      "format": "int64"
    },
    "user": {
      "name": "user",
      "in": "body",
      "description": "User attributes",
      "required": true,
      "schema": {
        "$ref": "#/definitions/UserInput"
      }
    }
  },
  "paths": {
    "/users": {
      "get": {
        "description": "Get all users",
        "operationId": "get_all_user",
        "responses": {
          "200": {
            "description": "All users",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/UserOutput"
              }
            }
          }
        }
      },
      "post": {
        "description": "Creates a user",
        "operationId": "create_user",
        "parameters": [
          {
            "$ref": "#/parameters/user"
          }
        ],
        "responses": {
          "201": {
            "description": "Created user",
            "schema": {
              "$ref": "#/definitions/UserOutput"
            }
          },
          "400": {
            "description": "Invalid parameters",
            "schema": {
              "$ref": "#/definitions/ErrorOutput"
            }
          }
        }
      }
    },
    "/users/{id}": {
      "parameters": [
        {
          "$ref": "#/parameters/user_id",
          "name": "id"
        }
      ],
      "get": {
        "description": "Finds the specified user",
        "operationId": "find_user_by_id",
        "responses": {
          "200": {
            "description": "User specified by its ID",
            "schema": {
              "$ref": "#/definitions/UserOutput"
            }
          },
          "404": {
            "description": "Resource not found",
            "schema": {
              "$ref": "#/definitions/ErrorOutput"
            }
          }
        }
      },
      "patch": {
        "description": "Updates the user",
        "operationId": "update_user",
        "parameters": [
          {
            "$ref": "#/parameters/user"
          }
        ],
        "responses": {
          "200": {
            "description": "Updated user",
            "schema": {
              "$ref": "#/definitions/UserOutput"
            }
          },
          "400": {
            "description": "Invalid parameters",
            "schema": {
              "$ref": "#/definitions/ErrorOutput"
            }
          },
          "404": {
            "description": "Resource not found",
            "schema": {
              "$ref": "#/definitions/ErrorOutput"
            }
          }
        }
      },
      "delete": {
        "description": "Deletes the user",
        "operationId": "delete_user",
        "responses": {
          "204": {
            "description": "The user was deleted"
          },
          "404": {
            "description": "Resource not found",
            "schema": {
              "$ref": "#/definitions/ErrorOutput"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "UserInput": {
      "required": [
        "name",
        "email"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string"
        }
      }
    },
    "UserOutput": {
      "required": [
        "id",
        "name",
        "email"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "format": "int64"
        },
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string"
        }
      }
    }
  }
}