APIGit
Native Git RepositoryVersioned, Git-native API repositoryAPI DesignOpenAPI, AsyncAPI and GraphQL editingAPI DocumentationPublish versioned docs from GitAPI GovernanceCheck OpenAPI and AsyncAPI standardsMock ServerFrom OpenAPI, GraphQL or Express.js codeTeam CollaborationOrganizations, teams, permissions and reviewsAI AgentsMCP server, llms.txt and Copy page for agentsCLILocal-first: lint, mock and publish from a terminal

The full API lifecycle

Design, document, mock and govern your APIs in one Git-native workspace, or local-first with the CLI and your coding agent.

Get started freeView pricing

Learning

Help DocsGetting StartedVideo TutorialsBlog

Support

Contact UsRequest a DemoReport an Issue
PricingAbout
Sign InSign Up for Free
APIGit

The Git-native, local-first API platform, ready for AI agents

Product

  • Native Git Repository
  • API Design
  • API Documentation
  • API Governance
  • Mock Server
  • Team Collaboration
  • AI Agents
  • CLI

Resources

  • Blog
  • Documentation
  • CLI Reference
  • MCP Server
  • Video Tutorials
  • Pricing
  • Contact

Company

  • About
  • Careers
  • Privacy Policy
  • Terms of Service
  • Service Level Agreement
  • Cookie Policy

© 2026 APIGit. All rights reserved.

Home / Blog / api-design / openapi-structure

OpenAPI Structure and Best Practices

2023-05-08
APIGit Team
6 min read
api-design

OpenAPI (formerly known as Swagger) is a specification for building APIs (Application Programming Interfaces). It provides a standard way of defining, documenting, and consuming RESTful APIs. The OpenAPI specification is written in YAML or JSON format and includes a number of fields that are used to define various aspects of the API.

Here are some of the most commonly used fields in OpenAPI:

  1. openapi: Specifies the version of the OpenAPI specification being used.
  2. info: Contains information about the API, such as title, description, version, and contact details.
  3. servers: Specifies the server(s) that the API is hosted on.
  4. paths: Defines the endpoints (URLs) of the API and the HTTP methods (GET, POST, PUT, DELETE, etc.) that can be used to access them.
  5. components: Contains reusable elements of the API, such as schemas, security schemes, and responses.
  6. security: Specifies the security schemes that the API uses.
  7. tags: Provides metadata for grouping and organizing operations and endpoints.
  8. externalDocs: Contains links to external documentation related to the API.

These are just a few examples of the fields that can be used in an OpenAPI specification. The full list of fields can be found in the official OpenAPI specification documentation.

How does Apigit contribute to filling in these fields?

While not all fields in an OpenAPI specification are strictly required, there are certain fields that must be included to ensure that the specification is valid and complete. Here are some of the must-have fields in an OpenAPI specification:

  1. openapi: Specifies the version of the OpenAPI specification being used. This field is required and must be included at the root level of the specification.

  2. info: Contains information about the API, such as title, description, version, and contact details. This field is required and must also be included at the root level of the specification.

  3. paths: Defines the endpoints (URLs) of the API and the HTTP methods (GET, POST, PUT, DELETE, etc.) that can be used to access them. This field is also required and must be included at the root level of the specification.

  4. servers: Specifies the server(s) that the API is hosted on. This field is not strictly required, but it is recommended to include it to provide information on the server(s) hosting the API.

  5. components: Contains reusable elements of the API, such as schemas, security schemes, and responses. This field is not strictly required, but it is recommended to include it for better organization and reusability of the specification.

These are the essential fields that must be included in an OpenAPI specification to ensure that it is valid and complete. Other fields such as security, tags, and externalDocs may also be included depending on the needs of the API and the level of detail required in the specification.

To add an API specification to your repository, click on the "+" sign above the file list. Input a pathname, such as "test/test.json," along with other relevant information like the "title" and "version." An empty file will help to fill all these required fields.

Then your json code would be like below.

{
  "openapi": "3.0.3",
  "info": {
    "title": "titlet",
    "description": "just a test",
    "termsOfService": "",
    "contact": {
      "email": ""
    },
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": "1.0"
  },
  "externalDocs": {
    "description": "Find out more about spec",
    "url": ""
  },
  "servers": [],
  "tags": [
    {
      "name": "Default",
      "description": ""
    }
  ],
  "paths": {},
  "components": {
    "schemas": {},
    "securitySchemes": {}
  }
}

How does Apigit assists more?

To illustrate how Apigit assists in filling a field in Form format, here are some examples. Fields in OpenAPI create parameter The Form view of a spec file

Add a parameter under components in Form.

Then your json code would be like below.

  "components": {
    "schemas": {},
    "securitySchemes": {},
    "parameters": {
      "petId": {
        "in": "path",
        "required": true,
        "description": "",
        "schema": {
          "type": "string"
        },
        "name": "petId"
      }
    }
  }

Add a path in Form.

Then your json code would be like below.

"paths": {
    "/getPet/{petId}": {
      "get": {
        "description": "",
        "operationId": "",
        "tags": [],
        "parameters": [],
        "requestBody": {},
        "responses": {
          "511": {}
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/petId"
        }
      ]
    }
  },

To explore more, you can try to fill other fields in Form and switch the view between Form and Code.

Fields in OpenAPI code view The Code view of the same file

Back to Blog

Related Posts

AsyncAPI Governance, GraphQL Mocks and Agent Pages Are Live

APIGit • 2026-11-13
api-design

AsyncAPI browser governance, hosted GraphQL mocks and generated agent pages are live. See the workflows and limits, with AsyncAPI and GraphQL lint in CLI 0.6.0 and hosted server lint availability tracked separately.

Read More

AsyncAPI and GraphQL Join OpenAPI in APIGit

APIGit • 2026-11-13
api-design

Create, edit and publish AsyncAPI documents and GraphQL schemas alongside OpenAPI. One Redoc 3 viewer, full-panel code editing and a clear guide to what each format supports.

Read More

What Are the Components of an API?

APIGit • 2023-04-19
api-design

This article explains the different components of a REST API by following a request from end to end. An API client is responsible for assembling and directing an API request to the API server. An API request to a REST API consists of an endpoint, method, parameters, request headers, and a request body. The API server handles authentication, validates input data, retrieves or manipulates data from a database, and returns the appropriate response to the client. An API response typically includes a status code, response headers, and a body. API status codes are used to provide information to the client about the outcome of the request and to help the client understand how to proceed. Response headers and bodies provide additional information and data about the response.

Read More

Ready to get started with APIGit?

Create a free workspace, add an OpenAPI file and publish your first API document and mock server in minutes.

Get Started Book a Demo