> ## Documentation Index
> Fetch the complete documentation index at: https://bruno-a6972042-docs-timeline-scripts.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# External Libraries

Bruno allows you to load any npm module for use in your scripting workflows.

## Prerequisites

Before you begin, ensure that you have the following:

1. Node.js installed on your system.
2. Bruno installed.

## Project Structure

The folder structure for this example will be:

```
bruno-collection/
├── api-testing/
├── openspec.yaml
├── .spectral.yml
├── package.json
├── bruno.json
└── node_modules/
    └── spectral-cli
```

## Configuration

You need to initialize `package.json` file inside your collection.

Navigate to your Bruno collection directory in the terminal.

```bash theme={null}
cd path/to/your/bruno-collection
```

Initialize `package.json` file inside your collection.

```bash theme={null}
npm init -y
```

Now you can install any npm package or module to use in your collection.

## Spectral Integration

In this example we're using [Spectral CLI <strong><sup>↗</sup></strong>](https://github.com/stoplightio/spectral?tab=readme-ov-file) as a npm package which help you to validate OpenSpec API YAML or JSON files with the built-in ruleset.

You need to have OpenAPI JSON or YAML file to work with spectral or you can download from [here <strong><sup>↗</sup></strong>](https://github.com/ganesh-bruno/spectral-example) as example.

### Spectral CLI Setup

You can install `spectral-cli` by running following command:

```bash theme={null}
npm install @stoplight/spectral-cli
```

Run this command in your terminal to initialize `.spectral.yml` file which is predefined ruleset.

```js copy theme={null}
echo 'extends: ["spectral:oas", "spectral:asyncapi", "spectral:arazzo"]' > .spectral.yaml
```

Validate your **openapi.yaml** file from Bruno collection by running following CLI command:

```js copy theme={null}
spectral lint openspec.yaml --r .spectral.yaml
```

## Output Overview

After following the process outlined above, warning messages will be displayed on the CLI such as duplicates and empty tags. This is how you can validate your OpenSpec files using Spectral.

```bash theme={null}
openspec.yaml:
 2:6  warning  info-contact    Info object must have "contact" object.      info
 10:9 warning  operation-tags  Operation must have non-empty "tags" array.  paths./pets.get
 36:9 warning  operation-tags  Operation must have non-empty "tags" array.  paths./pets/{petId}.get
```
