OpenAPI: Lint, Format and Structure a Maintainable API

OpenAPI: Lint, Format and Structure a Maintainable API

operationId, tags, error responses: rules that prevent spec debt on OpenAPI files.

09.08.2026
10 min read
Share this article:
openapi
lint
format
api-design
REST
Tutorial

Why lint and format OpenAPI specs before merging?

A spec can pass schema validation yet still ship without operationId, missing tags, or only a default response — and that technical debt shows up weeks later when SDK generators, API portals, or contract tests fail silently. Formatting alone does not fix those gaps; linting catches style and completeness rules that validators ignore. FastMinify's online OpenAPI linter applies a fixed Spectral-style subset on path operations, entirely in your browser. Pair it with the OpenAPI formatter for readable PR diffs and the OpenAPI validator for schema conformance. Start with our OpenAPI validation guide if structural errors block you first, then explore the API tools hub.

Catch missing operationId, tags, and 2xx responses before SDK or portal generation
Spectral-style subset: info-contact, paths-kebab-case, operation-description, and more
Format JSON or YAML for stable PR diffs — optional recursive key sort
100% local — specs never leave the browser (ideal for internal contracts)
Recommended chain: validate → format → lint → commit

Honest limits and maintainable API design

What lint-openapi does not do

A passed lint status means no issues in the v1 rule subset — not that your API is production-ready or fully documented.

No security testing (auth flows, scope enforcement)
No runtime contract testing against live endpoints
No automatic multi-file bundle — one self-contained paste per run
No Swagger 2.0 support — OpenAPI 3.x only
Warnings do not block a "passed with warnings" status — treat them as merge blockers if your team policy says so
operationId, tags, and error responses

These fields prevent spec debt that validators miss but generators and portals require.

operationId: stable, unique, camelCase — avoid renaming without a deprecation plan
tags: group by domain or bounded context — match your developer portal sections
2xx responses: lint enforces presence — add explicit 400/401/404/500 with schemas where clients need them
info.description and info.contact: lint warns when missing — fill them for external APIs
Path naming: prefer /pet-orders over /petOrders — kebab-case rule aligns with REST conventions
When to escalate to CI tooling

Browser tools accelerate feedback; pipelines enforce org-wide policy.

Custom Spectral rulesets (naming, security headers, pagination patterns)
Breaking-change detection between spec versions
Bundling multi-file specs with external $ref resolution
Gateway-specific import validation (AWS API Gateway, Kong plugins)
Document the OpenAPI target version (3.0 vs 3.1 JSON Schema draft) in the repo README

Design-first: validate, format, then lint

Three tools, three intents

Do not swap steps during review — each tool answers a different question about your OpenAPI file.

Validate (validate-openapi): OpenAPI 3.x schema conformance via Scalar — valid/invalid verdict
Format (format-openapi): indentation and readability — does not fix semantic or style gaps
Lint (lint-openapi): Spectral-style rules on path operations — warnings and errors separate from schema validate
Recommended order: validate → format → lint before merge
JSON syntax alone is not enough — see the validation guide for schema vs lint
Lint rules in v1 (Spectral-style subset)

FastMinify lint is not full Spectral — it ships a fixed rule set focused on maintainable path operations (ADR-OAS-009).

not-openapi (error): root must be OpenAPI 3.x with an info object — gate before other rules
info-contact (warning): info.contact should be present
info-description (warning): non-empty info.description
paths-kebab-case (warning): path segments should be kebab-case or vN
operation-operationId (warning): every operation needs a non-empty operationId
operation-tags (warning): at least one tag per operation
operation-description (warning): summary or description required
operation-success-response (error): at least one 2xx response — default alone does not count
path-item-ref (warning): path item $ref not expanded in v1 lint
What lint does not cover (v1)

Honest scope — avoid assuming parity with Spectral, Redocly, or gateway policy engines.

Path operations only — webhooks and callbacks are out of scope in v1
No custom ruleset upload — fixed subset, not a Spectral runner
Lint does not replace schema validate — run validate-openapi for Scalar conformance
No external $ref URL fetch — paste a self-contained spec
512 KiB input limit — very large specs belong in CI tooling
Format for review, not for semantics

The formatter pretty-prints JSON or YAML (2 or 4 space indent) and can sort keys recursively for stable diffs.

JSON in → JSON out; YAML in → YAML out — input kind preserved
YAML comments are lost on format — snapshot before reformatting annotated specs
Numeric openapi: 3.0 in YAML normalizes to string 3.0.0
Sort keys helps PR review — not an OpenAPI-aware section reorder
Invalid OpenAPI may still format if parse succeeds — always re-validate after heavy edits

Lint and format OpenAPI: step-by-step workflow

Using the OpenAPI linter

The OpenAPI linter parses JSON or YAML (max 512 KiB), checks the not-openapi gate, then runs path-operation rules. Status: passed, passed with warnings, or failed — never a plain green when warnings exist.

Live debounced lint in the Monaco editor
Issue list with rule code, level, and JSON Pointer path
Results panel: error/warning counts and paths/operations stats
Parse errors surface with line numbers when known
Swagger 2.0 documents fail the not-openapi gate — migrate to OpenAPI 3 first
Using the OpenAPI formatter

The OpenAPI formatter pretty-prints for human review. Auto-format on paste; use the Format button (⌘↵) after manual edits.

Indentation 2 or 4 spaces — team convention
Optional recursive key sort for stable git diffs
Shiki-highlighted output panel
Chain format → validate → lint for a full pre-merge pass
Pair with <a href="/en/json-validator" class="text-primary hover:underline">JSON validator</a> if raw syntax is suspect
Scenario — SDK generation blocked by missing operationId

Your mobile pipeline generates a client from the spec — warnings you ignored become hard failures downstream.

1

Step 1: Validate schema conformance

Paste into validate-openapi. Fix Scalar errors first — lint will not help on a structurally invalid spec.

2

Step 2: Lint path operations

Open lint-openapi. Resolve operation-operationId and operation-tags warnings on every public endpoint.

3

Step 3: Format and open the PR

Run the fixed spec through format-openapi with key sort if your team uses stable diffs. Re-lint before commit.

Scenario — Unreadable YAML diff in contract review

A designer exports minified YAML — reviewers cannot spot accidental path renames.

1

Step 1: Format for readability

Paste into format-openapi, pick 2-space indent, enable sort keys if the team agrees.

2

Step 2: Validate then lint

Validate with Scalar, then lint for paths-kebab-case and operation-success-response on new endpoints.

3

Step 3: Document error responses

Lint enforces 2xx presence — manually add 4xx/5xx responses with descriptions for production-grade contracts (not covered by v1 lint errors).

PR review workflow: from design-first to merge

Recommended pre-merge checklist

Treat the browser trio as a fast gate before git push — CI remains the team source of truth, but catching issues locally saves pipeline minutes. Order: (1) validate-openapi — fix Scalar errors; (2) format-openapi — readable diff; (3) lint-openapi — resolve errors, then warnings per team policy; (4) commit.

Reviewer focus areas

Beyond green validate, ask: Are operationId values unique and stable for codegen? Do tags map to your API portal navigation? Does every operation document at least one success response — and are common error shapes described for client teams?

Pairing with CI and sibling tools

In CI, teams often run Spectral, openapi-cli, or Redocly with custom rulesets stricter than FastMinify v1. Combine browser lint with our CI/CD automation guide. For schema pivots, use json-schema-to-openapi and openapi-to-json-schema on the hub. To validate payloads against a schema once the contract is sound: json-schema-validator (dedicated article coming).

Conclusion

Maintainable OpenAPI specs need more than schema validation: lint catches the operationId, tag, and response gaps that block generators, and formatting keeps PRs reviewable. Validate first, format for humans, lint for style — all locally before CI. Explore the API hub for JSON Schema conversion and GraphQL SDL validation when your contract work expands beyond REST.

Chain validate → format → lint before every spec PR
Treat lint warnings as merge blockers when SDK generation is in scope
Enable key sort only if the whole team agrees — it changes diff semantics
Re-read the validation guide when Scalar errors appear before debugging lint
Escalate to CI Spectral/Redocly for org-specific rules beyond v1 subset
Share this article
Share this article: