# schema2md

> A lightweight markdown generator from JSON Schema.

Latest version **0.2.1** (published 2020-03-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install schema2md
pnpm add schema2md
yarn add schema2md
bun add schema2md
```

## 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.2.1 |
| Published | 2020-03-07 |
| First published | 2020-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | ulivz |
| Maintainers | ulivz |

## Links

- npm: https://www.npmjs.com/package/schema2md
- Repository: https://github.com/rich-lab/json-schema-2-markdown
- Homepage: https://github.com/rich-lab/json-schema-2-markdown#readme
- Issues: https://github.com/rich-lab/json-schema-2-markdown/issues
- npm.io page: https://npm.io/package/schema2md

## Dependencies (2)

- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2

## Recent versions

- 0.2.1 (latest) — 2020-03-07
- 0.2.0 — 2020-03-07
- 0.1.5 — 2020-03-07
- 0.1.4 — 2020-03-07
- 0.1.3 — 2020-03-06
- 0.1.2 — 2020-03-06
- 0.1.1 — 2020-03-06
- 0.1.0 — 2020-03-06

## README

# schema2md

[![NPM version](https://img.shields.io/npm/v/schema2md.svg?style=flat)](https://npmjs.com/package/schema2md) [![NPM downloads](https://img.shields.io/npm/dm/schema2md.svg?style=flat)](https://npmjs.com/package/schema2md) ![Node.js CI](https://github.com/rich-lab/schema2md/workflows/Node.js%20CI/badge.svg) [![codecov](https://codecov.io/gh/rich-lab/schema2md/branch/master/graph/badge.svg)](https://codecov.io/gh/rich-lab/schema2md)

## Install

```bash
tnpm install schema2md --save
```

## Example

- `Input`: 

```json
{
  "title": "foo.config.js",
  "description": "My Config File",
  "properties": {
    "type": {
      "description": "TYPE's description",
      "type": "string",
      "enum": [
        "foo",
        "bar"
      ]
    },
    "env": {
      "description": "ENV's description",
      "type": "string"
    }
  }
}
```

- `Output`:

```md
# foo.config.js
 
My Config File

## type

- Type: `"foo" | "bar"`
- Description: TYPE's description

## env

- Type: `string`
- Description: ENV's description"
```

## Usage

```js
const { transform } = require('schema2md')

transform({
  schemaPath: 'fixtures/simple.json',
  outputPath: 'docs/config/README.md',
})
```

## Using in VuePress

Here is seperate [VuePress plugin](https://github.com/vuepressjs/vuepress-plugin-schema2md) for you to use it at VuePress.

## API

### .transform()

- Type: `(options: ITransformOptions) => Promise<string>`
- Description: `Get markdown output by JSON Schema.`

Type of `ITransformOptions` is as follows:

```typescript
interface ITransformOptions {
  /**
   * Current working directory, used to calcaulate absolute path for "schemaPath"
   * and "outputPath" with relative path, defaults to `process.cwd()`.
   */
  cwd?: string;
  /**
   * A relative path or an absolute path to a JSON Schema file. 
   */
  schemaPath: string;
  /**
   * A relative path or an absolute path to a output markdown file.
   */
  outputPath: string;
  /**
   * Whether to write output content to "outputPath".
   */
  write: boolean;
  /**
   * Current locale.
   */
  locale: string;
  /**
   * Specify a markdown file to be merged into the generated markdown.
   */
  schemaMarkdown: string;
  /**
   * Frontmatter content.
   */
  frontmatter: string;
  /**
   * Content at the below of h1.
   */
  heading: string;
  
}
```

### .batchTransform()

- Type: `(options: IBatchTransformOptions) => Promise<string[]>`
- Description: `Get markdown output by JSON Schema.`

Type of `IBatchTransformOptions` is as follows:

```typescript
interface IBatchTransformOptions {
  /**
   * Global "cwd".
   */
  cwd: string;
  /**
   * Global "cwd".
   */
  locale: string;
  /**
   * Global "write".
   */
  write: string;
  /**
   * Meta transform config.
   */
  configs: ITransformOptions[];
}
```

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D


## Author

**schema2md** © [ULIVZ](https://github.com/ulivz), Released under the [MIT](./LICENSE) License.<br>


> [github.com/ulivz](https://github.com/ulivz) · GitHub [@ULIVZ](https://github.com/ulivz) · Twitter [@_ulivz](https://twitter.com/_ulivz)

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