# ajv-inspector

> Uses ajv to compile a JSON Schema and lets you inspect it.

Latest version **1.3.1** (published 2017-10-25) · 0 weekly downloads

## Install

```sh
npm install ajv-inspector
pnpm add ajv-inspector
yarn add ajv-inspector
bun add ajv-inspector
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2017-10-25 |
| First published | 2016-03-25 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.2.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+5 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Mateu Aguiló Bosch |
| Maintainers | e0ipso |

## Links

- npm: https://www.npmjs.com/package/ajv-inspector
- Repository: https://github.com/e0ipso/ajv-inspector
- Homepage: https://github.com/e0ipso/ajv-inspector#readme
- Issues: https://github.com/e0ipso/ajv-inspector/issues
- npm.io page: https://npm.io/package/ajv-inspector

## Dependencies (3)

- [ajv](https://npm.io/package/ajv.md) ~4.11.7
- [lodash](https://npm.io/package/lodash.md) ~4.17.4
- [request](https://npm.io/package/request.md) ~2.83.0

## Recent versions

- 1.3.1 (latest) — 2017-10-25
- 1.3.0 — 2017-04-18
- 1.2.0 — 2017-04-18
- 1.1.4 — 2016-08-17
- 1.0.4 — 2016-04-29
- 1.0.3 — 2016-04-14
- 1.0.2 — 2016-03-30
- 1.0.1 — 2016-03-29
- 1.0.0 — 2016-03-25

## README

[![Build Status](https://travis-ci.org/e0ipso/ajv-inspector.svg?branch=master)](https://travis-ci.org/e0ipso/ajv-inspector)
[![Coverage Status](https://coveralls.io/repos/github/e0ipso/ajv-inspector/badge.svg?branch=master)](https://coveralls.io/github/e0ipso/ajv-inspector?branch=master)

This module allows you to inspect a JSON schema. Take a schema and request a path to drill donw into the schema to get the dereferenced schema.

This project is based on [ajv](https://github.com/epoberezkin/ajv) and leverages it to load and compile the JSON schemas.

You don't really need this if you are not using references in your schema.

## API
The first part is loading and compiling the schema, and *then* inspect the schema.

```js
const SchemaInspector = require('ajv-inspector');

const schemaObject = {
  '$schema': 'http://json-schema.org/draft-04/schema#',
  type: 'object',
  title: 'Person',
  requiredProperties: ['location'],
  properties: {
    location: {'$ref': 'http://json-schema.org/geo'},
    address: {'$ref': 'http://json-schema.org/address'},
    name: {
      description: 'The person name',
      type: 'string'
    }
  }
};

// Options are passed to ajv. In this case since we have to load
// data over HTTP we can use the loader helper.
const options = {loadSchema: SchemaInspector.httpSchemaLoader};
// Build the inspector with the schema.
const inspector = new SchemaInspector(schemaObject, options);
// Compile the schema.
inspector.compile()
  .then(() => {
    // You can now inspect the schema!
    console.log(inspector.inspect('location.latitude'));
    // Outputs: {type: 'number'}
  });
```

See the [unit tests](https://github.com/e0ipso/ajv-inspector/blob/master/test/index.js#L111-L130) for more details and examples.

---
_Source: https://npm.io/package/ajv-inspector · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
