# Find Out Why A Governance Rule Did Or Did Not Fire On Your OpenAPI

**Published:** 2026-11-30  
**Author:** Kin Lane  
**Canonical:** https://apievangelist.com/2026/11/30/find-out-why-a-governance-rule-did-or-did-not-fire-on-your-openapi/

The most common question I get about API governance isn't "what rules should we have?" It is "why did this rule flag my API?", and right after it, "why *didn't* it flag that one?" A lint report tells you what failed. It doesn't tell you what the rule looked at, what it was checking for, or whether it even ran. Without that, the conversation between the team that owns the style guide and the team that owns the API turns into an argument about the tool when it should be about the API.

That is the job `explain_rule_result` does. Behind it is the REST operation `POST /governance/explain`. You give it a document and a rule id, and it walks the rule step by step. First, did the document match the rule's `formats`? Second, what did the `given` path select? Third, what field did `then` check? Last, a one-line verdict. It looks the rule up in a ruleset you pass, then in our curated catalog, then in OpenLint's built-in rulesets.

## What I gave it

I used the [Tic Tac Toe example](https://github.com/OAI/learn.openapis.org/blob/main/examples/v3.1/tictactoe.yaml) from the OpenAPI Initiative's learn site. It's a small, public, OpenAPI 3.1 description with three operations, and everyone can open it. I passed the full YAML as `document` and called the tool three times, with three built-in rules:

- `info-license`: does the `info` object carry a license?
- `operation-operationId`: does every operation have an `operationId`?
- `oas2-api-host`: does a Swagger 2.0 document declare a `host`?

I picked those three because I expected one to fire, one to pass and one to not run at all. Those are the three answers people are usually confused by.

## What came back

The license rule fired, and the explanation showed me why:

```json
{
  "rule": "info-license",
  "origin": "builtin",
  "verdict": "Fired 1 time(s): `given` matched 1 node(s) and `then` failed on 1.",
  "steps": {
    "formats": { "declared": [], "match": true },
    "given": [ { "path": "$", "matches": 1, "sample": [""] } ],
    "then": { "field": "info.license" }
  },
  "diagnostics": [ {
    "message": "Info object must have \"license\" object.",
    "severity": "warning",
    "path": ["info"]
  } ]
}
```

The Tic Tac Toe `info` block has a title, a description and a version, and no license. So the rule was right. What's useful is that I can see *how* it decided. It declares no formats, so it runs on anything. It selects the document root and checks for `info.license`.

The operationId rule did not fire, and the explanation says it wasn't skipped. It checked and passed:

```json
"verdict": "Did not fire: `given` matched 3 node(s) and `then` passed on every one.",
"given": [ {
  "path": "$.paths[*][get,put,post,delete,options,head,patch,trace]",
  "matches": 3,
  "sample": [ "/paths/~1board/get",
              "/paths/~1board~1{row}~1{column}/get",
              "/paths/~1board~1{row}~1{column}/put" ]
} ]
```

That's the difference between "passed" and "never looked", and a plain lint report hides it. Here I can see the expanded path and all three operations it reached by pointer. If someone adds a fourth operation and the count still says three, I know it's the selector that's wrong and not the API.

The Swagger rule didn't run at all:

```json
"verdict": "Did not run: the rule applies to [OpenAPI 2.0 (Swagger)] and the document matches none of them.",
"formats": { "declared": ["OpenAPI 2.0 (Swagger)"], "match": false }
```

This is the answer to most "why didn't my rule catch this?" questions I see. The rule was scoped to a format the document isn't in.

To be honest about it, two things in the output are rough. When `given` is the document root (`$`), the sample comes back as an empty string. It's technically the root's JSON pointer, but it reads like nothing matched. Also, the Swagger rule still reports `given` matching one node even though it never ran. The verdict is right, but a quick reader could take that count as evidence the rule did something. I'd rather see the root shown as `/`, and the `given` step left out when formats don't match. Both are on my list.

## What that makes possible

- **End the argument faster.** When a producer pushes back on a finding, the steward can paste the explanation instead of defending the linter. It shows the selector, the field and the verdict, so the discussion moves to whether the rule is the right rule.
- **Debug your own rules before you publish them.** Pass your `ruleset` along with a sample spec, and you'll see whether the `given` lands where you intended. An empty match count is how a custom rule silently does nothing in CI for months.
- **Let an agent explain its own lint results.** An agent that runs `validate_api` and gets a warning can call this next, so it can tell the user why the warning happened, not just that it did. It can also tell a real failure apart from a rule that doesn't apply.
- **Audit format scoping.** Run your style guide's rules against a 3.1 document and look for "Did not run". That's the list of rules you think are protecting you and aren't.

If you're writing the `given` paths yourself, last Tuesday's post on [pointing a rule at the right part of an OpenAPI](https://apievangelist.com/2026/11/24/point-a-governance-rule-at-the-right-part-of-an-openapi-before-you-write-it/) with `query_jsonpath` is the step before this one.

## Try it

It's free. Over MCP, connect to `https://mcp.apievangelist.com/mcp` and call `explain_rule_result` with a `document` and a `rule`. Over REST:

```sh
curl -X POST https://api.apievangelist.com/v1/governance/explain \
  -H "Content-Type: application/json" \
  -d '{"rule": "info-license", "document": "openapi: 3.1.0\ninfo:\n  title: Demo\n  version: 1.0.0\npaths: {}"}'
```

- Reference: [Governance API](https://developer.apievangelist.com/governance-api)
- MCP server docs: [developer.apievangelist.com/mcp-server](https://developer.apievangelist.com/mcp-server)
- Getting started: [developer.apievangelist.com/getting-started](https://developer.apievangelist.com/getting-started)
