Skip to main content

Auto-fix

Some lint findings have exactly one correct repair. A server URL that ends in a slash loses the slash. A nullable: true in an OpenAPI 3.1 document becomes a type array with "null". For these, a lint rule can carry a fix: a small, deterministic edit computed from the document alone. No AI model is involved, and the same document always gets the same fix.

This page explains which rules are fixable, what kind of edit each fix makes, and where the line is drawn. The rule catalog shows the same information for every rule; see Built-in lint rules.

At a glance​

Every fix takes the same path, wherever you ask for it:

  1. A finding with a fixable rule. The rule's fix computes JSON Patch operations that stay inside the finding. A rule without a fix leaves the finding for a person or an AI assistant.
  2. A plan. Apiome checks the fixes against each other (conflicts) and classifies each fix's change with the classified diff. A breaking fix is never applied.
  3. A choice of output. The ready fixes come back as one JSON Patch, an Overlay 1.0 document or a unified diff (Plan formats).
  4. A new revision. Applying builds the fixed document, imports it as a new revision marked lint-fix, and lints it again. The revision you fixed is never changed (Apply fixes).

You can ask for fixes in four places:

WhereWhat you doSection
REST APIPlan a stored revision or a posted document, then applyPlan the fixes, Apply fixes
UIApply fix in a revision's lint report and in Lint postureApply fixes in the UI
CLIapiome lint --fix, with --dry-run to previewFix from the CLI
CISuggested fixes on the pull request, never applied for youFix suggestions in CI

:::note What ships today

The first thirteen OpenAPI rules and three Arazzo rules carry a fix; the rule catalog (GET /v1/lint/rules) publishes every rule's fix capability. Fixing a local file in place with apiome lint <file> --fix arrives with local-file lint (see Local files); until then, plan a file with the REST API or apiome lint suggest. Nothing in a lint report, score or grade changes because these rules exist: the new rules below are evaluated only when a fix plan is asked for.

:::

How a fix is described​

A fix is a list of JSON Patch operations (add, remove, replace, move) against the document the finding was reported on. Every fixable rule declares four things, and the catalog publishes them:

Catalog fieldMeaning
fixClassWhat kind of edit the fix makes: structural, removal, fill-in or rename
wireVisibleWhether the fix changes what clients see on the wire or in generated code
fixScopeWhat the fix may touch: finding or document
fixDefaultWhether the fix is applied without being switched on by name

fixSummary is one line saying what the fix does.

Fix classes​

ClassWhat it doesExample
structuralRe-spells something without changing its meaningexample: "Rex" becomes examples: ["Rex"]
removalDeletes something that carries no informationAn unused component, or required: []
fill-inAdds a value derived from the document itselfAn operationId built from the method and path
renameChanges how an identifier is spelledList_pets becomes listPets

A fix stays inside its finding​

A fix may only touch the place its finding points at, and anything beneath it. The engine checks every operation, and refuses the whole fix if one reaches outside. A fix for a finding on components.schemas.Pet cannot edit components.schemas.Owner.

One fix needs more room. Renaming a schema moves it to a new key and rewrites every $ref that points to it, anywhere in the document. That rule declares fixScope: document, and the catalog says so. Every other fix has fixScope: finding.

The fixable rules​

All thirteen are OpenAPI rules. The three syntax rules at the top apply to documents that declare OpenAPI 3.1 or later, where the 3.0 spelling is no longer valid.

RuleClassWhat the fix does
structure.nullable-keywordstructuralAdds "null" to the schema's type (and to enum), and removes nullable
structure.schema-example-keywordstructuralMoves example into a one-item examples array
structure.boolean-exclusive-boundstructuralMoves the bound's number onto exclusiveMinimum / exclusiveMaximum
structure.server-url-trailing-slashstructuralRemoves the trailing slash from a server URL
structure.server-url-scheme-casestructuralLower-cases a server URL's scheme (HTTPS:// becomes https://)
structure.unused-componentremovalRemoves a component that nothing references
structure.empty-requiredremovalRemoves required: []
structure.duplicate-tagremovalRemoves a repeated tag declaration
structure.operation-missing-operation-idfill-inAdds an operationId built from the method and path
structure.operation-missing-tagsfill-inAdds a tag named after the first path segment. Off by default
naming.operation-id-camel-caserenameRe-cases an operationId to camelCase
naming.tag-case-mismatchrenameRe-cases a tag on an operation to match its declaration
naming.schema-pascal-caserenameRenames a schema to PascalCase and rewrites its references. Off by default, wire-visible

Fixable Arazzo rules​

An Arazzo workflow document gets its own three fixes, through the same plan, conflict check and output formats. A plan of a posted document (POST /v1/lint/fixes/plan) recognises an Arazzo document by its top-level arazzo field and plans these rules instead of the OpenAPI ones. They read the document you send, so a finding's path is a place in that file, such as workflows.0.steps.1.stepId.

RuleClassWhat the fix does
arazzo.step-id-suffixrenameGives a repeated stepId a suffix: list becomes list-2, then list-3
arazzo.success-criteria-scaffoldfill-inAdds successCriteria: [{condition: "$statusCode == 200"}] to a step that has none. Off by default
arazzo.version-marker-bumpstructuralChanges arazzo: 1.0.x to 1.1.0 when the document uses a 1.1-only feature
  • Step ids. Only the repeat is renamed; the first step keeps its id, so every $steps.<id> and goto that already resolved still points at the same step. The new id is the first <id>-<n> (starting at 2) that no step of the workflow uses. A rename is not wire-visible.
  • The scaffold is derived, never guessed. It is planned only when the step calls an operation by operationId and the source description is embedded in the document (content), so the fix can read the operation's responses. It uses 200 when the operation declares it, otherwise the lowest numeric 2xx code. A 2XX range or default response gives no code, so no scaffold. Because a scaffold is only a starting point, switch it on by name (rules) or in your guide.
  • The marker bump fires when a document that declares Arazzo 1.0 uses an AsyncAPI source description, a channelPath step, or a querystring / channel parameter. The fix names the version that defines what the document already uses; it does not remove anything.

Their one-defect fixtures sit beside the OpenAPI ones in scanner_evaluation/fix/, and the same gates run on them. These rules are separate from the detection rules of the Arazzo lint pack, which keep their own paths and are unchanged.

:::note Local files and ladders

apiome lint <file.arazzo.yaml> --fix follows from local-file lint with no extra Arazzo code: the file is detected by its arazzo field. Until then, plan the file with the REST API. A maturity ladder judges Arazzo and Overlay findings with the guide's shared levels.

:::

The operationId template​

A missing operationId is built from a template. The default is {method}{Path}, which turns GET /pets/{petId} into getPetsPetId. The template may use four placeholders:

PlaceholderValue for GET /pets/{petId}
{method}get
{Method}Get
{path}petsPetId
{Path}PetsPetId

A template must use {path} or {Path}. If two operations would receive the same id, the later one gets a number: getPetsId, then getPetsId2.

Fixes that are off by default​

Two fixes are never applied unless they are switched on by name (fixDefault: false):

  • structure.operation-missing-tags guesses a tag from the path. That suits some APIs and not others.
  • naming.schema-pascal-case is wire-visible: a renamed schema changes the type names in every generated SDK.

When a fix declines​

A fixable rule does not promise a fix for every finding. The fix produces nothing when the repair is not a purely mechanical one, and the finding stays for a person:

  • nullable: true on a schema with no type, or beside a $ref.
  • example on a schema that already has examples.
  • A duplicate tag that carries its own description.
  • An operationId whose new spelling is already taken, or that a link refers to.
  • A schema whose PascalCase name is already taken.
  • An operation with no tags whose path starts with a parameter, such as /{tenant}/pets.

What every fix is tested against​

Each fixable rule has a one-defect fixture in the scanner-evaluation corpus (apiome-rest/tests/fixtures/scanner_evaluation/fix/<rule id>/): a small OpenAPI document with exactly one defect, the plan Apiome must produce for it, and the document it must produce after the fix. Five gates run in the REST CI on every fixture, so a fix cannot silently change more than its finding:

  1. After the fix the rule is clean. The finding is gone, and the fixed document is the expected one, key order included.
  2. No other finding changes. The findings of every other rule, default lint and fixable rules alike, are the same before and after.
  3. Byte-stable twice. Planning and applying a second time changes nothing, and planning the same document twice yields the same plan.
  4. The classified diff is non-breaking. The classified diff of the fix's own change must not be breaking. The few fixes the classifier does read as breaking (the nullable rewrite, the two server URL rules and the schema rename) are pinned in their fixture with the reason; the plan withholds them as breaking and never applies them. If a classification changes, the fixture has to change in review.
  5. No fixable rule without a fixture. Adding a rule with a fix but no fixture fails the build in test_every_fixable_rule_has_a_fixture.

The corpus README lists every fixable rule with its fixture, regenerated from the rule registry. See the scanner-evaluation corpus for how the corpus is organised and how to add a fixture.

What is never fixed​

A fix never invents meaning. These are never fixable, whatever the rule:

  • Descriptions and summaries. Apiome cannot know what your operation does.
  • Examples. A missing or non-conforming example needs a real value.
  • Security schemes and requirements. Guessing these is a risk, not a repair.

The catalog marks who repairs each rule's findings in fixOwner:

fixOwnerMeaning
engineThe rule carries a deterministic fix
agentThe repair needs judgement about meaning: every documentation and security rule, and the examples pack. These are left for an AI assistant or a person, never for a fix
humanEverything else

Plan the fixes​

A fix plan lists every finding a fix could repair, the JSON Patch operations of each fix, and whether the fix may be applied. Ask for one over a stored revision:

GET /v1/versions/{tenantSlug}/{projectId}/{versionId}/lint/fixes
X-API-Key: <your-api-key>

Or over a file, without storing anything (file mode). Send the document as YAML or JSON text:

POST /v1/lint/fixes/plan
X-API-Key: <your-api-key>
Content-Type: application/json

{ "document": "openapi: 3.1.0\ninfo: …" }

A revision is planned under its project's style guide. A posted document is planned under your workspace's style guide. A rule the guide turns off is not planned unless you name it.

Both take the same options:

OptionDefaultMeaning
formatjsonjson, patch, overlay or diff (see Plan formats)
rulesevery rulePlan only these rules. Comma-separated in the query, a list in the body. Naming a rule also selects a fix that is off by default, a rename, or a rule the guide turns off
includeRenamesfalsePlan rename fixes, including naming.schema-pascal-case
operationIdTemplate{method}{Path}The operationId template

The same document and options always give a byte-identical plan.

Plan statuses​

Every entry of a plan has a status:

StatusMeaning
readyThe fix may be applied
conflictThe fix edits the same part of the document as another ready fix. conflictsWith names that fix
breakingThe fix's own change is classified as breaking. It is never applied
excludedThe fix was not selected. reason says why

Conflicts. Two fixes conflict when one edits a node and the other edits that node or something inside it. The fix of the outer node wins. Removing an unused schema wins over re-spelling example inside it. Plan again after applying the winner: if the loser's finding is still there, it is ready this time.

Breaking fixes. Apiome applies each fix on its own and compares the result with the original using the classified diff. If the change contains anything breaking, the fix becomes breaking, and the entry's classification lists the changes. A schema rename is the usual case: removing the old name breaks clients. The classifier also treats a changed server URL (trailing slash, scheme case) as a removed server, and a widened type array as a type change, so those fixes are breaking too.

Exclusions. reason is one of:

reasonWhy
not-selectedYou named other rules in rules
guide-disabledThe style guide turns the rule off
renames-not-includedIt is a rename fix and includeRenames is false
opt-in-requiredThe fix is off by default (structure.operation-missing-tags)

An excluded entry still lists its operations, so you can see what it would do.

A plan entry​

{
"fixId": "fix-05817bbcff5519df",
"ruleId": "structure.empty-required",
"fixClass": "removal",
"wireVisible": false,
"path": "components.schemas.Order",
"pointer": "/components/schemas/Order",
"findingId": "lint-05817bbcff5519df",
"message": "Schema declares an empty required list.",
"ops": [{ "op": "remove", "path": "/components/schemas/Order/required" }],
"status": "ready",
"reason": null,
"conflictsWith": null,
"classification": {
"maxSeverity": null,
"counts": { "breaking": 0, "non-breaking": 0, "docs-only": 0, "unclassified": 0, "total": 0 },
"changes": []
}
}

The plan also returns counts (entries per status), appliedOrder (the ready fixes in the order they are applied), documentFingerprint and fixedDocumentFingerprint. A revision's plan adds reportFingerprint and reportCurrent: the fingerprint of the revision's stored lint report and whether that report still matches the planned document.

Plan formats​

formatReturns
jsonThe plan, as above
patchOne JSON Patch document with the ready fixes' operations, in the order they apply (application/json-patch+json)
overlayThe same change as an Overlay 1.0 document. Each operation becomes a remove and/or an update action, and info.title names the rules
diffA unified diff of the document before and after, as indented JSON (text/x-diff)

The overlay output produces the same document as the patch. Keep it instead of editing your source: store it in the revision's overlay chain, or apply it at export.

Apply fixes​

POST /v1/versions/{tenantSlug}/{projectId}/{versionId}/lint/fixes/apply
X-API-Key: <your-api-key>
Content-Type: application/json

{ "fixIds": ["fix-05817bbcff5519df"], "reason": "Tidy before review" }

Name the fixes in exactly one of:

  • fixIds: fixes from the plan. Each must be ready.
  • rules: every ready fix of these rules. Fixes of those rules that are not ready are listed in the response's skipped.

reason is required and is recorded on the audit entry. The body also takes includeRenames, operationIdTemplate and versionLabel. Send the same includeRenames and operationIdTemplate you planned with, so the fix ids match.

Applying needs the versions:edit permission, and the revision must not be published.

Apply never changes the revision. Apiome builds the fixed document and imports it as a new revision of the same project, through the import quality gate, like an upload. Then it:

  1. lints the new revision and stores its report;
  2. records source: lint-fix on the new revision, with the fix ids, the rules and your reason;
  3. writes a version.lint_fix_applied audit entry.

Steps 2 and 3 are written together. If they cannot be written, the new revision is withdrawn, so an apply leaves one audited revision or nothing. The response names the new revision (versionRecordId, versionLabel), the fixes applied, and its new score and grade.

StatusCodeWhen
409lint-fix-version-publishedThe revision is published
422lint-fix-breakingA named fix is breaking, or every fix of the named rules is
422lint-fix-conflictA named fix is a conflict. Apply the fix it conflicts with first
422lint-fix-excludedA named fix is excluded. Name its rule in rules, or set includeRenames
422lint-fix-unknownA fix id is not in the revision's plan
422lint-fix-nothing-to-applyThe named rules have no ready fixes
422lint-fix-invalid-optionsAn unknown rule, or an invalid operationId template
422lint-fix-not-openapiThe revision is not an OpenAPI 3.x document

Applying every ready fix and then planning again leaves nothing ready.

Apply fixes in the UI​

Both UI surfaces call the same apply endpoint, with a reason:

  • Versions → lint report: a Fix chip on each fixable finding and Apply N deterministic fixes for all ready ones. See Version dialogs → Lint report.
  • Lint posture: Apply fix in a finding's drawer and in the bulk bar, for findings on catalog revisions. The finding moves to Fixed only once the new revision's lint report no longer lists it. See Lint posture → Apply a fix.

Only ready fixes are offered. breaking and conflict entries show their reason, and a published revision's fixes are read-only.

Fix from the CLI​

apiome lint --fix plans a version's fixes and applies the ready ones as a new revision, like Apply fixes. Add --dry-run first to see the change without writing anything:

apiome lint --project payments-api --version 1.0.0 --fix --dry-run

The summary goes to stderr and the change to stdout, as a unified diff of the document before and after:

Fix plan: 2 ready, 0 conflict, 1 breaking, 0 excluded
ready structure.empty-required components.schemas.Order
ready structure.nullable-keyword components.schemas.Order.properties.note
breaking structure.server-url-trailing-slash servers[0] (the change is breaking; never applied)
Dry run: nothing was written.
--- a/openapi.json
+++ b/openapi.json
@@ -20,10 +20,10 @@
"Order": {
"properties": {
"note": {
- "nullable": true,
- "type": "string"
+ "type": [
+ "string",
+ "null"
+ ]
}
},
- "required": [],
"type": "object"
}

Drop --dry-run to apply. The CLI prints the plan again, then the new revision:

Applied 2 fixes as new revision 1.0.1 (dddddddd-dddd-4ddd-8ddd-dddddddddddd).
Score 91 grade A
1 fix need a person:
1 breaking: never applied; change the API by hand.

The revision you planned on is never changed, and the apply needs the same permission and an unpublished revision as the REST call. Its audited reason is Applied with apiome lint --fix.

OptionMeaning
--dry-runPrint the change and write nothing
--only rule,ruleFix only these rules. An unknown rule id is refused, and nothing is planned. Naming a rule also selects a fix that is off by default or a rename, as rules does
--allow-renamesInclude rename fixes (includeRenames)
--fix-format diff|patch|overlayPrint or write the change as a unified diff (the default), one JSON Patch, or an Overlay 1.0 document
-o, --output <file>Write the change to this file. On a dry run the summary then stays on stdout; without --dry-run, the file records what was applied

A breaking fix is never applied, whatever the options, --allow-renames included. --json prints the plan (with --dry-run), or the plan and the apply response as {"plan", "applied"}.

Exit codes​

CodeWhen
0Nothing to fix, or every ready fix was applied. A dry run always exits 0 when the plan was read
3Fixes remain that need a person: a breaking fix, or a conflict (run --fix again on the new revision, and it is ready)
2A refused request: an unknown --only rule, a published revision, a missing permission, or an option given without --fix
1Apiome could not be reached, or a server error

See the apiome lint reference and Exit codes.

Local files​

apiome lint <file> --fix, which rewrites a local file in place, follows the local-file lint of apiome lint <file>. Until that command exists, plan a file with POST /v1/lint/fixes/plan. When it lands, a YAML file keeps its comments, key order, quoting and indentation, and a JSON file keeps its key order and indentation: only the places a fix changes are rewritten.

Fix suggestions in CI​

A reviewer can tell from the pull request which lint failures are mechanical, without opening a terminal. Three CI summaries carry a Suggested fixes section. Each lists the number of ready fixes per rule, the fix class and the first hunk of one fix as a diff snippet. It also says how many breaking and conflict fixes are left for a person. Suggestions are never applied for you: nothing is written to the version or pushed to the branch.

WhereWhat it shows
apiome lint gate --format markdownThe section before Provenance, planned over the stored version. It links GET …/lint/fixes?format=patch and ?format=overlay
apiome checks run --format md and the provider check runThe section under the evidence of the API change check suite. The provider check's summary is this text, so the pull request shows the fix count and the patch link
diff-actionA second section of the one sticky comment, planned over the spec file in the pull request. It adds one-click suggestion blocks and a workflow artefact

The version summaries plan with the default options: every rule the style guide turns on, without renames. The linked patch therefore holds the same bytes as apiome lint --project P --version V --fix --dry-run --fix-format patch. A version that is not OpenAPI 3.x has no section.

Suggest fixes for a spec file​

apiome lint suggest <file> plans a local file (POST /v1/lint/fixes/plan, nothing stored). Each ready fix is applied on its own to the file's text, so the snippets and line numbers are those of the file itself, YAML comments included. The file is never rewritten.

apiome lint suggest api/openapi.yaml # the Suggested fixes section (Markdown)
apiome lint suggest api/openapi.yaml --format json # rules, plus a line range per fix
apiome lint suggest api/openapi.yaml --format patch -o fixes.patch.json
OptionWhat it does
--formatmarkdown (default), json, or the full change as patch, overlay or diff (the plan endpoint's bytes)
--pathThe file's path as the pull request names it, used in the section (default: the path you gave)
--artifact-urlWith markdown: link the full patch and overlay at this URL
--only, --allow-renamesAs for --fix
-oWrite to this file instead of standard output

With --format json, suggestions lists every ready fix that changes one region of the file. Each has its startLine, endLine and the replacement text for those lines. That is what a GitHub suggestion block needs. A fix that changes several places is listed under rules only. The command exits 0 whatever it suggests.

Read the fix capability of a rule​

GET /v1/lint/rules
X-API-Key: <your-api-key>

Each rule carries fixable, fixOwner, and, when it is fixable, fixClass, wireVisible, fixSummary, fixScope and fixDefault:

{
"ruleId": "structure.server-url-trailing-slash",
"pack": "openapi",
"category": "structure",
"defaultSeverity": "info",
"fixable": true,
"fixClass": "structural",
"wireVisible": false,
"fixSummary": "Removes the trailing slash from the server URL.",
"fixScope": "finding",
"fixDefault": true,
"fixOwner": "engine"
}

For a rule that is not fixable, fixable is false and the other fix fields are null. See the lint REST reference.