Skip to content

Commit a3279d8

Browse files
mpywclaude
andcommitted
docs: add GitHub alerts to SCHEMA.md for better readability
- [!TIP]: Shortcuts and helpful hints - [!NOTE]: Specification clarifications - [!IMPORTANT]: Critical requirements - [!WARNING]: Potential pitfalls - [!CAUTION]: Path parameter precedence warning Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 944b18b commit a3279d8

1 file changed

Lines changed: 36 additions & 9 deletions

File tree

SCHEMA.md

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ global_helpers:
8484
| `js` | string | Inline JavaScript code |
8585
| `js_files` | string[] | Paths to JavaScript files (relative to config) |
8686

87+
> [!TIP]
8788
> **Shorthand:** `global_helpers: |` is equivalent to `global_helpers: { js: | }`
8889

8990
## CSV Config
@@ -107,7 +108,10 @@ The `value_parser` function receives `value` (string) and should return the pars
107108

108109
## Queries
109110

110-
Query endpoints for SELECT operations. Each query must have either `sql` OR [`mock`](#mock), not both.
111+
Query endpoints for SELECT operations.
112+
113+
> [!IMPORTANT]
114+
> Each query must have either `sql` OR [`mock`](#mock), not both.
111115

112116
```yaml
113117
queries:
@@ -138,6 +142,9 @@ queries:
138142
| `one` | Returns a single row as an object. Returns 404 if not found (or `null` to post with `handle_not_found: true`) |
139143
| `many` | Returns multiple rows as an array. Returns empty array `[]` if no rows found |
140144

145+
> [!TIP]
146+
> Use `handle_not_found: true` to handle not-found cases in post-transform (e.g., return a default object instead of 404).
147+
141148
### Query Method
142149

143150
| Value | Description |
@@ -150,7 +157,13 @@ queries:
150157

151158
## Mutations
152159

153-
Mutation endpoints for INSERT/UPDATE/DELETE operations. Each mutation (type: one/many) must have either `sql` OR [`mock`](#mock), not both. Type: none requires `sql`.
160+
Mutation endpoints for INSERT/UPDATE/DELETE operations.
161+
162+
> [!IMPORTANT]
163+
> Each mutation (type: one/many) must have either `sql` OR [`mock`](#mock), not both.
164+
165+
> [!WARNING]
166+
> `type: none` requires `sql` — mock is not supported.
154167

155168
```yaml
156169
mutations:
@@ -172,7 +185,6 @@ mutations:
172185
| `accepts` | string/array | `[json, form]` | [Accepted Content-Types](#accepts) |
173186
| `transform` | object | - | [Pre/post transforms](#transform) |
174187

175-
> Note: `type: none` requires `sql` - [mock](#mock) is not supported for type: none.
176188

177189
### Mutation Type
178190

@@ -193,7 +205,10 @@ mutations:
193205

194206
### MySQL-Specific Behavior
195207

196-
For MySQL, mutations use `Exec` instead of `Query` since MySQL does not support `RETURNING` clause. This makes `ctx.lastInsertId` and `ctx.rowsAffected` available in [post-transform](#post-transform):
208+
> [!WARNING]
209+
> MySQL does not support `RETURNING` clause. Use `ctx.lastInsertId` and `ctx.rowsAffected` in post-transform instead.
210+
211+
For MySQL, mutations use `Exec` instead of `Query`. This makes `ctx.lastInsertId` and `ctx.rowsAffected` available in [post-transform](#post-transform):
197212

198213
```yaml
199214
mutations:
@@ -210,6 +225,7 @@ mutations:
210225
| `ctx.lastInsertId` | Auto-increment ID from INSERT | `undefined` |
211226
| `ctx.rowsAffected` | Number of affected rows | `undefined` |
212227

228+
> [!TIP]
213229
> For PostgreSQL, SQLite, and SQL Server, use `RETURNING *` clause instead to get inserted data directly.
214230

215231
## Mock
@@ -220,7 +236,8 @@ Mock is specified at the [query](#queries)/[mutation](#mutations) level (same le
220236

221237
### Mock Sources
222238

223-
**Only one source type can be specified per mock.**
239+
> [!IMPORTANT]
240+
> Only one source type can be specified per mock.
224241

225242
#### Object Sources (type: one only)
226243

@@ -289,7 +306,10 @@ mock:
289306

290307
### Filter
291308

292-
The `filter` option allows filtering array data using JavaScript. For `type: one` with [array sources](#array-sources-type-many-or-type-one-with-filter), `filter` is **required** to select which row to return.
309+
The `filter` option allows filtering array data using JavaScript.
310+
311+
> [!IMPORTANT]
312+
> For `type: one` with [array sources](#array-sources-type-many-or-type-one-with-filter), `filter` is **required** to select which row to return.
293313

294314
**Filter variables:**
295315
- `row` (parameter): Current row being evaluated
@@ -433,6 +453,7 @@ post:
433453
return { items: output };
434454
```
435455

456+
> [!TIP]
436457
> **Shorthand:** `post: |` is equivalent to `post: { all: | }`
437458

438459
## Error Handling
@@ -446,6 +467,9 @@ pre: |
446467
}
447468
```
448469

470+
> [!NOTE]
471+
> If you throw without `status`, the default depends on the phase:
472+
449473
| Phase | Default Status |
450474
|-------|----------------|
451475
| [`pre`](#pre-transform) | 400 Bad Request |
@@ -467,7 +491,8 @@ queries:
467491
sql: SELECT * FROM posts WHERE user_id = :user_id
468492
```
469493

470-
**Priority:** Path parameters take precedence over query string and body parameters.
494+
> [!CAUTION]
495+
> Path parameters take precedence over query string and body parameters. If both exist, the path parameter wins.
471496

472497
```yaml
473498
# Request: GET /users/42?id=999
@@ -530,7 +555,8 @@ For common patterns, use `{param:*shorthand*}` syntax:
530555
sql: SELECT * FROM events WHERE id = :id
531556
```
532557

533-
The `*...*` syntax is unambiguous because `*` at the start of a regex is invalid.
558+
> [!NOTE]
559+
> The `*...*` syntax is unambiguous because `*` at the start of a regex is invalid.
534560

535561
## Named Placeholders
536562

@@ -562,4 +588,5 @@ accepts: form # Only application/x-www-form-urlencoded
562588
accepts: [json, form] # Both (default)
563589
```
564590

565-
Returns 415 Unsupported Media Type if the request Content-Type doesn't match.
591+
> [!WARNING]
592+
> Returns 415 Unsupported Media Type if the request Content-Type doesn't match.

0 commit comments

Comments
 (0)