Swagger Editor
AsyncAPI preview plugin now uses @asyncapi/parser
v3 instead of v1. The way, how we pass options to the AsyncAPI parser changed.
editorPreviewAsyncAPI.actions.parse
FSA creator now accepts options objects in a shape of { parserOptions, parseOptions }
as a second argument. parserOptions
are passed to the parser constructor during the parser creation and parseOptions
are passed to parse function during the parsing.
Here is an example how to override how AsyncAPI parser resolves HTTP(S) URLs:
const AsyncAPIParseOptionsPlugin = () => ({
statePlugins: {
editorPreviewAsyncAPI: {
wrapActions: {
parse:
(oriAction) =>
(content, options = {}) => {
const httpsFetchResolver = {
schema: 'https',
canRead: true,
async read(uri) {
const response = await fetch(uri.toString());
return response.text();
},
};
const httpFetchResolver = {
schema: 'http',
canRead: true,
async read(uri) {
const response = await fetch(uri.toString());
return response.text();
},
};
const parserOptions = {
...options.parserOptions,
__unstable: {
resolver: {
resolvers: [httpsFetchResolver, httpFetchResolver],
},
},
};
const parseOptions = options.parseOptions ?? {};
return oriAction(content, { parserOptions, parseOptions });
},
},
},
},
});
[!IMPORTANT]
Instructions for building SwaggerEditor@5 withwebpack@5
have changed.Handling
process
withimports-loader
it no longer necessary.To avoid runtime errors, alias for
@stoplight/ordered-object-literal
needs to introduced. Please consult the amended Usage section of the main README file for more details.
[!IMPORTANT]
Instructions for building SwaggerEditor@5 withwebpack@5
changed. Before,process
injection was handled bywebpack.ProvidePlugin
. Now it's handled byimports-loader
. Please consult the amended Usage section of the main README file for more details. You can find the reasoning for the change in https://github.com/swagger-api/swagger-editor/issues/4848.
[!IMPORTANT] For those looking to integrate SwaggerEditor@4 with older versions of React, we have provided a recipe to assist you in this process. Please refer to the Using older version of React section of the main README for detailed instructions and tips to ensure a smooth integration.
This recipe is tailored to help you navigate any compatibility issues and make the most out of SwaggerEditor@4 with earlier React versions. We encourage you to explore this recipe and reach out to us if you need further assistance.