# @github/rest-api-operations

A Node.js module that decorates [@github/openapi](https://npm.im/@github/openapi) schemas for rendering on [docs.github.com](https://docs.github.com/rest/reference).

## What it does

- Generates arrays of [Operation](lib/operation.js) objects from @github/openapi schemas
- Validates generated operations using a [JSON schema](lib/operation-schema.js)
- Renders operation markdown properties to HTML using [hubdown](https://ghub.io/hubdown):
  - descriptions
  - code samples
  - response payloads
  - parameter descriptions
  - body paramater descriptions
  - preview notices
- Adds `slug` properties to each operation for use as unique DOM ids using [github-slugger](https://ghub.io/github-slugger)
- Adds HTTP status messages to responses using [http-status-code](https://ghub.io/https-status-code)
- Matches internal nomenclature for GitHub product variants, e.g. `dotcom` and `2.20`

## Live Updates

This project uses [Dependabot](http://dependabot.com/) to keep dependencies up to date. Whenever a new version of the `@github/openapi` npm package is published it will automatically be updated in a new pull request, and the pull request will merge automatically if all checks are passing.

## Installation

```sh
npm install @github/rest-api-operations
```

## Usage

The npm module exports a single property `schemas` which is an object containing multiple versions of the GitHub REST API schema for api.github.com and all currently supported versions of GitHub Enterprise Server.

```js
const { schemas } = require('@github/rest-api-operations')

console.log(Object.keys(schemas))
// [
//   'dotcom',
//   '2.17',
//   '2.18',
//   '2.19',
//   '2.20'
// ]

console.log(schemas['2.20'])
// [
//   { Operation },
//   { Operation },
//   { Operation },
//   ...
// ]
```