Skip to content

Commit 0da7f44

Browse files
committed
readme
1 parent c302333 commit 0da7f44

File tree

2 files changed

+146
-1
lines changed

2 files changed

+146
-1
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/Lucas-C/pre-commit-hooks-nodejs
3+
rev: v1.1.2
4+
hooks:
5+
- id: markdown-toc
6+
stages: [ pre-commit ]
7+
files:
8+
(?x)^(
9+
README.md$|
10+
)$

README.md

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,141 @@
1-
# n8n-openapi-node
1+
# @devlikeapro/n8n-openapi-node
22

33
Turn Your **OpenAPI** (**Swagger**) spec into a **n8n node**!
44

55
![n8n logo](n8n.png)
66
![openapi logo](openapi.png)
7+
8+
<!-- toc -->
9+
10+
- [Installation](#installation)
11+
- [Usage](#usage)
12+
* [Overview](#overview)
13+
* [Customization](#customization)
14+
+ [Resource](#resource)
15+
+ [Operation](#operation)
16+
+ [Fields](#fields)
17+
- [Use Cases](#use-cases)
18+
- [FAQ](#faq)
19+
* [I have only OpenAPI v2 spec, what can I do?](#i-have-only-openapi-v2-spec-what-can-i-do)
20+
* [I have openapi.yaml spec, what can I do?](#i-have-openapiyaml-spec-what-can-i-do)
21+
* [How to set up credentials from OpenAPI v3 spec?](#how-to-set-up-credentials-from-openapi-v3-spec)
22+
* [Why it doesn't work with my OpenAPI spec?](#why-it-doesnt-work-with-my-openapi-spec)
23+
24+
<!-- tocstop -->
25+
26+
# Installation
27+
28+
Add `@devlikeapro/n8n-openapi-node` as dependency
29+
30+
```bash
31+
npm install @devlikeapro/n8n-openapi-node
32+
# OR
33+
pnpm add @devlikeapro/n8n-openapi-node
34+
# OR
35+
yarn add @devlikeapro/n8n-openapi-node
36+
```
37+
38+
# Usage
39+
40+
Add your `openapi.json` to `src/{NodeName}` folder
41+
(use **OpenAPI v3** and **json**, see [FAQ](#faq) if you don't have it)
42+
43+
Get your `Node.properties` from OpenAPI v3 spec:
44+
45+
```typescript
46+
import {INodeType, INodeTypeDescription} from 'n8n-workflow';
47+
import {N8NPropertiesBuilder, N8NPropertiesBuilderConfig} from '@devlikeapro/n8n-openapi-node';
48+
import * as doc from './openapi.json'; // <=== Your OpenAPI v3 spec
49+
50+
const config: N8NPropertiesBuilderConfig = {}
51+
const parser = new N8NPropertiesBuilder(doc, config);
52+
const properties = parser.build()
53+
54+
export class Petstore implements INodeType {
55+
description: INodeTypeDescription = {
56+
displayName: 'Petstore',
57+
name: 'petstore',
58+
icon: 'file:petstore.svg',
59+
group: ['transform'],
60+
version: 1,
61+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
62+
description: 'Interact with Petstore API',
63+
defaults: {
64+
name: 'Petstore',
65+
},
66+
inputs: ['main'],
67+
outputs: ['main'],
68+
credentials: [
69+
{
70+
name: 'petstoreApi',
71+
required: false,
72+
},
73+
],
74+
requestDefaults: {
75+
headers: {
76+
Accept: 'application/json',
77+
'Content-Type': 'application/json',
78+
},
79+
baseURL: '={{$credentials.url}}',
80+
},
81+
properties: properties, // <==== HERE
82+
};
83+
}
84+
```
85+
86+
## Overview
87+
88+
tbd
89+
90+
## Customization
91+
92+
### Resource
93+
94+
tbd
95+
96+
### Operation
97+
98+
tbd
99+
100+
### Fields
101+
102+
tbd
103+
104+
# Use Cases
105+
106+
Here's n8n community nodes generated from OpenAPI specifications you can use for reference:
107+
108+
- [@devlikeapro/n8n-nodes-petstore](https://github.com/devlikeapro/n8n-nodes-petstore) - Petstore example generated from
109+
[Petstore openapi.json](https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/petstore.yaml)
110+
- [@devlikeapro/n8n-nodes-chatwoot](https://github.com/devlikeapro/n8n-nodes-chatwoot) - ChatWoot n8n community node
111+
from
112+
[https://www.chatwoot.com/developers/api/](https://www.chatwoot.com/developers/api/). Defines credentials as well (
113+
manually)
114+
- [@devlikeapro/n8n-nodes-waha](https://github.com/devlikeapro/n8n-nodes-waha) - **WAHA** - Self-hosted **WhatsApp HTTP
115+
API** you can run in a click!
116+
117+
# FAQ
118+
119+
## I have only OpenAPI v2 spec, what can I do?
120+
121+
Paste your OpenAPI 2.0 definition into https://editor.swagger.io and select **Edit > Convert to OpenAPI 3** from the
122+
menu.
123+
124+
https://stackoverflow.com/a/59749691
125+
126+
## I have openapi.yaml spec, what can I do?
127+
128+
Paste your yaml spec to https://editor.swagger.io and select **File > Save as JSON** from the menu.
129+
130+
## How to set up credentials from OpenAPI v3 spec?
131+
132+
Right now you need to define it manually.
133+
Check [ChatWoot node](https://github.com/devlikeapro/n8n-nodes-chatwoot)
134+
for an example.
135+
136+
## Why it doesn't work with my OpenAPI spec?
137+
138+
Open [a new issue](https://github.com/devlikeapro/n8n-openapi-node/issues) and please attach
139+
your openapi.json file and describe the problem (logs are helpful too).
140+
141+

0 commit comments

Comments
 (0)