# blueprint2schema

> Build a JSON Schema tree from an API Blueprint spec file. The tree is similar to a subset of an [OpenAPI](https://github.com/OAI/OpenAPI-Specification) spec file. The `include` directive of [Aglio](https://github.com/danielgtaylor/aglio) is supported.

Latest version **0.2.2** (published 2017-06-20) · MIT license · 0 weekly downloads

## Install

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

Provides the command `blueprint2schema`.

## 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.2 |
| Published | 2017-06-20 |
| First published | 2017-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mika Kunnas |
| Maintainers | mikunnas |

## Links

- npm: https://www.npmjs.com/package/blueprint2schema
- npm.io page: https://npm.io/package/blueprint2schema

## Dependencies (4)

- [fury](https://npm.io/package/fury.md) ^2.3.0
- [commander](https://npm.io/package/commander.md) ^2.9.0
- [apib-include-directive](https://npm.io/package/apib-include-directive.md) ^0.1.0
- [fury-adapter-apib-parser](https://npm.io/package/fury-adapter-apib-parser.md) ^0.7.0

## Recent versions

- 0.2.2 (latest) — 2017-06-20
- 0.2.1 — 2017-06-20
- 0.2.0 — 2017-06-20
- 0.1.1 — 2017-04-12
- 0.1.0 — 2017-04-12

## README

# blueprint2schema
Build a JSON Schema tree from an API Blueprint spec file. The tree is similar to a subset of an [OpenAPI](https://github.com/OAI/OpenAPI-Specification) spec file. The `include` directive of [Aglio](https://github.com/danielgtaylor/aglio) is supported.

Note that the underlying [API Blueprint parser](https://github.com/apiaryio/snowcrash) doesn't support indentation with tabs. This tool supports conversion from tabs to spaces (Linux and OSX only using `expand`) before the parsing phase.

# Installation
`npm install -g blueprint2schema`

# Usage

Given the following API Blueprint file called `cat.apib`

```
FORMAT: 1A

## Cat [/cat]

### Create cat [POST]
Post a cat.

+ Request (application/json)

    + Attributes (Cat)

+ Response 201 (application/json)

    + Attributes (Cat)
        + id: 1 (number, required)

# Data Structures

## Cat

+ name: Catty (string, required)
```

the following will be ouputted to `stdout`:

```shell
$ blueprint2schema -i cat.apib -p
{
  "/cat": {
    "post": {
      "body": {
        "schema": {
          "$schema": "http://json-schema.org/draft-04/schema#",
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            }
          },
          "required": [
            "name"
          ]
        }
      },
      "responses": {
        "201": {
          "body": {
            "schema": {
              "$schema": "http://json-schema.org/draft-04/schema#",
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "id": {
                  "type": "number"
                }
              },
              "required": [
                "name",
                "id"
              ]
            }
          }
        }
      }
    }
  }
}
```

If option `-i` is not given, the input file is read from `stdin`.


## Options

```shell
$ blueprint2schema -h

  Usage: blueprint2schema [options]

  Options:

    -h, --help              output usage information
    -i, --input [filepath]  API Blueprint file
    -t, --expand-tabs       Expand tabs to spaces (Linux and OSX only)
    -p, --pretty-print      Enable pretty printing
	--requests-only         Include schemas only for requests
```

# License

MIT

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