# oas-wizard

> OpenAPI Spec generator using a (yaml) resource sample as starting point

Latest version **2.0.6** (published 2020-04-10) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install oas-wizard
pnpm add oas-wizard
yarn add oas-wizard
bun add oas-wizard
```

Provides the command `oas-wizard`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2020-04-10 |
| First published | 2020-02-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 31.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | isa-tecnico |

## Links

- npm: https://www.npmjs.com/package/oas-wizard
- Repository: https://github.com/isa-group/oas-wizard
- Homepage: https://github.com/isa-group/oas-wizard#readme
- Issues: https://github.com/isa-group/oas-wizard/issues
- npm.io page: https://npm.io/package/oas-wizard

## Dependencies (5)

- [snyk](https://npm.io/package/snyk.md) ^1.303.0
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.13.1
- [mustache](https://npm.io/package/mustache.md) ^4.0.0
- [commander](https://npm.io/package/commander.md) ^4.1.1
- [json-schema-generator](https://npm.io/package/json-schema-generator.md) ^2.0.6

## Recent versions

- 2.0.6 (latest) — 2020-04-10
- 2.0.5 — 2020-04-10
- 2.0.4 — 2020-03-22
- 2.0.3 — 2020-03-22
- 2.0.2 — 2020-03-22
- 2.0.1 — 2020-02-20
- 2.0.0 — 2020-02-20

## README

[![Build Status](https://travis-ci.org/isa-group/oas-wizard.svg?branch=master)](https://travis-ci.org/isa-group/oas-wizard) 
[![dependencies Status](https://david-dm.org/isa-group/oas-wizard.svg)](https://david-dm.org/isa-group/oas-wizard)
[![codecov](https://codecov.io/gh/isa-group/oas-wizard/branch/master/graph/badge.svg)](https://codecov.io/gh/isa-group/oas-wizard)
[![Known Vulnerabilities](https://snyk.io/test/github/isa-group/oas-wizard/badge.svg)](https://snyk.io/test/github/isa-group/oas-wizard)
[![Greenkeeper badge](https://badges.greenkeeper.io/isa-group/oas-wizard.svg)](https://greenkeeper.io/)
[![Maintainability](https://api.codeclimate.com/v1/badges/826c4f28b9bc9e33e9fe/maintainability)](https://codeclimate.com/github/isa-group/oas-wizard/maintainability) 

[![NPM](https://nodei.co/npm/oas-wizard.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/oas-wizard/)

This tool, *oas-wizard*, is a simple OpenAPI Spec generator using a *.yaml* resource sample as starting point.

## Usage
Install oas-wizard globally:
```bash
npm install -g oas-wizard
```

The command sintax is the following:
```bash
oas-wizard <OpenAPISpecFile.yaml> <ResourceSampleFile.yaml> <ResourceName> <IdPropertyName>
```

You can also run it without installing with *npx*: 
```bash
npx oas-wizard <OpenAPISpecFile.yaml> <ResourceSampleFile.yaml> <ResourceName> <IdPropertyName>
```

## Thirty seconds tutorial - From zero to REST server!
In this tutorial, you will be able to generate a RESTful API server in just three commands (Node.js required). Let's start:

1. Clone our tutorial folder to obtain an example input file for the tool:

   ```bash
   npx degit https://github.com/isa-group/oas-wizard/tutorial
   ```

2. Use this tool to generate the openAPI specification with one of the tutorial resource sample files downloaded:

   ```bash
   npx oas-wizard pet-oas.yaml petSample.yaml pet name
   ```

3. Use [oas-generator](https://github.com/isa-group/oas-generator), to generate the server from the OAS file generated:

   ```bash
   npx oas-generator pet-oas.yaml -n petServer
   ```

Now to run the server just access the `petServer` folder and run `npm start`. Once the dependencies are installed access `localhost:8080/docs` to see the SwaggerUI API documentation.  

## Five minutes tutorial - Create your own RESTful API
This tool is expected to be used in combination with others; as an example we propose the following lifecycle:
1. Think about an example of resource and write it in yaml (e.g. `contactSample.yaml`)
   ```yml
   nick: Peter
   phone: 123456
   email: "peter@peter.org"
   ```
2. Use *oas-wizard* to generate the OAS spec (e.g. `contact-oas.yaml`) based on the sample file you created using with a resource name and the id property:
   ```bash
   oas-wizard contact-oas.yaml contactSample.yaml contact nick
   ```

3. Generate a server scaffolding with  [oas-generator](https://www.npmjs.com/package/oas-generator) (using node v8 or up) 
   ```bash
   npm install -g oas-generator
   oas-generator contact-oas.yaml -n contactServer
   cd contactServer
   npm start
   ```
You should have a fully working API server mockup up and running in port 8080. Check the SwaggerUI API documentation at `localhost:8080/docs`. 

Now it's your turn to implement the controllers for each operation (files `controllers/*Service.js`).

Enjoy your API!

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