Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type RequestData = {
method: string;
parameters: ParameterWithIn[];
requestBody: any;
openapiOperation?: OperationDetails & Record<string, string>;
openapiOperation?: OperationDetails & { securitySchemes?: Record<string, Oas3SecurityScheme> };
};

export async function prepareRequest(
Expand Down
15 changes: 9 additions & 6 deletions packages/respect-core/src/utils/api-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { DEFAULT_RESPECT_MAX_FETCH_TIMEOUT } from '../consts.js';
import { parseWwwAuthenticateHeader } from './digest-auth/parse-www-authenticate-header.js';
import { generateDigestAuthHeader } from './digest-auth/generate-digest-auth-header.js';

import type { Oas3SecurityScheme } from '@redocly/openapi-core';
import type { RequestData } from '../modules/flow-runner/index.js';

const logger = DefaultLogger.getInstance();
Expand Down Expand Up @@ -278,12 +279,14 @@ export class ApiFetcher implements IFetcher {
...(step['x-security'] || []),
]
.reverse()
.find(
(security) =>
'scheme' in security &&
security.scheme?.type === 'http' &&
security.scheme?.scheme === 'digest'
);
.find((security) => {
const scheme =
'schemeName' in security && security.schemeName
? openapiOperation?.securitySchemes?.[security.schemeName]
: (security.scheme as Oas3SecurityScheme);

return scheme?.type === 'http' && scheme?.scheme === 'digest';
});

if (lastDigestSecurityScheme) {
// FETCH WITH DIGEST AUTH
Expand Down
Loading