---
schema_version: "1"
id: f2cb9fc68c72363d5a0dc14a2f107272ad488ea719f711ebce926fa5a309aa08
title: Validating and Publishing Custom Rulesets
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/api-governance/custom-rulesets-validate-and-publish.md
canonical_url: https://docs.mulesoft.com/api-governance/custom-rulesets-validate-and-publish
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0b67c90e0ee0ec18b5429a45abb6defebb0ef286aa79785d42bb17c775812089
description: MuleSoft Documentation Site
latest: true
---
---
product: API Governance
---

# Validating and Publishing Custom Rulesets

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

After you create a custom ruleset:

1.  [Validate](#validate-ruleset) the ruleset.

2.  [Generate the documentation](#generate-ruleset-doc) for the ruleset.

3.  [Publish your custom ruleset](#publish-ruleset) to Exchange as a new asset.

For an example sequence of commands to validate and publish your rulesets, see
[Example Command Sequence to Validate and Publish](#example-publish-sequence).

> [!NOTE] As with custom code and configurations, rulesets are not considered supported MuleSoft
> products. For help with issues with custom rulesets, post an issue in the
> [AMF Custom Validator Github repository](https://github.com/aml-org/amf-custom-validator).

## Validate the Ruleset

To validate your governance ruleset as you create it and before you publish it, use the following
command:

### governance:ruleset:validate

`> governance:ruleset:validate [flags] <governance-ruleset>`

Validates the ruleset definitions passed using the `governance-ruleset` parameter. You can pass one
of the following as the `governance-ruleset` parameter:

- A ruleset definition YAML file

- A ZIP file that contains an API project with an `exchange.json` file that specifies the ruleset as
  the main file

- A folder that contains an API project with an `exchange.json` file that specifies the ruleset as
  the main file

This command accepts the [default flags](https://docs.mulesoft.com/api-governance/#default-options).

**Example commands:**

```copy
anypoint-cli-v4 governance:ruleset:validate ~/myrulesetfolder/myruleset.yaml

anypoint-cli-v4 governance:ruleset:validate ~/myrulesetfolder/myruleset.zip

anypoint-cli-v4 governance:ruleset:validate ~/myrulesetfolder/myrulesetfolder
```

**Example output for a valid ruleset:**

Ruleset User/myuser/myrulesetfolder/myruleset.yaml Ruleset conforms with Dialect

**Example output for a nonvalid ruleset:**

Ruleset does not conform with Dialect ModelId: file:///Users/myuser/myrulesetfolder/prof-1-bad.yaml
Profile: Validation Profile 1.0 Conforms: false Number of results: 1

Level: Violation

- Constraint:
  http://a.ml/amf/default\_document#/declarations/profileNode\_profile\_required\_validation
  Message: Property 'profile' is mandatory Severity: Violation Target:
  file:///Users/myuser/myrulesetfolder/prof-1-bad.yaml#/encodes Property: http://schema.org/name
  Range: \[(3,0)-(11,19)\] Location: file:///Users/myuser/myrulesetfolder/prof-1-bad.yaml

## Generate the Ruleset Documentation

Use the following command to generate a documentation ZIP file for a ruleset YAML file. Upload the
resulting documentation ZIP file along with its associated ruleset file using the
`anypoint-cli-v4 exchange asset upload` command.

### governance:document

`> governance:document [flags] <ruleset> <doc-file>`

Creates the documentation for the API Governance ruleset definition ZIP file specified in `ruleset`.
It puts the documentation in the `doc-file` ZIP file for you to upload and publish to Exchange.

This command accepts the [default flags](https://docs.mulesoft.com/api-governance/#default-options).

**Example command:**

```copy
anypoint-cli-v4 governance:document /myrulesetfolder/mynewruleset.yaml /myrulesetfolder/ruleset.doc.zip
```

**Example output:**

validation name \[ 'security-fields-operation-empty' \] validation name \[
'access-tokens-oauth2-cleartext' \] validation name \[ 'insecure-oauth2-grants' \] validation name
\[ 'api-keys-in-cookie' \] validation name \[ 'api-keys-in-query' \] validation name \[
'api-keys-in-header' \] validation name \[ 'api-negotiates-authentication' \] validation name \[
'insecure-basic-auth' \] validation name \[ 'bearer-token-cleartext' \] validation name \[
'http-token-cleartext' \] validation name \[ 'oauth1-deprecated' \] validation name \[
'oauth2-redirections-non-encrypted' \] validation name \[ 'unknown-security-scheme' \] validation
name \[ 'valid-server-urltemplate' \] validation name \[ 'valid-oauth2-redirection-urls' \] Saving
to myRulesetFolder/ruleset.doc.zip

## Publish the Custom Ruleset

You can publish (upload) a ruleset and its documentation to Exchange using the following Anypoint
CLI command.

### exchange:asset:upload

\> exchange:asset:upload \[flags\] <assetIdentifier>

Uploads a rest-api, soap-api, http-api, raml-fragment, custom, app, template, example, policy,
extension, external-library, connector asset, or ruleset using the ID passed in `<assetIdentifier>`

Argument `assetIdentifier` should be formatted as follows: `([group_id]/)<asset_id>/<version>`  
If `group_id` is not specified, it defaults to the currently selected Organization ID

In addition to the [default flags](https://docs.mulesoft.com/api-governance/#default-options), this command accepts the following flags:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Flag</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><div><div><p><code>--categories</code></p></div></div></td><td><div><div><p>Categories (value should be a string in JSON format)</p></div></div></td><td><div><div><p><code>--categories '{"Department": "IT"}'</code></p></div></div></td></tr><tr><td><div><div><p><code>--dependencies</code></p></div></div></td><td><div><div><p>Asset dependencies (comma-separated)</p></div></div></td><td><div><div><p><code>--dependencies groupID:assetID:version,groupID2:assetID:version</code></p></div></div></td></tr><tr><td><div><div><p><code>--description</code></p></div></div></td><td><div><div><p>Asset description</p></div></div></td><td><div><div><p><code>--description "RAML"</code></p></div></div></td></tr><tr><td><div><div><p><code>--files</code></p></div></div></td><td><div><div><p>Asset file, identified as <code>classifier.packaging</code> or <code>packaging</code> and its file path<br>To send multiple files, you can use the same flag multiple times.<br>An exception to this is when you upload ruleset documentation with a ruleset. Both sets of classifiers and packaging options must be entered in a single <code>--files</code> flag</p></div></div></td><td><div><div><p>To upload a POM file and a RAML specification:</p></div><div><p><code>--files'{"pom.xml": "directory/pom-file.xml"}' --files='{"raml.raml": "./my-api.raml"}'</code></p></div><div><p>To upload a ruleset and its documentation:</p></div><div><p><code>anypoint-cli-v4 exchange asset upload my-auth-best-practices/1.0.0 --name "My Best Practices Ruleset" --description "This ruleset enforces my best practices for APIs." --files='{"ruleset.yaml":"/myRulesetFolder/mynewruleset.yaml","docs.zip":"/myRulesetFolder/ruleset.doc.zip"}'</code></p></div></div></td></tr><tr><td><div><div><p><code>--fields</code></p></div></div></td><td><div><div><p>Fields (value should be a string in JSON format)</p></div></div></td><td><div><div><p><code>--fields '{"releaseDate": "2020-01-01T20:00:00.000Z"}'</code></p></div></div></td></tr><tr><td><div><div><p><code>--keywords</code></p></div></div></td><td><div><div><p>Keywords (comma-separated)</p></div></div></td><td><div><div><p><code>--keywords raml,rest-api,someKeyword</code></p></div></div></td></tr><tr><td><div><div><p><code>--name</code></p></div></div></td><td><div><div><p>Asset name (required if no pom file is specified)</p></div></div></td><td><div><div><p><code>--name "Raml Asset"</code></p></div></div></td></tr><tr><td><div><div><p><code>--properties</code></p></div></div></td><td><div><div><p>Asset properties<br>The file of the specified "mainFile" property must be in the uploaded zip file on the root path. The file cannot be in a subfolder.</p></div></div></td><td><div><div><p><code>--properties='{"apiVersion":"v1", "mainFile":"api.raml", "contactName":"contact", "contactEmail":"<a href="mailto:example@mulesoft.com">example@mulesoft.com</a>"}'</code></p></div></div></td></tr><tr><td><div><div><p><code>--status</code></p></div></div></td><td><div><div><p>Asset status<br>Supported Values:</p></div><div><ul><li><p><code>development</code></p></li><li><p><code>published</code> (default)</p></li></ul></div></div></td><td><div><div><p><code>--status development</code></p></div></div></td></tr><tr><td><div><div><p><code>--tags</code></p></div></div></td><td><div><div><p>Tags (comma-separated)</p></div></div></td><td><div><div><p><code>-- tags api,tag1,tag2</code></p></div></div></td></tr><tr><td><div><div><p><code>--type</code></p></div></div></td><td><div><div><p>Asset type</p></div><div><p>Required if no file is specified.</p></div><div><p>Supported Values:</p></div><div><ul><li><p><code>rest-api</code></p></li><li><p><code>soap-api</code></p></li><li><p><code>http-api</code></p></li><li><p><code>raml-fragment</code></p></li><li><p><code>custom</code></p></li><li><p><code>connector</code></p></li><li><p><code>template</code></p></li><li><p><code>example</code></p></li><li><p><code>policy</code></p></li><li><p><code>app</code></p></li><li><p><code>extension</code></p></li><li><p><code>external-library</code></p></li><li><p><code>ruleset</code></p></li></ul></div><div><p>If it is uploaded, the type is inferred from the classifier of the file</p></div><div><p>Depending on the type of asset, some possible classifier values are:</p></div><div><ul><li><p>REST API</p><div><ul><li><p><code>oas</code> (with <code>zip</code>, <code>yaml</code>, or <code>json</code> as packaging)</p></li><li><p><code>raml</code> (with <code>zip</code> or <code>raml</code> as packaging)</p></li></ul></div></li><li><p>RAML Fragment</p><div><ul><li><p><code>raml-fragment</code> (with <code>zip</code> or <code>raml</code> as packaging)</p></li></ul></div></li><li><p>SOAP API</p><div><ul><li><p><code>wsdl</code> (with <code>zip</code>, <code>wsld</code>, or <code>xml</code> as packaging)</p></li></ul></div></li><li><p>Custom</p><div><ul><li><p><code>custom</code></p></li><li><p><code>docs</code> (with <code>doc.zip</code> as packaging)</p></li></ul></div></li><li><p>Application</p><div><ul><li><p><code>mule-application</code> (with <code>jar</code> as packaging)</p></li></ul></div></li><li><p>Policy</p><div><ul><li><p><code>mule-policy</code> (with <code>jar</code> as packaging) + <code>policy-definition</code> (with <code>yaml</code> as packaging)</p></li></ul></div></li><li><p>Example</p><div><ul><li><p><code>mule-application-example</code> (with <code>jar</code> as packaging)</p></li></ul></div></li><li><p>Template</p><div><ul><li><p><code>mule-application-template</code> (with <code>jar</code> as packaging)</p></li></ul></div></li><li><p>Extension</p><div><ul><li><p><code>mule-plugin</code> (with <code>jar</code> as packaging)</p></li></ul></div></li><li><p>Connector</p><div><ul><li><p><code>studio-plugin</code> (with <code>zip</code> as packaging) + file with no classifier and packaging <code>jar</code></p></li></ul></div></li><li><p>External Library</p><div><ul><li><p><code>external-library</code> (with <code>jar</code> as packaging)</p></li></ul></div></li><li><p>Ruleset</p><div><ul><li><p><code>ruleset</code> (with <code>zip</code> or <code>yaml</code> as packaging)</p></li></ul></div></li></ul></div></div></td><td><div><div><p><code>--type rest-api</code></p></div></div></td></tr></tbody></table>

## Example Command Sequence to Validate and Publish

Use the following example sequence to get started validating your ruleset, generating its
documentation, and uploading both to Exchange. Replace the details, such as the folder name, ruleset
file name, and ruleset documentation ZIP file name, with your own.

```console
anypoint-cli-v4 governance:ruleset:validate /myRulesetFolder/mynewruleset.yaml (1)

anypoint-cli-v4 governance:document /myRulesetFolder/mynewruleset.yaml /myRulesetFolder/ruleset.doc.zip (2)

anypoint-cli-v4 exchange asset upload my-auth-best-practices/1.0.0 --name "My Best Practices Ruleset" --description "This ruleset enforces my best practices for APIs." --files='{"ruleset.yaml":"/myRulesetFolder/mynewruleset.yaml", "docs.zip": "/myRulesetFolder/ruleset.doc.zip"}' (3)
```

<table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>Validates the ruleset locally. The ruleset file is <code>mynewruleset.yaml</code> in the <code>/myRulesetFolder/</code> folder.</td></tr><tr><td><i data-value="2"></i><b>2</b></td><td>Generates the documentation ZIP file, <code>ruleset.doc.zip</code>, for the ruleset <code>myruleset.yaml</code>. Both files are in the <code>/myRulesetFolder/</code> folder.</td></tr><tr><td><i data-value="3"></i><b>3</b></td><td>Uploads the ruleset, <code>mynewruleset.yaml</code>, and its documentation, <code>ruleset.doc.zip</code>. Both files are in the <code>/myRulesetFolder/</code> folder.</td></tr></tbody></table>

## See Also

- [Troubleshooting Anypoint CLI](https://docs.mulesoft.com/api-governance/cli-commands-troubleshoot)

- [CLI for Exchange Assets](https://docs.mulesoft.com/anypoint-cli/latest/exchange-assets)
