# @frctl/json-schema

> Parser to convert condensed JSON schemas to standard ones.

Latest version **0.1.0** (published 2017-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @frctl/json-schema
pnpm add @frctl/json-schema
yarn add @frctl/json-schema
bun add @frctl/json-schema
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-05-26 |
| First published | 2017-05-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6.0.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | allmarkedup |

## Links

- npm: https://www.npmjs.com/package/@frctl/json-schema
- Repository: https://github.com/frctl/json-schema
- Issues: https://github.com/frctl/json-schema/issues
- npm.io page: https://npm.io/package/@frctl/json-schema

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [@frctl/utils](https://npm.io/package/@frctl/utils.md) ^0.4.2

## Recent versions

- 0.1.0 (latest) — 2017-05-26

## README

# JSON Schema

Parser to convert condensed JSON schemas to standard ones.

[![Build Status](https://img.shields.io/travis/frctl/json-schema/master.svg?style=flat-square)](https://travis-ci.org/frctl/json-schema)
[![NPM Version](https://img.shields.io/npm/v/@frctl/json-schema.svg?style=flat-square)](https://www.npmjs.com/package/@frctl/json-schema)

## Overview

This is a parser that generates a fully qualified [JSON Schema](http://json-schema.org/) based on 'condensed' JSON schema input. From [Understanding JSON Schema](https://spacetelescope.github.io/understanding-json-schema/):
> JSON Schema is a powerful tool for validating the structure of JSON data.

### Rationale
[JSON Schema](http://json-schema.org/) is extremely useful for validation purposes; however, in some use cases it may also be more verbose than necessary. This tool was created to allow users of [Fractal](https://github.com/frctl/v2) to add specifications to their components, whilst hiding some of the complexity of the full specification.

```js

const schemaExpander = require('@frctl/json-schema');

const schema = schemaExpander.expand({ title: 'string', modifier: 'string' });

console.log(schema);

/*
Outputs:

{
  "$schema": "http://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "title": {
      "type": "string"
    },
    "modifier": {
      "type": "string"
    }
  }
}

*/
```

## Installation

```bash
npm i @frctl/json-schema --save
```

## API

### .expand(schema)

Returns a fully qualified JSON schema.

* `schema`: A [Condensed JSON schema](/docs/schema.md)


```js
const schema = jsonSchema.parse({ title: 'string', modifier: 'string' });
```

- If a valid condensed schema is provided, a converted, fully qualified schema will be returned.
- If an already fully qualified schema is provided, it will return that.
- If an invalid schema is provided, it will return an empty schema (i.e. all data will validate).


## Resources
* [Condensed JSON Schema specification](/docs/schema.md)
* [JSON Schema Validator](http://www.jsonschemavalidator.net/)
* [Understanding JSON Schema](https://spacetelescope.github.io/understanding-json-schema/)

## Requirements

Node >= v6.0 is required.

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