Convert Figma logo to code with AI

OAI logoOpenAPI-Specification

The OpenAPI Specification Repository

28,776
9,065
28,776
198

Top Related Projects

The OpenAPI Specification Repository

4,104

The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.

GraphQL is a query language and execution engine tied to any backend service.

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v3.1, v3.0, and v2.0 as well as AsyncAPI v2.x.

Quick Overview

The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. It is the most popular API description format for REST APIs.

Pros

  • Provides a standardized way to describe REST APIs, improving interoperability
  • Enables automatic generation of documentation, client libraries, and server stubs
  • Supports a wide range of tools and integrations in the API ecosystem
  • Facilitates API-first design and development practices

Cons

  • Can be complex for newcomers, especially for large APIs
  • May require additional effort to keep the specification in sync with the actual API implementation
  • Some advanced API features or non-REST architectures may not be fully supported
  • Version transitions (e.g., from OpenAPI 2.0 to 3.0) can be challenging

Getting Started

To start using the OpenAPI Specification:

  1. Choose an OpenAPI editor (e.g., Swagger Editor, Stoplight Studio)
  2. Create a new YAML or JSON file
  3. Begin defining your API using the OpenAPI structure:
openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /hello:
    get:
      summary: Returns a greeting
      responses:
        '200':
          description: Successful response
          content:
            application/json:    
              schema:
                type: object
                properties:
                  message:
                    type: string
  1. Validate your specification using OpenAPI validation tools
  2. Use the specification to generate documentation, client SDKs, or server stubs

Competitor Comparisons

The OpenAPI Specification Repository

Pros of OpenAPI-Specification

  • Widely adopted industry standard for API documentation
  • Extensive tooling ecosystem and community support
  • Supports multiple programming languages and frameworks

Cons of OpenAPI-Specification

  • Learning curve for complex specifications
  • Can become verbose for large APIs
  • Requires regular maintenance to keep in sync with API changes

Code Comparison

OpenAPI-Specification example:

openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /users:
    get:
      summary: List users
      responses:
        '200':
          description: Successful response

OpenAPI-Specification example:

openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /users:
    get:
      summary: List users
      responses:
        '200':
          description: Successful response

As we can see, the code examples are identical because OpenAPI-Specification and OpenAPI-Specification are the same repository. The comparison requested is between the same project, so there are no differences to highlight in terms of pros, cons, or code examples. The OpenAPI Specification is a standardized format for describing RESTful APIs, and it's maintained in a single repository by the OpenAPI Initiative.

4,104

The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.

Pros of AsyncAPI Specification

  • Specifically designed for event-driven and asynchronous APIs
  • Supports multiple protocols (e.g., AMQP, MQTT, Kafka) out of the box
  • Provides better support for describing message payloads and channels

Cons of AsyncAPI Specification

  • Less mature ecosystem and tooling compared to OpenAPI
  • Smaller community and fewer resources available
  • Limited support for describing synchronous request-response APIs

Code Comparison

AsyncAPI Specification:

asyncapi: 2.0.0
channels:
  user/signedup:
    publish:
      message:
        payload:
          type: object
          properties:
            userId:
              type: string

OpenAPI Specification:

openapi: 3.0.0
paths:
  /users:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                userId:
                  type: string

The AsyncAPI example describes an event-driven API where clients can publish messages to a "user/signedup" channel. The OpenAPI example describes a RESTful API endpoint for creating users. AsyncAPI is more suitable for event-driven architectures, while OpenAPI is better for traditional request-response APIs.

GraphQL is a query language and execution engine tied to any backend service.

Pros of GraphQL Specification

  • Allows clients to request only the data they need, reducing over-fetching
  • Provides a single endpoint for multiple resources, simplifying API structure
  • Enables strong typing and introspection, improving developer experience

Cons of GraphQL Specification

  • Increased complexity for simple APIs or CRUD operations
  • Potential performance issues with nested queries
  • Less standardized caching mechanisms compared to REST

Code Comparison

GraphQL Specification:

type Query {
  user(id: ID!): User
}

type User {
  id: ID!
  name: String!
  email: String
}

OpenAPI Specification:

paths:
  /users/{id}:
    get:
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:    
              schema:
                $ref: '#/components/schemas/User'

The GraphQL Specification defines a schema with types and fields, allowing clients to request specific data. The OpenAPI Specification describes REST endpoints, parameters, and response structures. GraphQL offers more flexibility in data fetching, while OpenAPI provides a standardized way to document RESTful APIs.

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

Pros of openapi-generator

  • Generates client libraries, server stubs, and documentation for multiple programming languages
  • Supports a wide range of frameworks and platforms
  • Actively maintained with frequent updates and community contributions

Cons of openapi-generator

  • More complex setup and configuration compared to the OpenAPI Specification
  • May generate unnecessary or redundant code in some cases
  • Requires additional dependencies and build processes

Code comparison

OpenAPI-Specification (YAML):

openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /users:
    get:
      summary: Get users

openapi-generator (Java client generation):

java -jar openapi-generator-cli.jar generate \
  -i petstore.yaml \
  -g java \
  -o /tmp/java-client

Summary

OpenAPI-Specification focuses on defining API structures, while openapi-generator is a tool for generating code based on those specifications. OpenAPI-Specification provides a standardized way to describe APIs, whereas openapi-generator offers practical implementation across various languages and frameworks. While OpenAPI-Specification is more straightforward to use, openapi-generator provides more extensive functionality for developers working with APIs in different programming environments.

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v3.1, v3.0, and v2.0 as well as AsyncAPI v2.x.

Pros of Spectral

  • Customizable linting rules for API descriptions
  • Supports multiple API description formats (OpenAPI, AsyncAPI, JSON Schema)
  • Extensible through custom rulesets and functions

Cons of Spectral

  • Focused on linting, not a full specification
  • Requires additional setup and configuration
  • May have a steeper learning curve for beginners

Code Comparison

OpenAPI-Specification (YAML):

openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /users:
    get:
      summary: List users

Spectral (JSON):

{
  "extends": ["spectral:oas", "spectral:asyncapi"],
  "rules": {
    "operation-description": "warn",
    "info-contact": "error"
  }
}

Summary

OpenAPI-Specification is the official repository for the OpenAPI standard, providing a comprehensive specification for describing RESTful APIs. Spectral, on the other hand, is a powerful linting tool that can validate API descriptions against various standards, including OpenAPI.

While OpenAPI-Specification focuses on defining the structure and format of API descriptions, Spectral emphasizes validation and enforcement of best practices. Spectral offers more flexibility in terms of supported formats and customization options but requires additional setup compared to simply following the OpenAPI specification.

Developers may use both in conjunction: OpenAPI-Specification for defining their APIs and Spectral for ensuring adherence to standards and best practices.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

The OpenAPI Specification

Build Status Issue triagers

The OpenAPI Specification is a community-driven open specification within the OpenAPI Initiative, a Linux Foundation Collaborative Project.

The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs. This allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic. When properly defined via OpenAPI, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interface descriptions have done for lower-level programming, the OpenAPI Specification removes guesswork in calling a service.

Use cases for machine-readable API definition documents include, but are not limited to: interactive documentation; code generation for documentation, clients, and servers; and automation of test cases. OpenAPI documents describe API services and are represented in YAML or JSON formats. These documents may be produced and served statically or generated dynamically from an application.

The OpenAPI Specification does not require rewriting existing APIs. It does not require binding any software to a service – the described service may not even be owned by the creator of its description. It does, however, require that the service's capabilities be described in the structure of the OpenAPI Specification. Not all services can be described by OpenAPI – this specification is not intended to cover every possible style of HTTP APIs, but does include support for REST APIs. The OpenAPI Specification does not mandate a specific development process such as design-first or code-first. It does facilitate either technique by establishing clear interactions with an HTTP API.

This GitHub project is the starting point for OpenAPI. Here you will find the information you need about the OpenAPI Specification, simple examples of what it looks like, and some general information regarding the project.

Current Version - 3.1.0

The current version of the OpenAPI specification is OpenAPI Specification 3.1.0.

Previous Versions

This repository also contains all previous versions.

Each folder in this repository, such as examples and schemas, should contain folders pertaining to the current and previous versions of the specification.

See It in Action

If you just want to see it work, check out the list of current examples.

Tools and Libraries

Looking to see how you can create your own OpenAPI definition, present it, or otherwise use it? Check out the growing list of implementations.

Participation

The current process for developing the OpenAPI Specification is described in Development Guidelines. Developing the next version of the OpenAPI Specification is guided by the Technical Steering Committee (TSC). This group of committers bring their API expertise, incorporate feedback from the community, and expand the group of committers as appropriate. All development activity on the future specification will be performed as features and merged into this branch. Upon release of the future specification, this branch will be merged to main.

The TSC holds weekly web conferences to review open pull requests and discuss open issues related to the evolving OpenAPI Specification. Participation in weekly calls and scheduled working sessions is open to the community. You can view the entire OpenAPI technical meeting calendar online.

The OpenAPI Initiative encourages participation from individuals and companies alike. If you want to participate in the evolution of the OpenAPI Specification, consider taking the following actions:

  • Review the current specification. The human-readable markdown file is the source of truth for the specification.
  • Review the development process so you understand how the spec is evolving.
  • Check the issues and pull requests to see if someone has already documented your idea or feedback on the specification. You can follow an existing conversation by subscribing to the existing issue or PR.
  • Subscribe to an open issue a day (or a week) in your inbox via CodeTriage.com.
  • Create an issue to describe a new concern. If possible, propose a solution.

Not all feedback can be accommodated, and there may be solid arguments for or against a change being appropriate for the specification.

Licensing

See: License (Apache-2.0)