You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Prompt for Generating n8n SearchApi Engines from OpenAPI Specs
1
+
# Generate n8n SearchApi Engine Command
2
2
3
+
## Overview
3
4
You are an expert n8n node developer tasked with generating SearchApi engine files from OpenAPI specifications. Your goal is to create TypeScript files that properly integrate with the n8n SearchApi node framework.
4
5
5
-
## Input Requirements
6
-
You will be provided with:
7
-
1. An OpenAPI 3.0 specification (YAML or JSON format)
8
-
2. The target engine name/endpoint to generate
6
+
**⚠️ CRITICAL REQUIREMENT**: You MUST run lint checks on the generated file before completing this task. The file MUST pass all lint checks.
9
7
10
-
## Output Requirements
11
-
Generate a TypeScript file following this exact structure:
8
+
---
12
9
10
+
## Task Workflow
11
+
12
+
### 1. Input Analysis
13
+
You will receive:
14
+
- An OpenAPI 3.0 specification (YAML or JSON format)
15
+
- The target engine name/endpoint to generate
16
+
- Look for .yaml files to get the openapi specs for the engine
17
+
18
+
### 2. Behavior Rules
19
+
-**If engine doesn't exist**: Create it from scratch
20
+
-**If engine already exists**: Act as a reviewer and ensure the code follows all guidelines
21
+
22
+
### 3. Final Validation (MANDATORY)
23
+
1. Run `pnpm lint` to check for any linting errors
24
+
2. If there are errors, run `pnpm lintfix` to automatically fix what can be fixed
25
+
3. Manually fix any remaining errors that couldn't be auto-fixed
26
+
4. Ensure the file passes all lint checks before completing the task
27
+
28
+
**DO NOT stop until the engine file passes all lint checks.**
required: false, // true if the value is required, false if not
65
+
required: false, // true if the value is required, false if not
70
66
default: 'default_value',
71
67
description: 'Clear, helpful description from OpenAPI',
72
68
options: [], // For non-options types, empty array
@@ -81,46 +77,69 @@ Each parameter must follow this structure:
81
77
}
82
78
```
83
79
84
-
### 4. Options Array Rules
80
+
---
81
+
82
+
## Parameter Mapping Rules
83
+
84
+
### Type Mappings
85
+
| OpenAPI Type | n8n Type | Notes |
86
+
|--------------|----------|-------|
87
+
|`string`|`'string'`| Basic text input |
88
+
|`integer`|`'string'`| For API compatibility |
89
+
|`number`|`'string'`| For API compatibility |
90
+
|`boolean`|`'boolean'`| Checkbox input |
91
+
|`string` with `enum`|`'options'`| Dropdown selection |
92
+
|`array`|`'multiOptions'`| If applicable |
85
93
94
+
### Display Name Conventions
95
+
-**Priority**: Use OpenAPI `x-display-name` if available
96
+
-**Fallback**: Convert parameter names to human-readable format
97
+
98
+
Common conversions:
99
+
-`q` → `'Query'`
100
+
-`api_key` → `'API Key'`
101
+
-`time_period` → `'Time Period'`
102
+
-`num` → `'Results Per Page'`
103
+
-`safe_search` → `'Safe Search'`
104
+
-`video_id` → `'Video ID'`
105
+
- Always use proper capitalization and spacing
86
106
87
-
- For enum parameters, create options with proper capitalization:
107
+
### Engine Naming Rules
108
+
-**Value**: Use snake_case (e.g., `google_search`, `bing_news`, `youtube_transcripts`)
109
+
-**Display Name**: Use Title Case (e.g., `Google Search`, `Bing News`, `YouTube Transcripts`)
110
+
- Must match the OpenAPI operationId or endpoint purpose
111
+
112
+
---
113
+
114
+
## Special Parameter Handling
115
+
116
+
### Excluded Parameters
117
+
Skip these parameters (handled by node framework):
118
+
-`api_key`
119
+
-`engine`
120
+
121
+
### Required vs Optional Parameters
122
+
- Mark truly required parameters with `required: true`
123
+
- Use reasonable defaults for optional parameters
124
+
- Optional parameters should have sensible `default` values
125
+
126
+
### Options/Enum Parameters
88
127
```typescript
89
128
options: [
90
129
{ name: 'Desktop', value: 'desktop' },
91
130
{ name: 'Mobile', value: 'mobile' },
92
131
{ name: 'Tablet', value: 'tablet' },
93
132
]
94
133
```
95
-
- The options must be correctly sorted in alphabetic order
96
-
- And the names must always be human readable
134
+
Requirements:
135
+
- Options must be sorted alphabetically by name
136
+
- Names must be human-readable with proper capitalization
137
+
- Values should match the API's expected format
97
138
98
-
### 5. Required Parameters
99
-
- Skip `api_key` and `engine` parameters (handled by node framework)
100
-
- Mark truly required parameters appropriately
101
-
- Use reasonable defaults for optional parameters
139
+
### Parameter Grouping
140
+
Use collections to group related parameters:
102
141
103
-
### 6. Description Guidelines
104
-
- Use the OpenAPI description as-is but ensure it's clear and helpful
105
-
- Add context about parameter usage when beneficial
106
-
- Include examples or format specifications when provided in OpenAPI
107
-
- Maintain markdown formatting for better readability
108
-
109
-
### 7. Special Parameter Handling
110
-
-**Location/Geographic**: Use appropriate defaults and clear descriptions
111
-
-**Language/Locale**: Provide comprehensive option lists with proper names
112
-
-**Pagination**: Default to reasonable values (`page: '1'`, `num: '10'`)
113
-
-**Date/Time**: Include format specifications and validation hints
114
-
-**Enum Arrays**: Convert to proper option arrays with human-readable names
115
-
116
-
### 8. Property Grouping
117
-
-**Collection Type**: Use `'collection'` type to group optional parameters that users can choose to add
118
-
-**Fixed Collection Type**: Use `'fixedCollection'` type to group semantically related parameters
119
-
- Group related parameters by category (e.g., "Search Options", "Pagination", "Location Settings", "Date Filters")
120
-
- Use meaningful group names that describe the parameter category
121
-
- Parameters within the same logical group should use the same `displayOptions` conditions
122
-
123
-
Example collection structure:
142
+
#### Collection Type (for optional parameter groups)
124
143
```typescript
125
144
{
126
145
displayName: 'Search Options',
@@ -135,30 +154,82 @@ Example collection structure:
135
154
}
136
155
```
137
156
138
-
### 9. Engine Name Conventions
139
-
- Use snake_case for the engine value (e.g., `google_search`, `bing_news`)
140
-
- Use Title Case for the display name (e.g., `Google Search`, `Bing News`)
141
-
- Ensure the engine name matches the OpenAPI operationId or endpoint purpose
157
+
#### Fixed Collection Type (for required parameter groups)
158
+
```typescript
159
+
{
160
+
displayName: 'Required Settings',
161
+
name: 'requiredSettings',
162
+
type: 'fixedCollection',
163
+
default: {},
164
+
options: [
165
+
// Related parameters go here
166
+
],
167
+
displayOptions,
168
+
}
169
+
```
170
+
171
+
Group categories examples:
172
+
- "Search Options"
173
+
- "Pagination"
174
+
- "Location Settings"
175
+
- "Date Filters"
176
+
- "Transcript Options"
177
+
- "Advanced Settings"
178
+
179
+
---
180
+
181
+
## Content Guidelines
182
+
183
+
### Descriptions
184
+
- Use the OpenAPI description as-is when clear and helpful
185
+
- Add context about parameter usage when beneficial
186
+
- Include format specifications when provided
187
+
- Maintain markdown formatting for readability
188
+
- End descriptions with periods for consistency
189
+
190
+
### Default Values
191
+
Common defaults by type:
192
+
- Pagination: `page: '1'`, `num: '10'`
193
+
- Language: `'en'`
194
+
- Boolean flags: `false`
195
+
- Location: Appropriate regional defaults
196
+
197
+
---
142
198
143
199
## Quality Checklist
144
-
Before finalizing, ensure:
145
-
-[ ] All parameter names are human-readable
146
-
-[ ] All enum options are properly capitalized
147
-
-[ ] Default values are sensible and useful
148
-
-[ ] Descriptions are clear and informative
200
+
201
+
Before finalizing, verify:
202
+
203
+
### Code Quality
149
204
-[ ] TypeScript syntax is correct
150
205
-[ ] Import statements are included
151
206
-[ ] Export structure matches the pattern
152
-
-[ ] Required parameters are properly handled
207
+
-[ ] No TypeScript errors
208
+
209
+
### Parameter Quality
210
+
-[ ] All parameter names are human-readable
211
+
-[ ] All enum options are properly capitalized and sorted
212
+
-[ ] Default values are sensible and useful
213
+
-[ ] Descriptions are clear and informative
214
+
-[ ] Required parameters are properly marked
153
215
-[ ] Optional parameters have appropriate defaults
154
-
-[ ] No API keys or sensitive parameters are exposed
155
-
-[ ] Related parameters are grouped using collection or fixedCollection types
216
+
217
+
### Structure Quality
218
+
-[ ] Related parameters are grouped using collections
156
219
-[ ] Group names are meaningful and descriptive
157
-
-[ ] Parameters within the same group have consistent displayOptions
158
-
-[ ] Run "pnpm lintfix" and fix all errors it does not fix automatically
220
+
-[ ] Parameters within groups have consistent displayOptions
221
+
-[ ] No API keys or sensitive parameters are exposed
222
+
223
+
### Linting (MANDATORY)
224
+
-[ ] Run `pnpm lint` - no errors
225
+
-[ ] Run `pnpm lintfix` if needed
226
+
-[ ] All lint errors resolved
227
+
228
+
---
159
229
160
230
## Example Transformation
161
-
Given an OpenAPI parameter like:
231
+
232
+
### OpenAPI Input:
162
233
```yaml
163
234
device:
164
235
name: device
@@ -172,7 +243,7 @@ device:
172
243
x-display-name: "Device Type"
173
244
```
174
245
175
-
Transform to:
246
+
### n8n Output:
176
247
```typescript
177
248
{
178
249
displayName: 'Device Type',
@@ -196,12 +267,26 @@ Transform to:
196
267
}
197
268
```
198
269
270
+
---
271
+
272
+
## Completion Criteria
273
+
274
+
The task is **ONLY** complete when:
275
+
276
+
1. ✅ The engine file has been generated or reviewed
277
+
2. ✅ `pnpm lint` has been run on the file
278
+
3. ✅ All linting errors have been fixed
279
+
4. ✅ The file passes all lint checks without errors
280
+
281
+
**🛑 STOP**: Do NOT mark this task as complete until the lint check passes!
282
+
283
+
---
284
+
199
285
## Additional Notes
200
-
- Always prioritize user experience with clear, intuitive parameter names
286
+
287
+
- Prioritize user experience with clear, intuitive parameter names
201
288
- Follow n8n's established patterns for consistency
202
289
- Test the generated code for TypeScript compatibility
203
290
- Consider parameter interdependencies and validation
204
291
- Ensure the generated engine integrates seamlessly with the SearchApi node framework
205
-
- Look for .yaml files to get the openapi specs for the engine
206
-
207
-
Generate the complete TypeScript engine file following these guidelines exactly.
292
+
- To save tokens, when reading the yaml files, you can read everything that is inside the "parameters" key, and everything that is inside the "request" key. As it is the only thing that is needed to generate the engine.
0 commit comments