Repository navigation
[CLI] Make API spec validation configurable #331
Description
Summary
Make the cg check spec command more flexible by allowing users to set compliance thresholds, configure rule strictness, and selectively ignore rules when validating an implementation’s OpenAPI spec against the CommonGrants base spec.
What problem are we solving?
Currently, cg check spec fails if there are any validation errors in an implementation’s OpenAPI spec. This all-or-nothing behavior makes it difficult for teams to adopt the CommonGrants protocol incrementally.
Without more configurability:
- Developers cannot silence or ignore certain rules, even if they are known issues or not relevant for their implementation.
- The command cannot distinguish between critical errors and minor warnings.
- CI/CD pipelines break on partial compliance, making it harder to adopt CommonGrants progressively.
As a result, teams face friction integrating the check into their workflows, which slows down adoption.
What do we propose?
Enhance cg check spec to support more granular configuration:
- Compliance threshold: Instead of failing on the first error, calculate a % compliance score (e.g., 95%) and fail only if it falls below a user-configurable threshold (default = 100%).
- Configurable strictness: Support distinguishing warnings vs. errors, and allow users to set a strictness level (e.g., fail only on errors, fail on warnings, etc.)
- Ignore rules: Allow users to silence specific rules, similar to tools like pylint, ruff, or eslint. Ideally rules could be ignored globally or by path.
- Configuration file: Introduce support for a config file (e.g.
.cgcheck.yamlor.cgcheck.toml) that defines thresholds, rule strictness, and ignored rules. - CI/CD integration: Ensure exit codes reflect configured thresholds and strictness, making it easy to adopt in pipelines.
Here's an example of a potential config file format:
complianceThreshold: 95
strictness: error # options: error, warning, strict
ignore: # ignores across all routes
- "response-schema-conflict"
- "missing-status-code"Why does it matter to CommonGrants adopters?
Configurability enables incremental adoption. Instead of having to be 100% compliant from day one, teams can start by tracking compliance, ignoring non-critical rules, and gradually tightening their standards over time. This lowers the barrier to integrating cg check spec into real-world workflows, especially in CI/CD environments.
Effort and dependencies
Moderate effort: ~3 sprints
Acceptance criteria
-
cg check specsupports a config file for compliance thresholds, rule strictness, and ignored rules - Command reports a compliance % and fails only if below threshold (default 100%)
- Users can configure whether warnings count as failures, and can selectively ignore rules
- Documentation updated with examples of config-driven usage in local dev and CI/CD environments
Fider
- Vote for this feature: Post
- Votes: 6
Dependencies
Here are the upstream and downstream dependencies for this issue:
flowchart LR
%% ─────────────────────────────
%% Styles
%% ─────────────────────────────
classDef default fill:#fff,stroke:#333,stroke-width:1px,color:#000,rx:5,ry:5
classDef InProgress fill:#e1f3f8,stroke:#07648d,stroke-width:2px,color:#000
classDef Done fill:#8DE28D,stroke:#204e34,stroke-width:3px,color:#000
style Canvas fill:transparent,stroke:#171716
style Legend fill:#F7F7F4,stroke:#171716
%% ─────────────────────────────
%% Legend
%% ─────────────────────────────
subgraph Legend["Key"]
direction LR
k1["Todo"]
k2["In progress 🛠️ "]:::InProgress
k3["Done ✔️"]:::Done
k1 -.-> k2 -.-> k3
end
%% ─────────────────────────────
%% Main canvas
%% ─────────────────────────────
subgraph Canvas["Dependencies"]
direction LR
HHS/simpler-grants-protocol#331["Make API spec validation configurable"]
HHS/simpler-grants-protocol#335["Create GH action and badge for CommonGrants compliance"]
%% ─────────────────────────────
%% Relationships
%% ─────────────────────────────
HHS/simpler-grants-protocol#331 --> HHS/simpler-grants-protocol#335
end
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
widal001 commentedon Nov 5, 2025
Context
We need an extensible way to configure the behavior of
cg check specto override or alter how certain validations are applied. Ideally this configuration format would borrow inspiration from other popular linters likeeslint,pylint, andruffand could be easily extended to other CLI commands.In particular we want to answer the following questions:
Decision
We'll support yaml or json config files, that can either be passed using the
--configflag to the CLI or automatically discovered if a file exists with the following name in the root of the current directory:cg.config.[yml | yaml | json]Config files MUST follow the format outlined below, which is designed to closely mirror an updated version of the
check specoutput, making it easier for CLI users to create config files using the output as a guideline.cg check specoutput exampleHere's an example of the new proposed output for
cg check spec, designed to closely mirror the structure of the overrides section of the config file:Config example
Here's a sample config file that would adjust how we handle the warnings and errors in the output above, with some optional
explanationvalues documenting each override rule.Config syntax notes
Here's a more detailed breakdown of the override syntax:
Note
Each of the optional properties only restrict the scope of override. For example,
method: GETlimits an override to routes with aGETmethod, but omitting themethodproperty defaults to all methods. As a result, the following override would ignoreextra_propglobally (i.e. on all endpoints and schemas):check specREADME and implementation #524resolveAnyOf()incg check specworks #735