fix: fix custom http resolvers for AsyncAPI widget

Signed-off-by: David Weber <david.weber@w3tec.ch>
This commit is contained in:
David Weber
2024-01-09 21:50:54 +01:00
committed by Fredrik Adelöw
parent 1e4d574e3b
commit 8a69cc95b2
2 changed files with 26 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-api-docs': patch
---
Fix custom http resolvers for AsyncAPI widget.
@@ -143,18 +143,33 @@ const useStyles = makeStyles(theme => ({
},
}));
const fetchResolver = {
order: 199, // Use 199 as the built-in http resolver is 200
canRead: /^https?:\/\//,
async read(file: any) {
const response = await fetch(file.url);
const httpsFetchResolver = {
schema: 'https',
order: 1,
canRead: true,
async read(uri: any) {
const response = await fetch(uri.toString());
return response.text();
},
};
const httpFetchResolver = {
schema: 'http',
order: 1,
canRead: true,
async read(uri: any) {
const response = await fetch(uri.toString());
return response.text();
},
};
const config = {
parserOptions: {
resolve: { fetch: fetchResolver },
__unstable: {
resolver: {
resolvers: [httpsFetchResolver, httpFetchResolver],
},
},
},
};