Skip to content

fix(storage): document 200 responses for vector bucket CRUD endpoints - #1270

Open
grdsdev wants to merge 2 commits into
masterfrom
feat/vector-bucket-openapi
Open

fix(storage): document 200 responses for vector bucket CRUD endpoints#1270
grdsdev wants to merge 2 commits into
masterfrom
feat/vector-bucket-openapi

Conversation

@grdsdev

@grdsdev grdsdev commented Jul 28, 2026

Copy link
Copy Markdown

Context

The SDK team is starting to use the generated OpenAPI spec to generate idiomatic API clients for the Supabase SDKs. We're starting with vector buckets for testing. This PR is the first of several that will make the fastify-generated OpenAPI spec ready for client generation, split by route family to keep each one reviewable.

Summary

First slice of #1215 (too large to review as one PR), split by route family. This PR covers only the vector bucket routes.

  • Adds vectorBucketSchema, getVectorBucketResponseSchema, listVectorBucketsResponseSchema (mirroring bucketSchema/objectSchema), and wires them into create-bucket/delete-bucket/get-bucket/list-buckets so the exported spec has success schemas for the vector CRUD endpoints, not just error responses.
  • Adds src/http/routes/openapi-transform.ts: derives stable operationIds from each route's existing config.operation, names swagger components by $id instead of def-N, folds duplicate trailing-slash paths, and documents a generic 4xx (doc-only, covering 403 etc.) for any route without one. Prerequisite infra for generating a usable client from any route family, starting here with vector.

Deferred to follow-up PRs: bucket/object/iceberg/render/tus/cdn/health route documentation, error-handler.ts formatter support, apikey.ts, typespec tooling additions.

Test plan

  • tsc -noEmit — no errors
  • biome check on touched files — clean
  • vitest run on openapi-transform.test.ts — 5/5 passing

The vector bucket routes (create/get/list/delete) only ever documented
error responses, so the exported OpenAPI spec had no success schema at
all for them - unusable for SDK generation. Adds a vectorBucketSchema
component (mirroring bucketSchema/objectSchema) plus response wrappers
for get/list, and explicit `type: 'null'` 200s for the void
create/delete responses so generators don't try to decode an empty
body as JSON.

Also wires createOpenApiTransform/dedupeTrailingSlashPaths/
nameSchemaByDollarId into the swagger build (assigns stable
operationIds from each route's config.operation, names swagger
components by $id, and folds duplicate trailing-slash paths), and
documents the 403 response every JWT-guarded route (including vector)
can return.

First slice of a larger OpenAPI/SDK-generation PR, split up by route
family to keep review scoped.
@grdsdev
grdsdev requested a review from a team as a code owner July 28, 2026 09:13
@coveralls

coveralls commented Jul 28, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 30351674790

Coverage increased (+0.08%) to 80.382%

Details

  • Coverage increased (+0.08%) from the base build.
  • Patch coverage: 2 uncovered changes across 1 file (73 of 75 lines covered, 97.33%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
src/http/routes/openapi-transform.ts 67 65 97.01%
Total (3 files) 75 73 97.33%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
src/http/routes/s3/index.ts 1 86.09%

Coverage Stats

Coverage Status
Relevant Lines: 12896
Covered Lines: 10802
Line Coverage: 83.76%
Relevant Branches: 7580
Covered Branches: 5657
Branch Coverage: 74.63%
Branches in Coverage %: Yes
Coverage Strength: 409.84 hits per line

💛 - Coveralls

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond the inline finding, I also checked vectorBucketSchema's use of the OpenAPI-style nullable: true keyword on creationTime (rather than the type: ['integer', 'null'] / anyOf pattern used everywhere else in src/storage/schemas) — it's a docs-only response schema and AJV ignores the unrecognized nullable keyword rather than erroring, so it doesn't break validation, just an inconsistency worth normalizing at some point.

Extended reasoning...

Confirmed via grep that every other nullable field in src/storage/schemas (bucket.ts, object.ts, upload.ts, multipart.ts) uses type: [x, 'null'] or anyOf, never the OpenAPI 3.0 'nullable' keyword. Since this schema is only used for response documentation/serialization (not request validation) and AJV in this codebase's default config doesn't run in strict mode that would throw on unknown keywords, this doesn't cause a functional bug — just a style inconsistency, not delaying approval on its own.

Comment thread src/http/plugins/jwt.ts Outdated
The onRoute hook was mutating routeOptions.schema.response directly,
which Fastify compiles into a real fast-json-stringify serializer
independent of docs generation. Iceberg's routes use a custom error
formatter ({ error: { message, type, code } }, no top-level
statusCode/message/code), so any 403 there (wrong-role JWT) would fail
serialization against errorSchema's required fields and come back as
a 500 instead. openapi-transform.ts's defaultErrorResponse already
documents a generic 4xx (covering 403) doc-only for every route, so no
replacement is needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants