# react-schema-viewer

> React Schema Viewer

Latest version **3.2.3** (published 2019-11-12) · MPL-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install react-schema-viewer
pnpm add react-schema-viewer
yarn add react-schema-viewer
bun add react-schema-viewer
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.2.3 |
| Published | 2019-11-12 |
| First published | 2017-10-10 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 188.3 KB |
| Known vulnerabilities | 0 (+7 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 14 |
| Maintainers | helfi92, taskcluster-bot |
| Keywords | react, json, joi, validation, schema, table, jsonschema, viewer |

## Links

- npm: https://www.npmjs.com/package/react-schema-viewer
- Repository: https://github.com/taskcluster/react-schema-viewer
- Homepage: https://github.com/taskcluster/react-schema-viewer#readme
- Issues: https://github.com/taskcluster/react-schema-viewer/issues
- npm.io page: https://npm.io/package/react-schema-viewer

## Dependencies (6)

- [bootstrap](https://npm.io/package/bootstrap.md) ^3.3.7
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.0
- [markdown-it](https://npm.io/package/markdown-it.md) ^8.4.0
- [react-bootstrap](https://npm.io/package/react-bootstrap.md) ^0.31.3
- [react-hot-loader](https://npm.io/package/react-hot-loader.md) 3.0.0-beta.7
- [joi-to-json-schema](https://npm.io/package/joi-to-json-schema.md) ^3.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.2.3 (latest) — 2019-11-12
- 3.2.2 — 2019-11-08
- 3.2.1 — 2019-10-25
- 3.2.0 — 2019-02-11
- 3.1.0 — 2018-12-17
- 3.0.0 — 2018-12-11
- 2.3.3 — 2018-03-13
- 2.3.2 — 2018-03-13
- 2.3.1 — 2018-03-13
- 2.3.0 — 2018-03-13
- 2.2.2 — 2018-03-13
- 2.2.1 — 2018-03-13
- 2.2.0 — 2018-03-13
- 2.1.2 — 2018-03-12
- 2.1.1 — 2017-10-13
- … 6 more at https://npm.io/package/react-schema-viewer/versions

## README

# react-schema-viewer

<p align="center">
  <img src="https://raw.githubusercontent.com/taskcluster/react-schema-viewer/master/viewer.png" height="250">
</p>

---

React Schema Viewer takes a schema as input and uses it to generate comprehensible views.
It has full support for Joi and JSON schema (version 3 and 4).

## SchemaTable

### Props
| Property                | Type                       | Required? | Description                                                                                       |
|-------------------------|----------------------------|-----------|---------------------------------------------------------------------------------------------------|
| `schema`                | Object                     | ✓         | A JSON schema object.                                                                             |
| `headerBackgroundColor` | string                     | -         | The header background color given that a schema title is provided. Default: 'rgb(245, 245, 245)'. |
| `maxHeight`             | string                     | -         | Max height of the panel. Default: '100%'.                                                         |

## JoiSchemaTable

### Props
| Property                | Type                       | Required? | Description                                                                                       |
|-------------------------|----------------------------|-----------|---------------------------------------------------------------------------------------------------|
| `schema`                | Object                     | ✓         | A Joi schema object.                                                                              |
| `headerBackgroundColor` | string                     | -         | The header background color given that a schema title is provided. Default: 'rgb(245, 245, 245)'. |
| `maxHeight`             | string                     | -         | Max height of the panel. Default: '100%'.                                                         |

### Usage

react-schema-viewer is an ES-compatible module, so it can be imported as expected. If you want to use it with CJS require, you'll need to use the .default property to access the default exports:

_Example: Importing SchemaTable_

```js
// CJS require
const SchemaTable = require('react-schema-viewer/lib/SchemaTable').default;

// ES module
import SchemaTable from 'react-schema-viewer/lib/SchemaTable';
```

_Example: Rendering a JSON schema:_
```js
import React from 'react';
import { render } from 'react-dom';
import SchemaTable from 'react-schema-viewer/lib/SchemaTable';

const jsonSchema = {
  'title': 'Person',
  'type': 'object',
  'properties': {
    'firstName': {
      'type': 'string'
    },
    'lastName': {
      'type': 'string'
    },
    'age': {
      'description': 'Age in years',
      'type': 'integer',
      'minimum': 0
    }
  },
  'required': ['firstName', 'lastName']
};

render((
  <SchemaTable schema={jsonSchema} />
), document.getElementById('root'));
````

<p align="center">
  <img src="https://raw.githubusercontent.com/taskcluster/react-schema-viewer/master/json-joi.png" height="175">
</p>

_Example: Rendering a Joi object schema:_
```js
import React from 'react';
import { render } from 'react-dom';
import JoiSchemaTable from 'react-schema-viewer/lib/JoiSchemaTable';

joi.object({
  firstName: joi.string().required(),
  lastName: joi.string().required(),
  age: joi.number().integer().min(0).description('Age in years'),
}).label('Person');

render((
  <JoiSchemaTable schema={joiSchema} />
), document.getElementById('root'));
````

<p align="center">
  <img src="https://raw.githubusercontent.com/taskcluster/react-schema-viewer/master/json-joi.png" height="175">
</p>

## Development and Contributing

This repository uses [Neutrino](https://neutrino.js.org) and [neutrino-preset-react-components](https://github.com/eliperelman/neutrino-preset-react-components/) for developing, previewing, and building React components. To get started:

- Fork and clone this repo.
- Install the dependencies with `yarn`.
- Start the development servers with `yarn start`.
- Use CTRL-C to exit the development server.
- Use `yarn build` to generate the compiled component for publishing to npm.

Feel free to open an issue, submit a pull request, or contribute however you would like. Understand that this
documentation is still a work in progress, so file an issue or submit a PR to ask questions or make improvements.
Thanks!

## License

react-schema-viewer is released as [MPL 2.0](http://mozilla.org/MPL/2.0/).

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