@@ -74,11 +74,8 @@ export abstract class AbstractEndpoint {
7474 public abstract get scopes ( ) : ReadonlyArray < string > ;
7575 /** @internal */
7676 public abstract get tags ( ) : ReadonlyArray < string > ;
77- /**
78- * @internal
79- * @todo reconsider the purpose of this method, since parsers are global now
80- * */
81- public abstract get requestType ( ) : ContentType ;
77+ /** @internal */
78+ public abstract getProbableRequestType ( method ?: ClientMethod ) : ContentType ;
8279 /** @internal */
8380 public abstract get isDeprecated ( ) : boolean ;
8481}
@@ -89,6 +86,7 @@ export class Endpoint<
8986 CTX extends FlatObject ,
9087> extends AbstractEndpoint {
9188 readonly #def: ConstructorParameters < typeof Endpoint < IN , OUT , CTX > > [ 0 ] ;
89+ #requestType?: ContentType ;
9290
9391 /** considered an expensive operation, only required for generators */
9492 #ensureOutputExamples = R . once ( ( ) => {
@@ -161,15 +159,18 @@ export class Endpoint<
161159 }
162160
163161 /** @internal */
164- public override get requestType ( ) {
165- const found = findRequestTypeDefiningSchema ( this . #def. inputSchema ) ;
166- if ( found ) {
167- const brand = getBrand ( found ) ;
168- if ( brand === ezUploadBrand ) return "upload" ;
169- if ( brand === ezRawBrand ) return "raw" ;
170- if ( brand === ezFormBrand ) return "form" ;
171- }
172- return "json" ;
162+ public override getProbableRequestType ( method ?: ClientMethod ) {
163+ if ( method === "query" ) return "form" ;
164+ return ( this . #requestType ??= ( ( ) => {
165+ const found = findRequestTypeDefiningSchema ( this . #def. inputSchema ) ;
166+ if ( found ) {
167+ const brand = getBrand ( found ) ;
168+ if ( brand === ezUploadBrand ) return "upload" ;
169+ if ( brand === ezRawBrand ) return "raw" ;
170+ if ( brand === ezFormBrand ) return "form" ;
171+ }
172+ return "json" ;
173+ } ) ( ) ) ;
173174 }
174175
175176 /** @internal */
0 commit comments