Skip to content

OpenAPI Introduction — The Standard for API Documentation

DodaTech Updated 2026-06-28 5 min read

In this tutorial, you will learn about OpenAPI Introduction. We cover key concepts, practical examples, and best practices to help you master this topic.

The OpenAPI Specification is a standard, language-agnostic format for describing REST APIs using YAML or JSON, enabling automated documentation generation, client code generation, and interactive API testing.

In this tutorial, you will learn the fundamentals of OpenAPI, how it relates to API documentation, and how to create a basic specification that generates professional documentation automatically.

What You'll Learn

You will learn the history and purpose of OpenAPI, its core document structure, how to write a basic specification, and how to use OpenAPI tools to generate documentation, mock servers, and client libraries.

Why It Matters

OpenAPI has become the industry standard for API description, adopted by Google, Microsoft, and thousands of API providers. It eliminates ambiguity in API contracts, enables automatic code generation for 40-plus languages, and powers documentation tools like Swagger UI and Stoplight Elements.

Real-World Use

DodaTech uses OpenAPI to document all internal and external APIs. Doda Browser sync API, DodaZIP update service, and Durga Antivirus Pro threat intelligence endpoints all have OpenAPI specifications that generate client libraries automatically for web, desktop, and mobile platforms.

flowchart LR
  A[OpenAPI Spec] --> B[Swagger UI]
  A --> C[Code Generation]
  A --> D[Mock Server]
  A --> E[API Tests]
  A:::current
  classDef current fill:#f90,color:#fff,stroke:#333,stroke-width:2px

What Is OpenAPI?

OpenAPI is a specification format for describing HTTP APIs. It defines a standard way to describe available endpoints, input parameters, request bodies, response formats, authentication methods, and metadata about the API itself.

The specification was originally called Swagger, created by SmartBear in 2011. In 2016, the specification was donated to the OpenAPI Initiative under the Linux Foundation and renamed OpenAPI. The Swagger name lives on in Swagger UI and Swagger Editor, which are open-source tools that work with OpenAPI specs.

An OpenAPI specification can be written in YAML or JSON. YAML is more common because it is more readable for humans.

Minimal OpenAPI Example

Here is the simplest possible valid OpenAPI 3.1 specification:

openapi: 3.1.0
info:
  title: DodaTech Users API
  description: Manage users for DodaTech platform services
  version: 1.0.0
  contact:
    name: API Support
    email: api@dodatech.com
paths:
  /users:
    get:
      summary: List all users
      operationId: listUsers
      responses:
        "200":
          description: A list of users
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                    name:
                      type: string
                    email:
                      type: string

This specification describes a single endpoint that returns a list of users. From this file, documentation tools can generate a complete API reference page.

How OpenAPI Enables Documentation

Documentation tools read your OpenAPI file and render it as a web page. The key insight is that documentation is derived from the specification, not written separately.

// Example: Using Swagger UI to render docs
const SwaggerUI = require("swagger-ui");

SwaggerUI({
  dom_id: "#api-docs",
  url: "/openapi.yaml",
  defaultModelsExpandDepth: 1,
  docExpansion: "list",
  filter: true,
  showExtensions: true
});
<!-- HTML container for Swagger UI -->
<div id="api-docs"></div>

When you update the OpenAPI file, the documentation updates automatically. This keeps docs in sync with the API, provided you maintain the spec alongside the implementation.

OpenAPI Document Structure

openapi: 3.1.0          # Spec version
info:                    # API metadata
  title: My API
  version: 1.0.0
servers:                 # Where the API lives
  - url: https://api.example.com/v1
paths:                   # Endpoints and operations
  /users:
    get:
      ...
components:              # Reusable definitions
  schemas:               # Data models
  parameters:            # Reusable parameters
  responses:             # Reusable responses
  securitySchemes:       # Auth methods
security:                # Global security
  - BearerAuth: []
tags:                    # Grouping endpoints
  - name: Users
    description: User operations
externalDocs:            # Additional documentation
  description: Full guide
  url: https://docs.example.com

OpenAPI Versions

OpenAPI 3.1 is the current version, released in 2021. It introduced full JSON Schema 2020-12 support, Webhook support, and improved examples.

OpenAPI 3.0 is still widely used. The main difference from 3.1 is that 3.0 uses a subset of JSON Schema (draft 07) rather than the full spec.

OpenAPI 2.0 (originally called Swagger 2.0) is legacy but many existing APIs still use it.

# Check which version an API spec uses
grep "^openapi:" spec.yaml
# Expected: openapi: 3.1.0
# or: openapi: "3.0.3"
# or (Swagger 2.0): swagger: "2.0"

Common Mistakes

  1. Using the wrong spec version — Mixing OpenAPI 3.0 and 3.1 syntax. Check your spec version and use the correct schema for that version.

  2. Not including a version number — Omitting the openapi or swagger version field. Every spec must declare the version it uses.

  3. Empty or generic info section — Leaving description blank or using placeholder text. The info section is often the first thing developers read.

  4. No contact information — Not providing a way for developers to reach the API team. Always include at least an email or URL for support.

  5. Missing servers section — Not specifying the base URL for the API. Without servers, developers cannot make actual requests to test the API.

Practice Questions

  1. What is the relationship between OpenAPI and Swagger?
  2. What are the main sections of an OpenAPI specification?
  3. What are the differences between OpenAPI 3.0 and 3.1?
  4. How does an OpenAPI spec enable automated documentation?
  5. What is the minimum required information for a valid OpenAPI spec?

Challenge

Write an OpenAPI 3.1 specification for a simple notes API with two endpoints: create a note and list all notes. Include the info section with contact details, one server URL, and basic schema definitions for the Note object. Validate your spec using swagger-cli.

FAQ

Should I use YAML or JSON for my OpenAPI spec?

YAML is preferred because it is more readable, supports comments, and has less syntax overhead. JSON is better for programmatic generation. Both are valid.

Do I need to learn OpenAPI before writing API documentation?

Yes. OpenAPI is the foundation for modern API documentation. Learning OpenAPI first makes documentation easier because you write the spec once and generate docs automatically.

Can I convert an existing API to OpenAPI?

Yes. There are tools that analyze your API code and generate OpenAPI specs automatically. However, manual review is always needed because automated tools cannot capture intent.

What tools work with OpenAPI specs?

Swagger UI for interactive docs, Stoplight Elements for developer portals, Redoc for beautiful static docs, Postman for testing, and OpenAPI Generator for client SDKs.

Is OpenAPI only for REST APIs?

OpenAPI is designed for HTTP APIs that follow REST conventions. For Graphql, use the GraphQL schema language. For gRPC, use Protocol Buffers.

Mini Project

Take an existing API endpoint you use (or design a simple one) and write a minimal OpenAPI 3.1 specification for it. Include the info section, one path with two operations, and basic response schemas. Validate it with swagger-cli.

What's Next

In the next lesson, you will learn the detailed structure of an OpenAPI document, including the info object, servers, paths, and components sections.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro