Skip to content

Commit e3facbc

Browse files
committed
readme
1 parent c24b49a commit e3facbc

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ export class CustomResourceParser {
179179
}
180180
```
181181

182-
Alternatively, you can use `DefaultResourceParser` and override only the methods you need:
182+
Alternatively, you can use `DefaultResourceParser` and override only the methods you need.
183+
The default implementation you can find in [src/ResourceParser.ts](src/ResourceParser.ts)
183184

184185
```typescript
185186
import {OpenAPIV3} from 'openapi-types';
@@ -208,7 +209,7 @@ const parser = new N8NPropertiesBuilder(doc, config);
208209
const properties = parser.build()
209210
```
210211

211-
The default implementation you can find in [src/ResourceParser.ts](src/ResourceParser.ts)
212+
Find real example in [@devlikeapro/n8n-nodes-waha](https://github.com/devlikeapro/n8n-nodes-waha) repository.
212213

213214
## Operation
214215

@@ -247,7 +248,8 @@ export class CustomOperationParser implements IOperationParser {
247248
}
248249
```
249250

250-
Or you can use `DefaultOperationParser` and override only the methods you need:
251+
Alternatively, you can use `DefaultOperationParser` and override only the methods you need.
252+
The default implementation you can find in [src/OperationParser.ts](src/OperationParser.ts)
251253

252254
```typescript
253255
import {DefaultOperationParser} from '@devlikeapro/n8n-openapi-node';
@@ -278,9 +280,47 @@ const parser = new N8NPropertiesBuilder(doc, config);
278280
const properties = parser.build()
279281
```
280282

283+
Find real example in [@devlikeapro/n8n-nodes-waha](https://github.com/devlikeapro/n8n-nodes-waha) repository.
284+
281285
## Fields
282286

283-
tbd
287+
You can override some values for fields at the end, when full `properties` are ready.
288+
289+
Here's example how you can override `session` field value (which has `'default'` string default value) to more n8n
290+
suitable `=${$json.session}}`:
291+
292+
```typescript
293+
import {Override} from '@devlikeapro/n8n-openapi-node';
294+
295+
export const customDefaults: Override[] = [
296+
{
297+
// Find field by fields matching
298+
find: {
299+
name: 'session',
300+
required: true,
301+
type: 'string',
302+
},
303+
// Replace 'default' field value
304+
replace: {
305+
default: '={{ $json.session }}',
306+
},
307+
},
308+
];
309+
```
310+
311+
Then you use it in `N8NPropertiesBuilder`:
312+
313+
```typescript
314+
315+
import {N8NPropertiesBuilder, N8NPropertiesBuilderConfig} from '@devlikeapro/n8n-openapi-node';
316+
import * as doc from './openapi.json';
317+
import {customDefaults} from './customDefaults';
318+
319+
const parser = new N8NPropertiesBuilder(doc);
320+
const properties = parser.build(customDefaults);
321+
```
322+
323+
Find real example in [@devlikeapro/n8n-nodes-waha](https://github.com/devlikeapro/n8n-nodes-waha) repository.
284324

285325
# Use Cases
286326

0 commit comments

Comments
 (0)