Skip to content

Commit

Permalink
Make fallback HttpVisibilityProvider logic more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
willmtemple committed Dec 19, 2024
1 parent e6720be commit 42242b2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/http/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
isQueryParam,
isStatusCode,
} from "./decorators.js";
import { getHttpOperation } from "./operations.js";
import { HttpVerb, OperationParameterOptions } from "./types.js";

/**
Expand Down Expand Up @@ -333,11 +334,17 @@ export function HttpVisibilityProvider(

return {
parameters: (program, operation) => {
const verb = hasVerb
let verb = hasVerb
? (verbOrParameterOptions as HttpVerb)
: (verbOrParameterOptions?.verbSelector?.(program, operation) ??
getOperationVerb(program, operation) ??
"get");
getOperationVerb(program, operation));

if (!verb) {
const [httpOperation] = getHttpOperation(program, operation);

verb = httpOperation.verb;
}

return visibilityToFilter(program, getDefaultVisibilityForVerb(verb));
},
returnType: (program, _) => {
Expand All @@ -360,6 +367,10 @@ export function resolveRequestVisibility(
operation: Operation,
verb: HttpVerb,
): Visibility {
// WARNING: This is the only place where we call HttpVisibilityProvider _WITHIN_ the HTTP implementation itself. We
// _must_ provide the verb directly to the function as the first argument. If the verb is not provided directly, the
// provider calls getHttpOperation to resolve the verb. Since the current function is called from getHttpOperation, it
// will cause a stack overflow if the version of HttpVisibilityProvider we use here has to resolve the verb itself.
const parameterVisibilityFilter = getParameterVisibilityFilter(
program,
operation,
Expand Down

0 comments on commit 42242b2

Please sign in to comment.