Skip to content

Examples and guides for using the OpenAI API

4.2 KB
Raw Blame
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Event Management API",
    "description": "An API for managing event data"
  },
  "paths": {
    "/events": {
      "get": {
        "summary": "List all events",
        "operationId": "listEvents",
        "responses": {
          "200": {
            "description": "A list of events",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Event"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a new event",
        "operationId": "createEvent",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The event was created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          }
        }
      }
    },
    "/events/{id}": {
      "get": {
        "summary": "Retrieve an event by ID",
        "operationId": "getEventById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Delete an event by ID",
        "operationId": "deleteEvent",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The event was deleted"
          }
        }
      },
      "patch": {
        "summary": "Update an event's details by ID",
        "operationId": "updateEventDetails",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "location": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "date",
                  "location"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The event's details were updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Event": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "location": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "date",
          "location"
        ]
      }
    }
  }
}