liveBook · Manning

OpenAPI specification

As explained in AI Agents in Action

An OpenAPI specification is a machine-readable standard description of an HTTP API's endpoints, operations, parameters, and data structures.

An OpenAPI specification is a machine-readable description of an HTTP API. It records endpoints, operations, responses, and data schemas so tools and assistants can understand how to call the service. section 3.3.1

Use a specification to:

  • Describe a FastAPI endpoint, including its HTTP method, path, response structure, and data schema. section 3.3.1
  • Connect an external service to a GPT assistant by pasting the specification into a custom action and adding its server URL. section 3.3.2
  • Update the assistant’s action configuration whenever the connected API changes. section 3.3.2

Daily tasks API

A GET /tasks endpoint returns daily tasks as JSON. Its OpenAPI document identifies OpenAPI 3.1.0, describes the successful response as an array, and defines each Task with id, description, and completed fields. The document can be retrieved from FastAPI’s /openapi.json endpoint and saved as YAML or JSON. section 3.3.1

Listing 3.12 OpenAPI specification for the task API
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
paths:
  /tasks:
    get:
      summary: Get Tasks
      description: Retrieve a list of daily tasks.
      operationId: get_tasks_tasks_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Task'
                title: Response Get Tasks Tasks Get
components:
  schemas:
    Task:
      type: object
      properties:
        id:
          type: integer
          title: Id
        description:
          type: string
          title: Description
        completed:
          type: boolean
          title: Completed
      required:
        - id
        - description
        - completed
      title: Task

Inspect the complete OpenAPI document for the task endpoint, including its path, response schema, and Task component. section 3.3.1

How AI Agents in Action covers it

How deep it goes
Defines paths, operations, responses, and schemas through a concrete task API, but defers broader API design detail.
Examples
Uses a daily tasks endpoint with a Task schema and a GPT task-organizer custom action.
What it assumes
Assumes basic HTTP endpoint concepts while demonstrating FastAPI service generation and custom-action configuration.
What you can do after
Apply it via FastAPI and GPT custom actions to describe, expose, test, and connect an API service.
How it connects
Links FastAPI, HTTP APIs, Swagger documentation, custom actions, and ngrok-based service access.

Also explained in

Compare how 12 books explain OpenAPI specification →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action. The section links point to the parts of the book it draws on.