# open-rpc-compiler

> Organize OpenRPC doc into files and directories and compile a complete OpenRPC document

Latest version **1.0.14** (published 2023-09-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install open-rpc-compiler
pnpm add open-rpc-compiler
yarn add open-rpc-compiler
bun add open-rpc-compiler
```

Provides the command `open-rpc-compile`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.14 |
| Published | 2023-09-14 |
| First published | 2023-09-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Evan Brooks |
| Maintainers | evan-brooks |
| Keywords | OpenRPC, open-rpc |

## Links

- npm: https://www.npmjs.com/package/open-rpc-compiler
- Repository: https://github.com/evan-brooks/open-rpc-compiler
- Homepage: https://github.com/evan-brooks/open-rpc-compiler#readme
- Issues: https://github.com/evan-brooks/open-rpc-compiler/issues
- npm.io page: https://npm.io/package/open-rpc-compiler

## Dependencies (2)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [path](https://npm.io/package/path.md) ^0.12.7

## Recent versions

- 1.0.14 (latest) — 2023-09-14
- 1.0.13 — 2023-09-14
- 1.0.12 — 2023-09-14
- 1.0.11 — 2023-09-14
- 1.0.10 — 2023-09-14
- 1.0.9 — 2023-09-14
- 1.0.8 — 2023-09-14
- 1.0.7 — 2023-09-14
- 1.0.6 — 2023-09-14
- 1.0.5 — 2023-09-14
- 1.0.4 — 2023-09-14
- 1.0.3 — 2023-09-14
- 1.0.2 — 2023-09-14
- 1.0.1 — 2023-09-14
- 1.0.0 — 2023-09-14

## README

# Overview

Organize OpenRPC doc into files and directories and compile a complete OpenRPC document.

## Directory structure

```
📂 openrpc/  
├── 📂 components/  
|   └─── 📂 schemas/  
│        └─── 📄 jointPosition.json  
│───📄 info.json  
└───📂 methods/  
    └── 📂 tags/  
         └── 📂 motion/  
              └── 📄 getJointPosition.json  
```

## Example Info file
**./info.json**
```
{
    "version": "0.1.0",
    "title": "Motion Controller API"
}
```

## Example Schema File
**./components/schemas/jointPosition.json**
```
{
    "type": "object",
    "properties": {
        "jointIndex": {
            "type": "integer"
        },
        "position": {
            "type": "integer"
        }
    }
}
```
## Example Method File
Note, by placing a method file inside a tags subdirectory, the name of the subdirectory will be assigned as a tag for the method.

**./methods/tags/motion/getJointPosition.json**
```
{
    "name": "getPosition",
    "description": "Get current joint positions",
    "params": [],
    "result": {
        "name": "jointPositions",
        "description": "updated joint positions",
        "schema": {
            "type": "array",
            "items": {
                "$ref": "#components/schemas/jointPosition"
            }
        }
    },
    "examples": [
        {
            "name": "getPosition",
            "params": [],
            "result": {
                "name": "jointPositions",
                "value": [
                    {
                        "jointIndex": 1,
                        "position": 393
                    },
                    {
                        "jointIndex": 5,
                        "position": 1829
                    }
                ]
            }
        }
    ]
}
```

## Install
```
npm install open-rpc-compiler --no-save
```

## Compile into a single openrpc.json document
```
open-rpc-compile > openrpc.json
```

## Example Output
```
{
  "openrpc": "1.2.4",
  "info": {
    "version": "0.1.0",
    "title": "Motion Controller API"
  },
  "methods": [
    {
      "name": "getPosition",
      "description": "Get current joint positions",
      "params": [],
      "result": {
        "name": "jointPositions",
        "description": "updated joint positions",
        "schema": {
          "type": "array",
          "items": {
            "$ref": "#components/schemas/jointPosition"
          }
        }
      },
      "examples": [
        {
          "name": "getPosition",
          "params": [],
          "result": {
            "name": "jointPositions",
            "value": [
              {
                "jointIndex": 1,
                "position": 393
              },
              {
                "jointIndex": 5,
                "position": 1829
              }
            ]
          }
        }
      ],
      "tags": [
        {
          "name": "motion"
        }
      ]
    },
  ],
  "components": {
    "schemas": {
      "jointPosition": {
        "type": "object",
        "properties": {
          "jointIndex": {
            "type": "integer"
          },
          "position": {
            "type": "integer"
          }
        }
      }
    }
  }
}

```

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