← All articles

SwaggerPulse journal

The OpenAPI Spec GitHub Workflow: Repo to Uptime

Key takeaways

  • Keep the source OpenAPI spec at a predictable path like openapi.yaml at the repo root, and avoid linting generated artifacts under build/ or dist/.
  • View any spec instantly by pasting its raw.githubusercontent.com URL into Swagger UI or another hosted viewer, with no build step.
  • Treat the spec as code: one feature branch per change, tag releases like api-v3.0.0, and review diffs to paths, components.schemas, and required arrays as breaking-change flags.
  • Run Spectral via GitHub Actions on every pull request and set it as a required status check so a broken spec can never reach main.
  • Point SwaggerPulse at the raw Swagger JSON URL to generate one uptime monitor per endpoint, keeping spec changes and monitoring in sync.

Your openapi spec github workflow comes down to five moves: keep the spec file at a predictable path in your repo, preview it with GitHub's rendered view or a hosted Swagger viewer, version it with branches and tags like any other code, validate it automatically on every pull request, and feed the live Swagger JSON URL into endpoint monitoring so a spec change and an uptime check never drift apart. This guide walks through each step for a solo or small-team setup.

Where can I find the OpenAPI spec file in a GitHub repository?

Most repos keep the spec in one of a handful of places: the root (openapi.yaml, openapi.json, swagger.json), a /docs folder, /api, or /spec. If the repo has a README that mentions the API, it usually names the file. Search the repo for openapi: or "swagger": to find YAML or JSON containing the paths object, which only the live spec will have.

The trap is generated artifacts. Files under build/, dist/, or generated/ are often output from the source spec, not the source itself. Check the git history: the real spec gets edited directly, while artifacts are only touched by CI commits. Linting tools like Spectral expect the source file, so point them at the one humans edit.

Once you know which file is live, tools like SwaggerPulse can consume that same spec to drive endpoint checks.

How do I view an OpenAPI spec online directly from GitHub?

The quickest route is to paste your raw file URL into a hosted viewer. GitHub serves any file at raw.githubusercontent.com, so a spec living at https://raw.githubusercontent.com/you/your-repo/main/openapi.yaml can be dropped into Swagger UI's online demo or a viewer like Redoc's renderer to see the rendered docs immediately. No build step, no deployment.

Pointing Swagger UI at a raw GitHub URL

Self-hosting Swagger UI is a single HTML file with one config value: set the url parameter to your raw GitHub link and serve the page anywhere static. Two caveats matter. First, GitHub's raw responses carry the right CORS headers for GETs, so browser-based rendering works. Second, if your spec is split across $ref files, the viewer resolves them relative to the raw URLs, so relative references between files in the same repo usually resolve correctly.

Private repos and token-gated raw URLs

Raw URLs on private repos require authentication, so a viewer in the browser cannot fetch them directly. Options: generate a fine-grained personal access token with read-only contents scope and append it as a query parameter (treat that URL as a secret), or keep the spec in a public docs repo while the code stays private. Some teams commit a rendered copy to a gh-pages branch on merge, which keeps the public viewer working without exposing the source repo.

How should I version OpenAPI specs across branches and releases?

Feature branch per spec change

Treat the spec like code, because it is code. Open a branch per change: feature/add-webhooks-endpoint, not spec-update. A one-path-per-branch habit keeps pull requests small enough that reviewers actually read the diff, and it means a rejected change never contaminates main. Merge to main for the next unreleased version, and never edit the spec directly on main.

Tagging releases against API versions

Decide early whether info.version tracks the URL path (/v2/users) or moves independently. Most teams pin them together: when you ship /v3, bump info.version to 3.0.0 and cut a Git tag like api-v3.0.0 in the same commit. That tag is your contract. Anything consuming the Swagger JSON URL can pin to it, and rolling back is a checkout, not an archaeology project. Keep old tags deployed at versioned URLs so consumers' integrations never break mid-refactor.

Reading spec diffs in review

The long paragraph worth quoting on its own: a spec diff is only reviewable if your PR shows the paths object changing line by line, the same way it shows application code. That is the case for keeping a single hand-written source file rather than regenerating artifacts into the repo: a regenerated blob hides a renamed parameter inside ten thousand changed lines. Review the source, generate on CI, and treat any diff touching paths, components.schemas, or a required array as a breaking-change flag that needs a second pair of eyes. Once merged, point your viewer of choice at the raw file; Swagger UI can load a spec directly from a URL, so reviewers can click through the rendered docs for the branch before approving.

How do I validate an OpenAPI spec automatically in a GitHub pull request?

Add a GitHub Actions workflow that lints your spec with Spectral on every pull request. Any change to the paths object, a schema, or a response code gets checked before merge, so a typo in your Swagger JSON never reaches your generated docs or your uptime checks.

A minimal lint workflow

Commit a workflow file at .github/workflows/lint-spec.yml that runs on pull_request with paths: ['openapi.yaml', 'openapi.json']. It checks out the repo, installs @stoplight/spectral-cli, and runs spectral lint openapi.yaml --fail-severity=warn. The paths filter keeps the job from running on unrelated PRs, which matters when your minutes budget is thin. If you keep multiple specs, pass each file or glob to the lint step.

Blocking merges on lint failures

Spectral's non-zero exit code fails the job automatically. To make that matter, set the workflow as a required status check in your repo's branch protection settings, so main cannot receive a broken spec. Pick --fail-severity=warn rather than error if your ruleset flags style nits you do not want blocking a rename.

For breaking changes, run Spectral's oas3-valid-schema rules plus a diff against the base branch's spec in a second step, and fail the PR when a path or required response disappears.

What naming and folder conventions work best for OpenAPI specs in a repo?

Start with one spec per service. If your paths object has fewer than a dozen operations, a single openapi.yaml at the repo root is easiest to lint and diff. Past that, split into api/spec/paths/ with one file per resource and a root document that pulls them together with $ref. Keep every $ref relative so the spec resolves the same locally and in CI.

Single file vs split by paths object

Splitting by paths object keeps pull request diffs reviewable: a change to /orders touches one file. Validate the assembled spec, not the fragments, so a GitHub Actions workflow runs your linter on the root document on every PR; the GitHub Actions workflow syntax reference covers the trigger and job setup.

Multi-repo vs monorepo specs

One repo per service keeps spec ownership aligned with deployment ownership. In a monorepo, mirror the folder layout: services/payments/api/openapi.yaml. Use consistent filenames (openapi.yaml, not a mix) so tooling and uptime checks can find the spec without per-service configuration.

How do I keep generated docs in sync with the spec in GitHub?

Drift happens when someone edits the spec but never regenerates the docs. The fix is to make regeneration a CI step that runs on every merge to main, so the published output always matches the merged spec.

Regenerate on merge to main

Trigger a workflow on push to main, filtered to the spec path (for example openapi/**). The job checks out the repo, runs your generator of choice against the Swagger JSON, and commits the output back or opens a PR if anything changed. If the generated files differ from what's committed, the workflow fails, which forces the doc update into the same PR as the spec change.

Publishing docs from CI

After regeneration succeeds, push the generated HTML or docs bundle to GitHub Pages or an S3 bucket from the same workflow. Keep the published artefact tied to a commit SHA so you can always trace a live docs page back to the exact spec revision that produced it.

Which tools compare for monitoring an API defined by a GitHub-hosted spec?

Pick a monitor with the same criteria you'd apply to any tooling around your spec: can it read the OpenAPI spec itself rather than making you retype URLs, what does the free tier actually cover, and is it hosted or another thing to self-host. Hosted endpoint monitors like UptimeRobot, Checkly, and Hyperping poll URLs you type in by hand; Assertible works from API definitions; Uptime Kuma is a popular self-hosted option, though self-hosting means running your own infrastructure and managing its resource footprint. If you tag spec releases, any monitor should survive a version bump, so keep your tags SemVer-compatible.

SwaggerPulse against the same criteria

CriteriaSwaggerPulse
Spec-driven checksEndpoint checks generated from your Swagger JSON URL and paths object
PriceFree £0 tier (10 monitors / 100 endpoints), Pro £7.99
Self-host vs hostedHosted, GitHub sign-in, no infrastructure to run
Spec change historyTracked as your spec evolves on GitHub

Honest gap: the 10-monitor cap on Free is a real limit if you run many small APIs, and hosted means you depend on us rather than a container you control.

How do I turn a GitHub-hosted Swagger JSON URL into uptime checks?

From raw URL to monitors

Point SwaggerPulse at the raw Swagger JSON URL in your repo (the raw.githubusercontent.com link on your default branch, or a gist). It reads the paths object and creates one monitor per endpoint, so GET /users and POST /orders get separate uptime checks with their own response-time tracking. When you merge a spec change, re-sync and the endpoint list updates to match. The Free tier covers 10 monitors and 100 endpoints; Pro is £7.99 if you outgrow that.

Alerting and the public status page

When an endpoint check fails, you get a downtime email alert, so a broken deploy on one API does not wait for a customer to notice. Each project also gets a public status page you can link from your repo's README. If you already run Uptime Kuma or UptimeRobot, the difference is that the check list comes from the spec you maintain anyway, not from typing URLs by hand.

FAQ

Can I use a private GitHub repo's Swagger JSON URL for monitoring?

Not directly, because raw URLs on private repos require authentication and a monitor cannot fetch them as-is. Your options: commit the spec to a public docs repo, publish a rendered copy to a gh-pages branch on merge, or keep the repo public if the spec alone reveals nothing sensitive. The monitoring target needs to be fetchable without a token.

Is there a free tier for OpenAPI-driven uptime monitoring?

Yes. SwaggerPulse's Free tier costs £0 and covers 10 monitors and 100 endpoints, with Pro at £7.99 if you outgrow it. The 10-monitor cap is a real limit if you run many small APIs. Hosted alternatives like UptimeRobot and Hyperping also have free plans, though they typically require typing endpoint URLs by hand rather than reading your spec.

Do I need to redeploy anything when my OpenAPI spec changes on GitHub?

No deployment is needed for monitoring. Once your monitor reads the raw Swagger JSON URL, re-syncing after a merge updates the endpoint list to match the new spec. Version bumps are the exception to plan for: keep old Git tags deployed at versioned URLs so consumers' integrations keep working, and pin monitors to the tag that matches what production actually runs.

What is the difference between openapi.yaml and swagger.json in a repo?

They are the same specification in different formats. swagger.json signals the older Swagger 2.0 naming, while openapi.yaml or openapi.json signals OpenAPI 3.x, with YAML and JSON as interchangeable serialisations. What matters for your workflow is consistency: pick one filename and format per repo so linters, viewers, and uptime checks can find the spec without per-service configuration.

Can GitHub Actions check for breaking API changes between spec versions?

Yes. Run Spectral's oas3-valid-schema rules plus a diff against the base branch's spec in a second workflow step, and fail the pull request when a path or required response disappears. Treat any diff touching paths, components.schemas, or a required array as a breaking-change flag that needs a second pair of eyes before merge.