-
-
Notifications
You must be signed in to change notification settings - Fork 529
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
This previously used to work
input: {
target: 'https://example.com/api-docs/v2/swagger.yaml',
parserOptions: {
resolve: {
http: {
headers: {
Authorization:
'Basic ' + Buffer.from('username:password').toString('base64'),
},
},
},
},
},But is no longer working, looking at the code it seems we stopped passing the parserOptions:
async function resolveSpec(
input: string | Record<string, unknown>,
): Promise<OpenApiDocument> {
const data = await bundle(input, {
plugins: [readFiles(), fetchUrls(), parseJson(), parseYaml()],
treeShake: true,
});
const dereferencedData = dereferenceExternalRef(data);
const { valid, errors } = await validateSpec(dereferencedData);
if (!valid) {
throw new Error('Validation failed', { cause: errors });
}
const { specification } = upgrade(dereferencedData);
return specification;
}
export async function importSpecs(
workspace: string,
options: NormalizedOptions,
projectName?: string,
): Promise<WriteSpecBuilder> {
const { input, output } = options;
const spec = await resolveSpec(input.target);
return importOpenApi({
spec,
input,
output,
target: input.target,
workspace,
projectName,
});
}To fix this we could pass the parserOptions like we did before (or at least the headers):
await bundle(
document,
{
plugins: [
fetchUrls({
// Pass custom headers
// The header will only be attached to the list of domains
headers: [
{
domains: ['example.com'],
headers: {
'Authorization': 'Bearer <TOKEN>'
}
}
]
}),
readFiles(),
],
treeShake: false
},
)Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working