# yang-swagger

> YANG model-driven swagger/openapi transform

Latest version **2.3.4** (published 2021-01-30) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install yang-swagger
pnpm add yang-swagger
yarn add yang-swagger
bun add yang-swagger
```

Provides the command `yang-swagger`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.4 |
| Published | 2021-01-30 |
| First published | 2016-10-06 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 197.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Peter Lee |
| Maintainers | corenova |
| Keywords | yang, transform, swagger, openapi, yang2swagger, model, schema, adaptive, validate, object, rfc6020 |

## Links

- npm: https://www.npmjs.com/package/yang-swagger
- Repository: https://github.com/corenova/yang-swagger
- npm.io page: https://npm.io/package/yang-swagger

## Dependencies (6)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [config](https://npm.io/package/config.md) ^3.0.1
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.13.1
- [yang-js](https://npm.io/package/yang-js.md) ^0.24.63
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [traverse](https://npm.io/package/traverse.md) ^0.6.6

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 2.3.4 (latest) — 2021-01-30
- 2.3.3 — 2020-10-07
- 2.3.2 — 2020-10-06
- 2.3.1 — 2020-07-23
- 2.3.0 — 2020-07-11
- 2.1.1 — 2019-08-09
- 2.1.0 — 2019-08-03
- 2.0.1 — 2019-01-29
- 2.0.0 — 2019-01-29
- 1.2.5 — 2018-05-19
- 1.2.4 — 2018-05-17
- 1.2.3 — 2018-03-01
- 1.2.2 — 2016-11-11
- 1.2.1 — 2016-10-22
- 1.2.0 — 2016-10-22
- … 13 more at https://npm.io/package/yang-swagger/versions

## README

# yang-swagger

YANG model-driven swagger/openapi transform

  [![NPM Version][npm-image]][npm-url]
  [![NPM Downloads][downloads-image]][downloads-url]

## Installation

```bash
$ npm install -g yang-swagger
```

The preferred installation is *global* for easy access to the
`yang-swagger` utility but can also be used as a dependency module to
help generate swagger/openapi specification as part of your project.

> NOTE: Currently, Swagger/OpenAPI 2.0 Specification does **NOT**
> support JSON-schema `anyOf` and `oneOf` directives, which means
> that we cannot properly treat YANG `choice/case` statements during
> conversion. As a work-around, the current transform will simply
> serialize all configuration nodes from the `choice/case` sections
> into a flat list of properties.

## Quick Start

```bash
$ yang-swagger -f yaml -o swagger.yaml yang-openapi
```

The above example will import the `yang-openapi` YANG module and
transform into swagger specification YAML file.

```
  Usage: yang-swagger [options] modules...

  Options:
      -c, --config <filename>  Use <filename> to retrieve configuration data (default: uses 'config' directory)
      -f, --format <string>    Convert to YAML or JSON (default: json)
      -o, --output <filename>  Write to <filename> if specified, otherwise to console
```

Using the `--config` option will allow you to specify where to find
the configuration data for the `yang-openapi` YANG module. By default,
it will check the `config` directory but you can specify any arbitrary
file location for specifying the `yang-openapi:info` configuration
data.

You can also use it as a library module:

```coffeescript
swag = require("yang-swagger").eval {
  'yang-openapi:info':
    title: "my-api"
	description: "describe purpose"
	version: "1.0"
	contact:
	  name: "your name"
	  url: "http://some/website"
	  email: "your email"
	license:
	  name: "Apache-2.0"
}
swag.in('transform')
  .invoke modules: [ 'yang-openapi' ]
  .then (output) ->
    console.log "do something with <output.spec>"
```

For more information on programmatic usage, be sure to take a look at
the References listed below.

## References

- [Apiary Documentation](http://docs.yangswagger.apiary.io)
- [Working with Multiple Schemas](http://github.com/corenova/yang-js/blob/master/TUTORIAL.md#working-with-multiple-schemas)
- [Expressing Interfaces](http://github.com/corenova/yang-express)
- [Using YANG with JavaScript](http://github.com/corenova/yang-js)

## License
  [Apache 2.0](LICENSE)

This software is brought to you by
[Corenova Technologies](http://www.corenova.com). We'd love to hear
your feedback.  Please feel free to reach me at <peter@corenova.com>
anytime with questions, suggestions, etc.

[npm-image]: https://img.shields.io/npm/v/yang-swagger.svg
[npm-url]: https://npmjs.org/package/yang-swagger
[downloads-image]: https://img.shields.io/npm/dt/yang-swagger.svg
[downloads-url]: https://npmjs.org/package/yang-swagger

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