Scope boolean query overrides
This commit is contained in:
@@ -6,3 +6,7 @@ export const QueryBoolean = Schema.Literals(["true", "false"]).pipe(
|
||||
encode: SchemaGetter.transform((value) => (value ? "true" : "false")),
|
||||
}),
|
||||
)
|
||||
|
||||
export const QueryBooleanOpenApi = {
|
||||
anyOf: [{ type: "boolean" }, { type: "string", enum: ["true", "false"] }],
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { OpenApi } from "effect/unstable/httpapi"
|
||||
import { OpenCodeHttpApi } from "./api"
|
||||
import { QueryBooleanOpenApi } from "./groups/query"
|
||||
|
||||
type OpenApiParameter = {
|
||||
name: string
|
||||
@@ -54,17 +55,20 @@ type OpenApiResponse = {
|
||||
// Query schemas describe decoded Effect values, but the generated SDK needs the
|
||||
// public call shape. These keep SDK callers passing numbers/booleans while the
|
||||
// server still decodes string query params at runtime.
|
||||
const QueryBooleanParameters = new Set(["roots", "archived"])
|
||||
const QueryParameterSchemas: Record<string, OpenApiSchema> = {
|
||||
"GET /experimental/session start": { type: "number" },
|
||||
"GET /experimental/session roots": QueryBooleanOpenApi,
|
||||
"GET /experimental/session archived": QueryBooleanOpenApi,
|
||||
"GET /find/file limit": { type: "integer", minimum: 1, maximum: 200 },
|
||||
"GET /experimental/session cursor": { type: "number" },
|
||||
"GET /experimental/session limit": { type: "number" },
|
||||
"GET /session start": { type: "number" },
|
||||
"GET /session roots": QueryBooleanOpenApi,
|
||||
"GET /session limit": { type: "number" },
|
||||
"GET /session/{sessionID}/message limit": { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
||||
"GET /api/session limit": { type: "number" },
|
||||
"GET /api/session start": { type: "number" },
|
||||
"GET /api/session roots": QueryBooleanOpenApi,
|
||||
"GET /api/session/{sessionID}/message limit": { type: "number" },
|
||||
}
|
||||
|
||||
@@ -486,12 +490,6 @@ function normalizeParameter(param: OpenApiParameter, route: string) {
|
||||
param.schema = override
|
||||
return
|
||||
}
|
||||
if (QueryBooleanParameters.has(param.name)) {
|
||||
param.schema = {
|
||||
anyOf: [{ type: "boolean" }, { type: "string", enum: ["true", "false"] }],
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
param.schema = stripOptionalNull(param.schema)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user