Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Cap32 committed Jan 30, 2018
1 parent fab3f3c commit b87e8b0
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@

[WIP] JSON Schema Draft 6 plugin for [Skeeler](https://github.com/Cap32/skeeler)

## Table of Contents

<!-- MarkdownTOC -->

* [Simple Example](#simple-example)
* [Equals to JSON Schema Draft 6](#equals-to-json-schema-draft-6)
* [Options](#options)
* [Related projects](#related-projects)
* [License](#license)

<!-- /MarkdownTOC -->

<a name="simple-example"></a>

## Simple Example

```js
Expand All @@ -29,10 +43,13 @@ const mySkeeler = new Skeeler({
export default mySkeeler.export('json');
```

<a name="equals-to-json-schema-draft-6"></a>

### Equals to JSON Schema Draft 6

```js
export default {
type: 'object',
properties: {
foo: {
type: 'string',
Expand Down Expand Up @@ -70,10 +87,68 @@ export default {
};
```

<a name="options"></a>

## Options

By default, all the schema definitions will be compiled to `properties` in JSON schema, and the root type is `object`.

#### `other` option

If you want to pass some attributes outside `properties`, you may use `other` option.

###### Example

```js
const skeeler = new Skeeler({});
const options = { other: { title: 'awesome' } };
skeeler.export('json', options);

/**
* output
*
* { type: 'object', properties: {}, title: 'awesome' }
*/
```

#### `strict` option

If you want to writing in native JSON Schema way, you may use `strict` option.

###### Example

```js
const skeeler = new Skeeler({
properties: {
foo: types.string,
bar: types.number,
},
required(['foo', 'bar']),
});
const options = { strict: true };
skeeler.export('json', options);

/**
* output
*
* {
* properties: {
* foo: { type: 'string' },
* bar: { type: 'number' },
* },
* required: ['foo', 'bar'],
* }
*/
```

<a name="related-projects"></a>

## Related projects

* [Skeeler](https://github.com/Cap32/skeeler)

<a name="license"></a>

## License

MIT

0 comments on commit b87e8b0

Please sign in to comment.