OpenAPI

Add an OpenAPI spec to a page and let your users test endpoints right on the page with interactive blocks.

Manually writing REST API documentation can be a time-consuming process. Fortunately, GitBook streamlines this task by allowing you to import OpenAPI documents, which detail your API’s structure and functionality.

The OpenAPI Specification (OAS) is a framework that developers use to document REST APIs. Written in JSON or YAML, it outlines all your endpoints, parameters, schemas, and authentication schemes.

Once imported into GitBook, these documents are transformed into interactive and testable API blocks that visually represent your API methods—whether the specification is provided as a file or loaded from a URL.

GitBook supports Swagger 2.0 or OpenAPI 3.0 compliant files.

Add a new pet to the store.

post

Add a new pet to the store.

Authorizations
Body
idinteger · int64optional
Example: 10
namestringrequired
Example: doggie
categoryobjectoptional

photoUrlsstring[]required
tagsobject[]optional

statusstring · enumoptional

pet status in the store

Options: available, pending, sold
Responses
curl -L \
  --request POST \
  --url '/api/v3/pet' \
  --header 'Content-Type: application/json' \
  --data '{
    "id": 10,
    "name": "doggie",
    "category": {
      "id": 1,
      "name": "Dogs"
    },
    "photoUrls": [
      "text"
    ],
    "tags": [
      {
        "id": 1,
        "name": "text"
      }
    ],
    "status": "available"
  }'
{
  "id": 10,
  "name": "doggie",
  "category": {
    "id": 1,
    "name": "Dogs"
  },
  "photoUrls": [
    "text"
  ],
  "tags": [
    {
      "id": 1,
      "name": "text"
    }
  ],
  "status": "available"
}

Test it (powered by Scalar)

GitBook's OpenAPI block also supports a "test it" functionality, which allows your users to test your API methods with data and parameters filled in from the editor.

Powered by Scalar, you won't need to leave the docs in order to see your API methods in action. See and example of this above.

Last updated

Was this helpful?