Spectral Style Guides
Create or import Spectral rulesets in Swagger Studio and execute them in your API definitions for easy linting and validation. This functionality ensures centralized and efficient control over API governance. The protocols that support Spectral rulesets are Swagger Studio are: OpenAPI 2.x, 3.x, and AsyncAPI.
SwaggerHub CLI enables you to upload and download Spectral style guides.
Import Spectral style guides
Supported formats
You can import Spectral rulesets to your Swagger Studio organization in the following formats:
YAML
JavaScript
JSON
Pre-bundled as a
.ziparchiveImportant
The
.ziparchive must contain a valid Spectral ruleset at the root and can reference other files and functions in the archive. Custom functions must be stored in a separate folder in the archive.
Import a ruleset
To import a Spectral ruleset, follow these steps:
Click Governance on the sidebar.
Select Import Style Guide under the Spectral Style Guides section.
In the Import Style Guide dialog, provide the name of the new ruleset. Depending on your preferred import method, enter a path or URL of the style guide file or click to select the file from your local device.
Click Import to upload the file.
The list of imported style guides appears under Spectral Style Guides.
Create and edit custom style guides
The Spectral Ruleset Editor allows you to create and edit Spectral rulesets directly from the Governance page. It supports the creation of single- and multi-file ruleset projects, and adding or updating custom functions.
Overview of Spectral Ruleset Editor
Using the Spectral Ruleset Editor, you can modify your rulesets and organize their structure. A ruleset project's folder and file layout is visible in the editor's left panel.

Click the + plus icon to add a new file to the last opened folder.
Click the
folder icon to add a new folder.Click the
pencil icon to rename your ruleset.Search for files or folders within your project by entering their name in the search bar.
Add a new ruleset
To create a new Spectral ruleset, follow these steps:
Click Governance on the sidebar.
Select Create New in the Spectral Style Guides section.
Enter the name of the new ruleset and click Save.
A new ruleset project is created and opens in the Spectral Ruleset Editor. The project is pre-populated with
spectral.yaml.(Optional.) After adding any further changes to the project in the Spectral Ruleset Editor, click Save to submit your work.
Edit a ruleset
To edit an existing ruleset, follow these steps:
Click Governance on the sidebar.
Expand the Spectral Style Guides section to display the list of your Spectral rulesets.
Select Edit next to the ruleset project you want to update.
The project opens in the Spectral Ruleset Editor.
Add your updates to the ruleset.
Click Save to submit the edits.
Manage style guides
You can manage your existing rulesets in the Spectral Style Guides section of the Governance page.

Click the
copy icon to duplicate a ruleset.Click the
download icon to export a ruleset.Click the
pencil icon to edit your ruleset in the Spectral Editor.Click the
delete icon to remove a ruleset.
Learn more about Spectral
You can find the open-source Spectral library here.
For detailed information about Spectral features and rulesets, refer to the Spectral documentation and best practices when creating API style guides.