Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Snippets: `devproxy-plugin-rewrite-file` - RewritePlugin rewrites file
- Snippets: `devproxy-plugin-rewrite-file-schema` - RewritePlugin rewrites file schema
- Diagnostics: Show warning if config contains a summary plugin without a reporter
- Diagnostics: Show warning if OpenApiSpecGeneratorPlugin is placed after ApiCenterOnboardingPlugin

### Changed:

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The following sections describe the features that the extension contributes to V
- Check that a plugin can be configured with a configSection
- Check for configSections that are not used in plugins
- Check for reporter plugin when a summary plugin is used
- Check that ApiCenterOnboardingPlugin is placed after OpenApiSpecGeneratorPlugin

### Editor Actions

Expand Down
44 changes: 44 additions & 0 deletions src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const checkPlugins = (pluginsNode: parse.PropertyNode | undefined, diagnostics:
warnOnReporterPosition(pluginNodes, diagnostics);
validatePluginConfigurations(pluginNodes, diagnostics, documentNode);
checkForSummaryPluginWithoutReporter(pluginNodes, diagnostics);
checkAPICOnboardingPluginAfterOpenApiSpecGeneratorPlugin(pluginNodes, diagnostics);
}
};

Expand Down Expand Up @@ -341,4 +342,47 @@ function checkForSummaryPluginWithoutReporter(pluginNodes: parse.ObjectNode[], d
);
}
}
}

function checkAPICOnboardingPluginAfterOpenApiSpecGeneratorPlugin(pluginNodes: parse.ObjectNode[], diagnostics: vscode.Diagnostic[]) {
const openApiSpecGeneratorPluginIndex = pluginNodes.findIndex((pluginNode: parse.ObjectNode) => {
const pluginNameNode = getASTNode(
pluginNode.children,
'Identifier',
'name'
);
const pluginName = (pluginNameNode?.value as parse.LiteralNode)
.value as string;
const enabledNode = getASTNode(
pluginNode.children,
'Identifier',
'enabled'
);
const isEnabled = (enabledNode?.value as parse.LiteralNode)
.value as boolean;
return pluginName === 'OpenApiSpecGeneratorPlugin' && isEnabled;
}
);
if (openApiSpecGeneratorPluginIndex !== -1) {
const apiCenterOnboardingPluginIndex = pluginNodes.findIndex((pluginNode: parse.ObjectNode) => {
const pluginNameNode = getASTNode(
pluginNode.children,
'Identifier',
'name'
);
const pluginName = (pluginNameNode?.value as parse.LiteralNode)
.value as string;
return pluginName === 'ApiCenterOnboardingPlugin';
}
);
if (apiCenterOnboardingPluginIndex !== -1 && apiCenterOnboardingPluginIndex < openApiSpecGeneratorPluginIndex) {
diagnostics.push(
new vscode.Diagnostic(
getRangeFromASTNode(pluginNodes[openApiSpecGeneratorPluginIndex]),
'OpenApiSpecGeneratorPlugin should be placed before ApiCenterOnboardingPlugin.',
vscode.DiagnosticSeverity.Warning
)
);
}
}
}