@@ -26,7 +26,7 @@ import {
2626import { PtyPaths } from "../../src/server/routes/instance/httpapi/groups/pty"
2727import { MessagesQuery as V2MessagesQuery } from "../../src/server/routes/instance/httpapi/groups/v2/message"
2828import { SessionsQuery as V2SessionsQuery } from "../../src/server/routes/instance/httpapi/groups/v2/session"
29- import { QueryBoolean } from "../../src/server/routes/instance/httpapi/groups/query"
29+ import { QueryBoolean , QueryBooleanOpenApi } from "../../src/server/routes/instance/httpapi/groups/query"
3030import { resetDatabase } from "../fixture/db"
3131import { disposeAllInstances , tmpdir } from "../fixture/fixture"
3232import { it } from "../lib/effect"
@@ -36,6 +36,8 @@ const originalWorkspaces = Flag.OPENCODE_EXPERIMENTAL_WORKSPACES
3636type Method = "get" | "post" | "put" | "delete" | "patch"
3737type QuerySchema = { readonly fields : Record < string , unknown > }
3838type OpenApiSchema = {
39+ readonly anyOf ?: readonly OpenApiSchema [ ]
40+ readonly enum ?: readonly string [ ]
3941 readonly maximum ?: number
4042 readonly minimum ?: number
4143 readonly pattern ?: string
@@ -75,6 +77,13 @@ const numericSdkQueryParams = [
7577 { method : "get" , path : "/api/session/:sessionID/message" , name : "limit" , schema : { type : "number" } } ,
7678] satisfies Array < { method : Method ; path : string ; name : string ; schema : OpenApiSchema } >
7779
80+ const booleanSdkQueryParams = [
81+ { method : "get" , path : ExperimentalPaths . session , name : "roots" } ,
82+ { method : "get" , path : ExperimentalPaths . session , name : "archived" } ,
83+ { method : "get" , path : SessionPaths . list , name : "roots" } ,
84+ { method : "get" , path : "/api/session" , name : "roots" } ,
85+ ] satisfies Array < { method : Method ; path : string ; name : string } >
86+
7887const queryParamPatterns = [
7988 { method : "get" , path : SessionPaths . diff , name : "messageID" , pattern : "^msg" } ,
8089] satisfies Array < { method : Method ; path : string ; name : string ; pattern : string } >
@@ -174,20 +183,7 @@ describe("httpapi query schema drift", () => {
174183 )
175184
176185 it . effect (
177- "OpenAPI query parameter patterns come from runtime schemas" ,
178- Effect . sync ( ( ) => {
179- const spec = OpenApi . fromApi ( PublicApi )
180- for ( const expected of queryParamPatterns ) {
181- expect (
182- queryParameter ( spec . paths [ openApiPath ( expected . path ) ] ?. [ expected . method ] , expected . name ) ?. schema ,
183- `${ expected . method . toUpperCase ( ) } ${ expected . path } ${ expected . name } ` ,
184- ) . toEqual ( { type : "string" , pattern : expected . pattern } )
185- }
186- } ) ,
187- )
188-
189- it . effect (
190- "OpenAPI workspace query params are declared by runtime query schemas" ,
186+ "OpenAPI query params are declared by runtime query schemas" ,
191187 Effect . sync ( ( ) => {
192188 const spec = OpenApi . fromApi ( PublicApi )
193189 for ( const route of openApiDriftRoutes ) {
@@ -200,7 +196,7 @@ describe("httpapi query schema drift", () => {
200196 )
201197
202198 it . effect (
203- "OpenAPI numeric query params preserve generated SDK call shapes " ,
199+ "OpenAPI query and path schemas preserve compatibility metadata " ,
204200 Effect . sync ( ( ) => {
205201 const spec = OpenApi . fromApi ( PublicApi )
206202 for ( const expected of numericSdkQueryParams ) {
@@ -209,13 +205,18 @@ describe("httpapi query schema drift", () => {
209205 `${ expected . method . toUpperCase ( ) } ${ expected . path } ${ expected . name } ` ,
210206 ) . toEqual ( expected . schema )
211207 }
212- } ) ,
213- )
214-
215- it . effect (
216- "OpenAPI path parameter patterns come from runtime schemas" ,
217- Effect . sync ( ( ) => {
218- const spec = OpenApi . fromApi ( PublicApi )
208+ for ( const expected of booleanSdkQueryParams ) {
209+ expect (
210+ queryParameter ( spec . paths [ openApiPath ( expected . path ) ] ?. [ expected . method ] , expected . name ) ?. schema ,
211+ `${ expected . method . toUpperCase ( ) } ${ expected . path } ${ expected . name } ` ,
212+ ) . toEqual ( QueryBooleanOpenApi )
213+ }
214+ for ( const expected of queryParamPatterns ) {
215+ expect (
216+ queryParameter ( spec . paths [ openApiPath ( expected . path ) ] ?. [ expected . method ] , expected . name ) ?. schema ,
217+ `${ expected . method . toUpperCase ( ) } ${ expected . path } ${ expected . name } ` ,
218+ ) . toEqual ( { type : "string" , pattern : expected . pattern } )
219+ }
219220 for ( const expected of pathParamPatterns ) {
220221 expect (
221222 pathParameter ( spec . paths [ openApiPath ( expected . path ) ] ?. [ expected . method ] , expected . name ) ?. schema ,
0 commit comments