Skip to content

Commit 60517be

Browse files
burmeciaCopilot
andauthored
docs(openapi): update wasm module checksum and improve docs (supabase#572)
* docs(openapi): update wasm module checksum and improve docs * Update docs/catalog/openapi.md Co-authored-by: Copilot <[email protected]> * fix error in docs --------- Co-authored-by: Copilot <[email protected]>
1 parent a3990fd commit 60517be

2 files changed

Lines changed: 32 additions & 35 deletions

File tree

docs/catalog/openapi.md

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This wrapper allows you to query any REST API endpoint as a PostgreSQL foreign t
1818

1919
| Version | Wasm Package URL | Checksum | Required Wrappers Version |
2020
| ------- | ---------------- | -------- | ------------------------- |
21-
| 0.1.4 | `https://github.com/supabase/wrappers/releases/download/wasm_openapi_fdw_v0.1.4/openapi_fdw.wasm` | `TBD` | >=0.5.0 |
21+
| 0.1.4 | `https://github.com/supabase/wrappers/releases/download/wasm_openapi_fdw_v0.1.4/openapi_fdw.wasm` | `dd434f8565b060b181d1e69e1e4d5c8b9c3ac5ca444056d3c2fb939038d308fe` | >=0.5.0 |
2222

2323
## Preparation
2424

@@ -115,7 +115,7 @@ We need to provide Postgres with the credentials to access the API and any addit
115115
We recommend creating a schema to hold all the foreign tables:
116116

117117
```sql
118-
create schema if not exists api;
118+
create schema if not exists openapi;
119119
```
120120

121121
## Creating Foreign Tables
@@ -354,48 +354,45 @@ For APIs with very strict rate limits, consider using materialized views to cach
354354
### Basic Query
355355

356356
```sql
357-
create foreign table openapi.users (
358-
id text,
359-
name text,
360-
email text,
361-
attrs jsonb
362-
)
363-
server my_api_server
364-
options (
365-
endpoint '/users',
366-
rowid_column 'id'
367-
);
357+
-- Create a foreign server connecting to the Weather.gov API
358+
create server openapi_server
359+
foreign data wrapper wasm_wrapper
360+
options (
361+
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_openapi_fdw_v0.1.4/openapi_fdw.wasm',
362+
fdw_package_name 'supabase:openapi-fdw',
363+
fdw_package_version '0.1.4',
364+
fdw_package_checksum 'dd434f8565b060b181d1e69e1e4d5c8b9c3ac5ca444056d3c2fb939038d308fe',
365+
base_url 'https://api.weather.gov',
366+
spec_url 'https://api.weather.gov/openapi.json'
367+
);
368368

369-
-- List all users
370-
select id, name, email from openapi.users;
369+
-- Create a schema to hold the imported foreign tables
370+
create schema if not exists openapi;
371371

372-
-- Get a specific user
373-
select * from openapi.users where id = 'user-123';
372+
-- Auto-import all API endpoints as foreign tables based on the OpenAPI spec
373+
import foreign schema openapi from server openapi_server into openapi;
374+
375+
-- Query the stations endpoint to get weather station data
376+
select * from openapi.stations limit 5;
374377
```
375378

376379
### Nested Resources
377380

378381
```sql
379-
create foreign table openapi.user_orders (
380-
user_id text,
382+
-- Create a foreign table for a parameterized endpoint with {zone_id} path parameter
383+
create foreign table openapi.zone_stations (
384+
zone_id text,
381385
id text,
382-
total numeric,
383-
status text,
384-
created_at timestamptz,
386+
type text,
385387
attrs jsonb
386-
)
387-
server my_api_server
388+
) server openapi_server
388389
options (
389-
endpoint '/users/{user_id}/orders',
390+
endpoint '/zones/forecast/{zone_id}/stations',
390391
rowid_column 'id'
391392
);
392393

393-
-- Get orders for a specific user
394-
select * from openapi.user_orders where user_id = 'user-123';
395-
396-
-- Get a specific order
397-
select * from openapi.user_orders
398-
where user_id = 'user-123' and id = 'order-456';
394+
-- Query stations for Alaska zone AKZ317 - generates GET /zones/forecast/AKZ317/stations
395+
select id, type from openapi.zone_stations where zone_id = 'AKZ317';
399396
```
400397

401398
### Custom Headers

wasm-wrappers/fdw/openapi_fdw/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Handles pagination, rate limiting (429 backoff), path parameter substitution fro
1717
CREATE SERVER my_api_server
1818
FOREIGN DATA WRAPPER wasm_wrapper
1919
OPTIONS (
20-
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/...',
20+
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_openapi_fdw_v0.1.4/openapi_fdw.wasm',
2121
fdw_package_name 'supabase:openapi-fdw',
2222
fdw_package_version '0.1.4',
23-
fdw_package_checksum '...',
23+
fdw_package_checksum 'dd434f8565b060b181d1e69e1e4d5c8b9c3ac5ca444056d3c2fb939038d308fe',
2424
base_url 'https://api.example.com/v1',
2525
spec_url 'https://api.example.com/openapi.json',
2626
api_key_id '<vault_secret_id>'
@@ -29,10 +29,10 @@ OPTIONS (
2929
-- Import all endpoints as tables
3030
IMPORT FOREIGN SCHEMA openapi
3131
FROM SERVER my_api_server
32-
INTO api;
32+
INTO openapi;
3333

3434
-- Query the API
35-
SELECT * FROM api.users WHERE id = '123';
35+
SELECT * FROM openapi.users WHERE id = '123';
3636
```
3737

3838
## Development

0 commit comments

Comments
 (0)