DEV Community

Cover image for What Is a Git-Native API Workflow (and How Do You Build One)?
Hassann
Hassann

Posted on • Originally published at apidog.com

What Is a Git-Native API Workflow (and How Do You Build One)?

Your API code, CI pipelines, reviews, and release history already live in Git. Your OpenAPI spec should live there too.

Try Apidog today

A Git-native API workflow keeps your OpenAPI definition beside your application code. You edit the spec as YAML or JSON, commit it, review it in a pull request, and run it through the same automation as the rest of your project. The spec is no longer trapped in a separate cloud database or passed around through exports.

💡 Apidog supports this workflow with Spec-First Mode. You can design APIs in an IDE-style editor and sync raw OpenAPI files both ways with GitHub or GitLab. This guide explains what a Git-native API workflow means, why cloud-locked specs create friction, and how to set up Spec-First Mode step by step.

What a Git-native API workflow means

A Git-native API workflow treats your API spec as code. Your OpenAPI file lives in a repository alongside your services. Every change has a commit, an author, a message, and a diff.

This gives your API contract the same workflow you already use for source code:

  • Version history: use git log and git blame to see who changed an endpoint and when.
  • Branching and review: review spec changes in pull requests before they merge.
  • One source of truth: the file in main becomes the API contract that docs, mocks, tests, and generators consume.

A spec-first workflow means the specification leads and the implementation follows. For more background, see spec-first API development.

The alternative is storing your spec inside a proprietary cloud tool. That can work early on, but it often breaks down as your team adds more reviewers, automation, and release controls.

The problem with cloud-locked API specs

Many API design tools store the spec in their own database. You edit through a UI, but the actual source of truth is not a file in your repo.

That creates several practical problems.

Reviews happen in two places

Code changes go through GitHub or GitLab. Spec changes go through a separate tool with separate comments and separate history.

That means reviewers need to switch context, and approvals can drift out of sync.

Diffs are harder to inspect

When the spec lives in a cloud database, you usually cannot review a clean line-by-line OpenAPI diff in the same pull request as the code.

Instead of reviewing this:

 responses:
   "200":
     description: Order found
+  "404":
+    description: Order not found
Enter fullscreen mode Exit fullscreen mode

You may end up approving a vague “updated API design” without seeing the exact contract change.

Exports become part of the process

To use the spec in CI, you need to export it, commit the exported file, and hope nobody changed the cloud version in the meantime.

That creates two sources of truth:

  1. The cloud spec.
  2. The exported spec in Git.

Sooner or later, they conflict.

Automation needs files

Linters, contract tests, mock servers, and code generators usually expect a file on disk:

npx @redocly/cli lint openapi.yaml
Enter fullscreen mode Exit fullscreen mode

A cloud-locked spec adds an extra fetch or export step before your tools can run.

Treating your API spec as code removes that friction. The file is the spec, Git is the history, and CI can run directly against it. See API spec as code for the broader principle.

How Apidog Spec-First Mode works

Spec-First Mode is designed for teams that already work with commits, branches, and pull requests.

You edit raw YAML or JSON OpenAPI files in Apidog, then sync those files with your Git repository in both directions.

1. Edit OpenAPI in an IDE-style editor

Instead of filling out a form, you write the OpenAPI file directly.

The editor provides:

  • Syntax highlighting for YAML and JSON.
  • Validation against OpenAPI and Swagger schemas.
  • Auto-completion for OpenAPI keywords, data types, and references.

You still control the actual file. There are no hidden fields or UI-only metadata.

2. Keep the spec as raw YAML or JSON

Your OpenAPI definition remains a real file in your repository.

Example:

openapi: 3.1.0
info:
  title: Orders API
  version: 1.2.0

paths:
  /orders/{orderId}:
    get:
      summary: Get an order by ID
      operationId: getOrder
      parameters:
        - name: orderId
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Order found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Order"
        "404":
          description: Order not found

components:
  schemas:
    Order:
      type: object
      properties:
        id:
          type: string
        status:
          type: string
          enum: [pending, shipped, delivered]
Enter fullscreen mode Exit fullscreen mode

This is the same file that gets committed to Git.

3. Navigate large specs with an auto-parsed outline

As you type, Apidog parses the file and builds a visual outline in the left sidebar.

You can jump between:

  • Paths.
  • Operations.
  • Schemas.
  • References.

This is useful when your OpenAPI file grows beyond a few endpoints and scrolling becomes inefficient.

4. Sync both ways with Git

Spec-First Mode connects to your Git provider and keeps the repository and Apidog workspace aligned.

It supports:

  • GitHub.
  • GitLab.
  • Azure DevOps through a Git Connection.

A typical workflow looks like this:

Pull latest spec from Git
        ↓
Edit YAML/JSON in Apidog
        ↓
Commit changes
        ↓
Push back to the tracked branch
Enter fullscreen mode Exit fullscreen mode

5. Commit and push without leaving Apidog

You can stage changes, write a commit message, and push from Apidog.

The sync status indicator shows whether your workspace is up to date. After a successful push, it shows a status such as “Synced just now.”

If you change your mind before pushing, you can discard unpushed edits and return to the last synced state.

For a GitHub-specific walkthrough, see sync OpenAPI spec to GitHub.

Setup walkthrough

Here is the basic loop for setting up a Git-native OpenAPI workflow with Apidog Spec-First Mode.

For the full reference, see the Spec-First Mode docs.

Step 1: Create a Spec-First project from a repo

In Apidog, create a new Spec-First project and connect your Git provider.

Choose:

  • The repository that contains your API spec.
  • The branch to track, usually main.
  • The OpenAPI YAML or JSON files you want to work with.

Apidog pulls the existing spec files into the editor.

Step 2: Edit the OpenAPI file

Open the spec file and make a contract change.

For example, add a missing 404 response:

responses:
  "200":
    description: Order found
  "404":
    description: Order not found
Enter fullscreen mode Exit fullscreen mode

As you edit, Apidog provides syntax highlighting, validation, and auto-complete. The left sidebar outline updates automatically.

Step 3: Review changed files

Apidog shows which files changed since the last sync.

You can identify:

  • Modified files.
  • Added files.
  • Deleted files.

This lets you verify what will be included in the commit before pushing.

Step 4: Write a clear commit message

Use the same commit-message habits you use for application code.

Good:

Add 404 response to getOrder
Enter fullscreen mode Exit fullscreen mode

Less useful:

Update spec
Enter fullscreen mode Exit fullscreen mode

A clear commit message helps reviewers understand the API contract change quickly.

Step 5: Push to the tracked branch

Push the commit to the connected branch.

Your teammates and CI pipeline can now consume the updated OpenAPI file.

Step 6: Confirm the sync status

Check the sync status indicator.

When it reads “Synced just now,” your Apidog workspace and the remote branch match.

At that point, the change can move through your normal workflow:

Branch → Commit → Push → Pull request → Review → Merge → CI
Enter fullscreen mode Exit fullscreen mode

That is the full loop: pull, edit, commit, push, and verify. No manual export. No second source of truth.

Spec-First Mode vs Design-First Mode

Apidog supports two workflows. The main difference is where the spec lives and how you edit it.

Spec-First Mode (beta) Design-First Mode
Spec storage Raw YAML/JSON files in Git Apidog cloud project
Primary editor IDE-style code editor Visual form-based UI
Version control Native Git: commits, branches, diffs Apidog history and branches
Two-way Git sync Yes: GitHub, GitLab, Azure DevOps Via export/import
Best for Teams that live in Git Teams that prefer a visual workflow

Neither mode is universally better.

Use Spec-First Mode if your API review and release process already runs through Git. Use Design-First Mode if your team prefers visual editing and rarely works with raw OpenAPI files.

When to use Spec-First Mode

Use Spec-First Mode when:

  • Your API spec should go through pull requests.
  • You want git blame, commit history, and branch-based review for your API contract.
  • Your CI runs OpenAPI linting, contract tests, mock generation, or code generation.
  • Multiple engineers edit the spec and need mergeable diffs.
  • You want to stop exporting specs from one tool to feed another.

A simple CI step might look like this:

name: Validate OpenAPI

on:
  pull_request:
    paths:
      - "openapi.yaml"

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npx @redocly/cli lint openapi.yaml
Enter fullscreen mode Exit fullscreen mode

This works because the OpenAPI file is already in the repository.

Stick with a visual, cloud-first approach when non-engineers own the API design or when your team prefers form-based editing over raw YAML or JSON.

FAQ

What is a Git-native API workflow?

A Git-native API workflow stores your OpenAPI spec as a file in a Git repository. Changes are managed through commits, branches, and pull requests, just like application code.

Does Apidog Spec-First Mode support GitHub and GitLab?

Yes. Spec-First Mode syncs two ways with GitHub and GitLab directly. Azure DevOps is supported through a Git Connection.

Can I edit OpenAPI files as raw YAML or JSON?

Yes. Spec-First Mode provides an IDE-style editor for raw YAML and JSON, with syntax highlighting, schema validation, and auto-completion for OpenAPI and Swagger.

What is the difference between Spec-First Mode and Design-First Mode?

Spec-First Mode keeps your spec as raw files in Git and edits them in a code editor with two-way sync. Design-First Mode keeps the spec in an Apidog cloud project and provides a visual, form-based editor.

Choose Spec-First Mode if your API workflow already depends on Git.

Conclusion

A Git-native API workflow removes the split between your code and your API contract. The OpenAPI spec becomes a file, the file becomes a commit, and the commit moves through the review process your team already uses.

Apidog Spec-First Mode gives you the editor, outline, and two-way Git sync to make that workflow practical. You edit raw YAML or JSON, commit the change, push it, and verify the synced state.

Try Spec-First Mode and bring your API spec back to Git.

Top comments (0)