Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure prepareServer respects server variables when custom url is the same as the OAS url #855

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/src/lib/prepareServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function stripTrailingSlash(url: string) {
*
*/
export default function prepareServer(spec: Oas, url: string, variables: Record<string, string | number> = {}) {
let serverIdx;
let serverIdx: number | undefined;
const sanitizedUrl = stripTrailingSlash(url);
(spec.api.servers || []).forEach((server, i) => {
if (server.url === sanitizedUrl) {
Expand All @@ -25,7 +25,7 @@ export default function prepareServer(spec: Oas, url: string, variables: Record<
// If we were able to find the passed in server in the OAS servers, we should use that! If we
// couldn't and server variables were passed in we should try our best to handle that, otherwise
// we should ignore the passed in server and use whever the default from the OAS is.
if (serverIdx) {
if (serverIdx !== undefined) {
return {
selected: serverIdx,
variables,
Expand Down