Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/busterc/ndjson-generate-schema
:information_source: Effortlessly convert your NDJSON data to a JSON Schema.
https://github.com/busterc/ndjson-generate-schema
json-schema json-schema-generator jsonld jsonlines jsonschema ndjson
Last synced: 15 days ago
JSON representation
:information_source: Effortlessly convert your NDJSON data to a JSON Schema.
- Host: GitHub
- URL: https://github.com/busterc/ndjson-generate-schema
- Owner: busterc
- License: isc
- Created: 2018-04-13T21:09:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-25T22:02:27.000Z (over 6 years ago)
- Last Synced: 2024-11-17T17:47:05.213Z (about 1 month ago)
- Topics: json-schema, json-schema-generator, jsonld, jsonlines, jsonschema, ndjson
- Language: JavaScript
- Size: 80.1 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ndjson-generate-schema [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url]
> Effortlessly convert your NDJSON data to a JSON Schema.
* Powered by: [`generate-schema`](https://github.com/nijikokun/generate-schema)
## Installation
```sh
$ npm install --save ndjson-generate-schema# Or to use the CLI globally
$ npm install --global ndjson-generate-schema
```## Usage
Given an NDJSON file `dogs.db`:
```
{"id":1,"name":"Buddy","breed":"Boston Terrier"}
{"id":2,"name":"Charley"}
```### CLI
```sh
$ ndjson-generate-schemaEffortlessly convert your NDJSON data to a JSON Schema.
Usage
$ ndjson-generate-schema [outfile]
Inputs
title Required, Title of Schema
file Required, NDJSON file to read
outfile Optional, filename to write Schema out to
```### Module
```js
const path = require('path');
const ndjsonGenerateSchema = require('ndjson-generate-schema');ndjsonGenerateSchema('Dogs', path.resolve(__dirname, 'dogs.db')).then(
schema => {
console.log(schema);
/*
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Dogs Set",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"name": {
"type": "string"
},
"breed": {
"type": "string"
}
},
"required": [
"id",
"name"
],
"title": "Dogs"
}
}
*/
}
);
```## API
### `ndjsonGenerateSchema(title, file)`
* ### `title`
* `Required` : `String` the title of the Schema
* ### `file`
* `Required` : `String` the NDJSON file to read## License
ISC © [Buster Collings](https://about.me/buster)
[npm-image]: https://badge.fury.io/js/ndjson-generate-schema.svg
[npm-url]: https://npmjs.org/package/ndjson-generate-schema
[travis-image]: https://travis-ci.org/busterc/ndjson-generate-schema.svg?branch=master
[travis-url]: https://travis-ci.org/busterc/ndjson-generate-schema
[daviddm-image]: https://david-dm.org/busterc/ndjson-generate-schema.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/busterc/ndjson-generate-schema
[coveralls-image]: https://coveralls.io/repos/busterc/ndjson-generate-schema/badge.svg
[coveralls-url]: https://coveralls.io/r/busterc/ndjson-generate-schema