Skip to content

Commit d11ad93

Browse files
committed
add functionality to read api schema. add skill for schema command
1 parent 954df17 commit d11ad93

21 files changed

Lines changed: 43099 additions & 10 deletions

File tree

.github/workflows/test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ jobs:
2121
- name: Download dependencies
2222
run: go mod download
2323

24+
- name: Verify generated schema is up to date
25+
run: |
26+
go generate ./...
27+
if ! git diff --exit-code internal/spec/extracted_gen.go; then
28+
echo "::error::internal/spec/extracted_gen.go is stale. Run 'go generate ./...' and commit the result."
29+
exit 1
30+
fi
31+
2432
- name: Run tests
2533
run: go test ./... -v -race -coverprofile=coverage.out
2634

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ The CLI uses a **resource-registry** pattern:
4141
| `cmd/` | Root Cobra command, persistent flags, version command |
4242
| `internal/registry/` | Resource/Operation types, dynamic Cobra command builder |
4343
| `internal/resources/` | All resource implementations |
44+
| `internal/spec/` | OpenAPI request/response schemas (extracted at build time) |
45+
| `cmd/extract-schemas/` | Generator: reads `api/*.json` and emits `internal/spec/extracted_gen.go` |
46+
| `api/` | Checked-in OpenAPI specs (source of truth for the schema feature) |
4447
| `skills/` | Per-command agent skill documents (`<command>/SKILL.md` with YAML frontmatter) |
4548
| `internal/client/` | HTTP client with retry logic, structured error types |
4649
| `internal/auth/` | Credential resolution (env -> file), OAuth token caching |
@@ -196,6 +199,7 @@ When adding a new resource or operation:
196199
4. If the resource uses name-based lookup, add a `PreRun` hook for server-side ID resolution
197200
5. Update the **Command Surface** table in this file
198201
6. If the resource adds a new leaf command, add a corresponding `skills/<command>/SKILL.md` with frontmatter (`name`, `description`, `command`) and task-oriented agent guidance
202+
7. Set `SpecRef: registry.SpecRef{Path: "...", Method: "..."}` on each operation that maps to an OpenAPI route, then run `go generate ./...` (or `make generate`) so `internal/spec/extracted_gen.go` picks up the new route. CI fails if this file is stale.
199203

200204
### Adding New Skills
201205

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ LDFLAGS = -X github.com/airbytehq/airbyte-cli/cmd.Version=$(VERSION) \
66
-X github.com/airbytehq/airbyte-cli/cmd.Commit=$(COMMIT) \
77
-X github.com/airbytehq/airbyte-cli/cmd.Date=$(DATE)
88

9-
.PHONY: build test lint install clean
9+
.PHONY: build generate test lint install clean
1010

11-
build:
11+
build: generate
1212
go build -ldflags "$(LDFLAGS)" -o airbyte .
1313

14+
generate:
15+
go generate ./...
16+
1417
test:
1518
go test ./... -v
1619

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ main.go
3131
| `cmd/` | Root Cobra command, persistent flags, version |
3232
| `internal/registry/` | `Resource` interface, dynamic command builder |
3333
| `internal/resources/` | Resource implementations |
34+
| `internal/spec/` | Generated OpenAPI request/response schemas |
35+
| `cmd/extract-schemas/` | Build-time generator: extracts the routes the CLI uses from `api/*.json` |
36+
| `api/` | Checked-in OpenAPI specs |
3437
| `skills/` | Per-command agent skill documents (`<command>/SKILL.md`) |
3538
| `internal/client/` | HTTP client (3x exponential-backoff retry on 429/5xx, 30s timeout) |
3639
| `internal/auth/` | Credential resolution, OAuth token caching |
@@ -163,9 +166,12 @@ This is **client-side**: the full payload still travels from the API to the CLI.
163166
```bash
164167
airbyte --help # list resources
165168
airbyte connectors --help # list operations
166-
airbyte connectors execute --describe # show parameter schema
169+
airbyte connectors execute --describe # CLI params + OpenAPI request/response schema
170+
airbyte schema connectors execute # equivalent top-level form
167171
```
168172

173+
`--describe` and `airbyte schema <resource> <operation>` return the same payload: CLI-level parameters under `params`, plus the underlying OpenAPI route (path, method, parameters, request body, response) under `api`. The OpenAPI schemas are extracted at build time from `api/*.json` and cover only the routes the CLI actually uses, so the dump stays focused.
174+
169175
### Command surface
170176

171177
| Resource | Operation | Description |

0 commit comments

Comments
 (0)