Skip to main content

Configuring Validation

You can configure the validation process as per your requirements by providing a validation configuration in the APIMatic's Metadata file which needs to be uploaded along with the API definition/specification:

{
"ValidationConfiguration": {
"SkipLinting": true
}
}

The capabilities that this configuration provides is as follows:

  • Skipping some rules of a ruleset, the entire ruleset or a group of rulesets e.g. skipping all linting rulesets.

  • Enabling only some rules from a ruleset and skipping the rest.

  • Enabling rules of a ruleset that are kept disabled by default either because of low priority or any other reason.

  • Overriding severity of rules depending on needs e.g. converting a warning into error.

    note

    The capabilities differ w.r.t. whether the ruleset is meant for validation or linting. Validation rules/rulesets can only be enabled but not skipped nor can their severity be changed.

Validation Configuration Object

The available properties and their respective types are as follows:

PropertyTypeDetails
SkipCodeGenerationChecksBooleanWhen set to true, linting checks associated with code/SDK generation will not be performed. Code generation checks are enabled by default unless you are performing only transformations in the API Transformer.
SkipLintingBooleanDefault: false. When set to true, all linting rulesets will be entirely skipped and only validation rulesets will be applied.
RulesetsMap[String, Ruleset Configuration]Configuration for each ruleset. The key is the unique id/code that identifies a ruleset and the value provides required configurations for that ruleset. The rulesets not specified here will work with default behavior.

Example 1 - Skip all linting rules:

{
"SkipLinting": true
}

Example 2 - Configuring a ruleset:

The following configuration will let you skip the rule no-ambiguous-path from the openapi-v3-standards-linting ruleset and also downgrade the severity of all rules in the ruleset from Warning to Information. Here, no-ambiguous-path and openapi-v3-standards-linting are rule and ruleset ids respectively.

{
"Rulesets": {
"openapi-v3-standards-linting": {
"Severity": "Information",
"Rules": {
"Skip": ["no-ambiguous-path"]
}
}
}
}

Ruleset Configuration Object

This configuration object will let you configure a single ruleset. The available properties and their respective types are as follows:

PropertyTypeDetails
SkipBooleanDefault: false. When set to true, all checks from the ruleset will be skipped/ignored. Only applicable for linting rulesets.
SeverityRule SeverityThe severity set here will override severity level of all rules in the ruleset. Only applicable for linting rulesets. If a rule in this ruleset has severity overrides provided in the rules configuration of the ruleset, the rule level severity configuration will take precedence.
FilePathStringRelative path to a custom ruleset file.
RulesRules ConfigurationConfiguration for specific rules of the ruleset can be provided here. Rules not configured explicitly or implicitly here will work with default behavior.

Example

{
"Skip": true
}

Ruleset Rules Configuration Object

This configuration will let you configure rules of a ruleset. The available properties and their respective types are as follows:

PropertyTypeDetails
EnableAllBooleanDefault: false. When set to true, all rules of the ruleset will be applied including those that may be disabled by default and any configurations provided under EnableOnly or Enable will be ignored.
EnableOnlyArray[String]If a list of rule ids/codes is provided, only those rules from the ruleset will be applied and others will be skipped regardless of any default configuration or configurations provided using the Enable setting. Only applicable for linting rulesets.
EnableArray[String]A list of rule ids/codes to enable. This can be used to enable rules from a ruleset that may be disabled by default for any reason (low priority or any other). The default behavior will be used for rules not specified here.
SkipArray[String]If a list of rule ids/codes is provided, they will not be applied. Only applicable for linting rulesets. Rules listed here will be ignored regardless of any configurations provided under EnableAll, EnableOnly or Enable.
SeverityMap[String, Rule Severity]This will let you override severity of a rule e.g. changing an error to warning. Only applicable for linting rulesets. The key should be the id/code of the rule you wish to change severity of.

Example 1 - Enable only selected rules from a ruleset:

{
"EnableOnly": [
"unique-case-insensitive-header-parameter-names", //using rule id
"OPENAPI3STANDARDS_L065" //using rule code
]
}

Example 2 - Skip a rule from a ruleset:

{
"Skip": [
"no-ambiguous-path"
]
}

Example 3 - Changing severity of a rule:

{
"Severity": [
{
"valid-schema-example": "Error"
}
]
}