fix: fix custom http resolvers for AsyncAPI widget
Signed-off-by: David Weber <david.weber@w3tec.ch>
This commit is contained in:
committed by
Fredrik Adelöw
parent
1e4d574e3b
commit
8a69cc95b2
@@ -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],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user