{
  "openapi": "3.0.0",
  "info": {
    "title": "PSX sample API",
    "version": "1"
  },
  "servers": [
    {
      "url": "http:\/\/example.phpsx.org"
    }
  ],
  "paths": {
    "\/population\/openapi": {
      "summary": "Returns a collection of population entries",
      "get": {
        "operationId": "doGet",
        "parameters": [
          {
            "name": "startIndex",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "count",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "200 Response",
            "content": {
              "application\/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          }
        }
      },
      "post": {
        "requestBody": {
          "content": {
            "application\/json": {
              "schema": {
                "$ref": "#/components/schemas/Entity"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "201 Response",
            "content": {
              "application\/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          }
        }
      }
    },
    "\/population\/openapi\/{id}": {
      "summary": "Returns a collection of population entries",
      "parameters": [{
        "name": "id",
        "in": "path",
        "required": false,
        "schema": {
          "type": "integer"
        }
      }],
      "get": {
        "parameters": [
          {
            "name": "startIndex",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "count",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "200 Response",
            "content": {
              "application\/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          }
        }
      },
      "put": {
        "requestBody": {
          "content": {
            "application\/json": {
              "schema": {
                "$ref": "#/components/schemas/Entity"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200 Response",
            "content": {
              "application\/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          }
        }
      },
      "delete": {
        "responses": {
          "200": {
            "description": "200 Response",
            "content": {
              "application\/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Collection": {
        "description": "Collection result",
        "type": "object",
        "properties": {
          "totalResults": {
            "type": "integer"
          },
          "entry": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Entity"
            }
          }
        }
      },
      "Entity": {
        "description": "Represents an internet population entity",
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Unique id for each entry"
          },
          "place": {
            "type": "integer",
            "minimum": 1,
            "maximum": 64,
            "description": "Position in the top list"
          },
          "region": {
            "type": "string",
            "minLength": 3,
            "maxLength": 64,
            "pattern": "[A-z]+",
            "description": "Name of the region"
          },
          "population": {
            "type": "integer",
            "description": "Complete number of population"
          },
          "users": {
            "type": "integer",
            "description": "Number of internet users"
          },
          "worldUsers": {
            "type": "number",
            "description": "Percentage users of the world"
          },
          "datetime": {
            "type": "string",
            "format": "date-time",
            "description": "Date when the entity was created"
          }
        },
        "required": ["place", "region", "population", "users", "worldUsers"]
      },
      "Message": {
        "description": "Operation message",
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
