зеркало из https://github.com/Azure/autorest.git
Refactor: Plugins structure (#4042)
This commit is contained in:
Родитель
e184942478
Коммит
1ecc7831f3
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@autorest/core",
|
||||
"comment": "**Internal** Refactor plugins",
|
||||
"type": "patch"
|
||||
}
|
||||
],
|
||||
"packageName": "@autorest/core",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -27,7 +27,7 @@ Directives consist of three parts:
|
|||
- A `property` can be filtered by:
|
||||
- its location within its parent object
|
||||
|
||||
- **Transform**: denoted by the field `transform`, the actions we would like to be applied on the specified objects. The list of available variables and functions can be found in [eval.ts](https://github.com/Azure/autorest/blob/master/packages/extensions/core/src/lib/pipeline/plugins/transformer/eval.ts)
|
||||
- **Transform**: denoted by the field `transform`, the actions we would like to be applied on the specified objects. The list of available variables and functions can be found in [eval.ts](https://github.com/Azure/autorest/blob/master/packages/extensions/core/src/lib/plugins/transformer/eval.ts)
|
||||
|
||||
## Built-in Directives
|
||||
|
||||
|
|
|
@ -19,48 +19,14 @@ import {
|
|||
import { AutorestContext, getExtension } from "../context";
|
||||
import { Channel } from "../message";
|
||||
import { OutstandingTaskAwaiter } from "../outstanding-task-awaiter";
|
||||
import { PipelinePlugin } from "./common";
|
||||
import { createComponentModifierPlugin } from "./component-modifier";
|
||||
import { createCSharpReflectApiVersionPlugin } from "./metadata-generation";
|
||||
import { AutoRestExtension } from "./plugin-endpoint";
|
||||
import { createCommonmarkProcessorPlugin } from "./plugins/commonmark";
|
||||
import { createAllOfCleaner } from "./plugins/allof-cleaner";
|
||||
import { createCommandPlugin } from "./plugins/command";
|
||||
|
||||
import { createComponentKeyRenamerPlugin } from "./plugins/component-key-renamer";
|
||||
import { createComponentsCleanerPlugin } from "./plugins/components-cleaner";
|
||||
import { createSwaggerToOpenApi3Plugin } from "./plugins/conversion";
|
||||
import { createDeduplicatorPlugin } from "./plugins/deduplicator";
|
||||
import { createArtifactEmitterPlugin } from "./plugins/emitter";
|
||||
import { createEnumDeduplicator } from "./plugins/enum-deduplication";
|
||||
import { createExternalPlugin } from "./plugins/external";
|
||||
import { createHelpPlugin } from "./plugins/help";
|
||||
import {
|
||||
createIdentityPlugin,
|
||||
createIdentityResetPlugin,
|
||||
createNormalizeIdentityPlugin,
|
||||
createNullPlugin,
|
||||
} from "./plugins/identity";
|
||||
import { createOpenApiLoaderPlugin, createSwaggerLoaderPlugin } from "./plugins/loaders";
|
||||
import { createMultiApiMergerPlugin } from "./plugins/merger";
|
||||
import { createNewComposerPlugin } from "./plugins/new-composer";
|
||||
import { createProfileFilterPlugin } from "./plugins/profile-filter";
|
||||
import { createQuickCheckPlugin } from "./plugins/quick-check";
|
||||
import { subsetSchemaDeduplicatorPlugin } from "./plugins/subset-schemas-deduplicator";
|
||||
import {
|
||||
createImmediateTransformerPlugin,
|
||||
createTextTransformerPlugin,
|
||||
createTransformerPlugin,
|
||||
createGraphTransformerPlugin,
|
||||
} from "./plugins/transformer";
|
||||
import { createTreeShakerPlugin } from "./plugins/tree-shaker/tree-shaker";
|
||||
import { createApiVersionParameterHandlerPlugin } from "./plugins/version-param-handler";
|
||||
import { createJsonToYamlPlugin, createYamlToJsonPlugin } from "./plugins/yaml-and-json";
|
||||
import { createOpenApiSchemaValidatorPlugin, createSwaggerSchemaValidatorPlugin } from "./plugins/schema-validation";
|
||||
import { createArtifactEmitterPlugin } from "../plugins/emitter";
|
||||
import { createExternalPlugin } from "../plugins/external";
|
||||
import { createHash } from "crypto";
|
||||
import { isCached, readCache, writeCache } from "./pipeline-cache";
|
||||
import { values } from "@azure-tools/linq";
|
||||
import { createOpenAPIStatsCollectorPlugin } from "./plugins/openapi-stats-collector";
|
||||
import { PLUGIN_MAP } from "../plugins";
|
||||
|
||||
const safeEval = createSandbox();
|
||||
|
||||
|
@ -220,70 +186,14 @@ function isDrainRequired(p: PipelineNode) {
|
|||
|
||||
export async function runPipeline(configView: AutorestContext, fileSystem: IFileSystem): Promise<void> {
|
||||
// built-in plugins
|
||||
const plugins: { [name: string]: PipelinePlugin } = {
|
||||
"help": createHelpPlugin(),
|
||||
"identity": createIdentityPlugin(),
|
||||
"null": createNullPlugin(),
|
||||
"reset-identity": createIdentityResetPlugin(),
|
||||
"normalize-identity": createNormalizeIdentityPlugin(),
|
||||
"loader-swagger": createSwaggerLoaderPlugin(),
|
||||
"loader-openapi": createOpenApiLoaderPlugin(),
|
||||
"openapi-stats-collector": createOpenAPIStatsCollectorPlugin(),
|
||||
"transform": createTransformerPlugin(),
|
||||
"text-transform": createTextTransformerPlugin(),
|
||||
"new-transform": createGraphTransformerPlugin(),
|
||||
"transform-immediate": createImmediateTransformerPlugin(),
|
||||
"compose": createNewComposerPlugin(),
|
||||
"schema-validator-openapi": createOpenApiSchemaValidatorPlugin(),
|
||||
"schema-validator-swagger": createSwaggerSchemaValidatorPlugin(),
|
||||
// TODO: replace with OAV again
|
||||
"semantic-validator": createIdentityPlugin(),
|
||||
"openapi-document-converter": createSwaggerToOpenApi3Plugin(),
|
||||
"component-modifiers": createComponentModifierPlugin(),
|
||||
"yaml2jsonx": createYamlToJsonPlugin(),
|
||||
"jsonx2yaml": createJsonToYamlPlugin(),
|
||||
"reflect-api-versions-cs": createCSharpReflectApiVersionPlugin(),
|
||||
"commonmarker": createCommonmarkProcessorPlugin(),
|
||||
"profile-definition-emitter": createArtifactEmitterPlugin(),
|
||||
"emitter": createArtifactEmitterPlugin(),
|
||||
"pipeline-emitter": createArtifactEmitterPlugin(
|
||||
async () =>
|
||||
new QuickDataSource([
|
||||
await configView.DataStore.getDataSink().writeObject("pipeline", pipeline.pipeline, ["fix-me-3"], "pipeline"),
|
||||
]),
|
||||
),
|
||||
"configuration-emitter": createArtifactEmitterPlugin(
|
||||
async () =>
|
||||
new QuickDataSource([
|
||||
await configView.DataStore.getDataSink().writeObject(
|
||||
"configuration",
|
||||
configView.config.raw,
|
||||
["fix-me-4"],
|
||||
"configuration",
|
||||
),
|
||||
]),
|
||||
),
|
||||
"tree-shaker": createTreeShakerPlugin(),
|
||||
"enum-deduplicator": createEnumDeduplicator(),
|
||||
"quick-check": createQuickCheckPlugin(),
|
||||
"model-deduplicator": createDeduplicatorPlugin(),
|
||||
"subset-reducer": subsetSchemaDeduplicatorPlugin(),
|
||||
"multi-api-merger": createMultiApiMergerPlugin(),
|
||||
"components-cleaner": createComponentsCleanerPlugin(),
|
||||
"component-key-renamer": createComponentKeyRenamerPlugin(),
|
||||
"api-version-parameter-handler": createApiVersionParameterHandlerPlugin(),
|
||||
"profile-filter": createProfileFilterPlugin(),
|
||||
"allof-cleaner": createAllOfCleaner(),
|
||||
"command": createCommandPlugin(),
|
||||
};
|
||||
|
||||
// dynamically loaded, auto-discovered plugins
|
||||
const __extensionExtension: { [pluginName: string]: AutoRestExtension } = {};
|
||||
for (const useExtensionQualifiedName of configView.GetEntry("used-extension") || []) {
|
||||
const extension = await getExtension(useExtensionQualifiedName);
|
||||
for (const plugin of await extension.GetPluginNames(configView.CancellationToken)) {
|
||||
if (!plugins[plugin]) {
|
||||
plugins[plugin] = createExternalPlugin(extension, plugin);
|
||||
if (!PLUGIN_MAP[plugin]) {
|
||||
PLUGIN_MAP[plugin] = createExternalPlugin(extension, plugin);
|
||||
__extensionExtension[plugin] = extension;
|
||||
}
|
||||
}
|
||||
|
@ -327,6 +237,13 @@ export async function runPipeline(configView: AutorestContext, fileSystem: IFile
|
|||
const times = !!configView.config["timestamp"];
|
||||
const tasks: { [name: string]: Promise<DataSource> } = {};
|
||||
|
||||
const pipelineEmitterPlugin = createArtifactEmitterPlugin(
|
||||
async (context) =>
|
||||
new QuickDataSource([
|
||||
await context.DataStore.getDataSink().writeObject("pipeline", pipeline.pipeline, ["fix-me-3"], "pipeline"),
|
||||
]),
|
||||
);
|
||||
|
||||
const ScheduleNode: (nodeName: string) => Promise<DataSource> = async (nodeName) => {
|
||||
const node = pipeline.pipeline[nodeName];
|
||||
if (!node) {
|
||||
|
@ -374,7 +291,13 @@ export async function runPipeline(configView: AutorestContext, fileSystem: IFile
|
|||
const usenull =
|
||||
configEntry?.["null"] === true || values(configView.GetEntry("null")).any((each) => each === pluginName);
|
||||
|
||||
const plugin = usenull ? plugins.null : passthru ? plugins.identity : plugins[pluginName];
|
||||
const plugin = usenull
|
||||
? PLUGIN_MAP.null
|
||||
: passthru
|
||||
? PLUGIN_MAP.identity
|
||||
: pluginName === "pipeline-emitter"
|
||||
? pipelineEmitterPlugin
|
||||
: PLUGIN_MAP[pluginName];
|
||||
|
||||
if (!plugin) {
|
||||
throw new Error(`Plugin '${pluginName}' not found.`);
|
||||
|
|
|
@ -13,8 +13,8 @@ import {
|
|||
} from "@azure-tools/datastore";
|
||||
import { Model, isReference, Refable, Schema } from "@azure-tools/openapi";
|
||||
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { values, length, items } from "@azure-tools/linq";
|
||||
|
||||
export class AllOfCleaner {
|
|
@ -1,5 +1,5 @@
|
|||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { DataSource, DataSink, DataHandle, QuickDataSource } from "@azure-tools/datastore";
|
||||
import { execute, cmdlineToArray } from "@azure-tools/codegen";
|
||||
import { FileUriToPath } from "@azure-tools/uri";
|
|
@ -1,6 +1,6 @@
|
|||
import { DataHandle, QuickDataSource } from "@azure-tools/datastore";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { processCodeModel } from "../commonmark-documentation";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { processCodeModel } from "../pipeline/commonmark-documentation";
|
||||
|
||||
/* @internal */
|
||||
export function createCommonmarkProcessorPlugin(): PipelinePlugin {
|
|
@ -11,8 +11,8 @@ import {
|
|||
} from "@azure-tools/datastore";
|
||||
import { clone, Dictionary } from "@azure-tools/linq";
|
||||
import * as oai from "@azure-tools/openapi";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
export class ComponentKeyRenamer extends Transformer<any, oai.Model> {
|
||||
// oldRefs -> newRefs;
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { Clone } from "@azure-tools/datastore";
|
||||
import { mergeOverwriteOrAppend } from "@autorest/common";
|
||||
import { createPerFilePlugin, PipelinePlugin } from "./common";
|
||||
import { createPerFilePlugin, PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
function decorateSpecialProperties(o: any): void {
|
||||
if (o["implementation"]) {
|
|
@ -16,8 +16,8 @@ import {
|
|||
} from "@azure-tools/datastore";
|
||||
import { Dictionary } from "@azure-tools/linq";
|
||||
import * as oai from "@azure-tools/openapi";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
/**
|
||||
* components-to-keep are the ones that:
|
|
@ -1,5 +1,5 @@
|
|||
import { DataHandle, IFileSystem, QuickDataSource } from "@azure-tools/datastore";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { convertOai2ToOai3Files } from "@azure-tools/oai2-to-oai3";
|
||||
import { clone } from "@azure-tools/linq";
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
import { DataHandle, DataSink, DataSource, QuickDataSource } from "@azure-tools/datastore";
|
||||
import { Deduplicator } from "@azure-tools/deduplication";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { values } from "@azure-tools/linq";
|
||||
|
||||
async function deduplicate(context: AutorestContext, input: DataSource, sink: DataSink) {
|
|
@ -1,8 +1,8 @@
|
|||
import { DataHandle, DataSource, Normalize, QuickDataSource, createSandbox, Stringify } from "@azure-tools/datastore";
|
||||
import { ResolveUri } from "@azure-tools/uri";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { Channel } from "../../message";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { Channel } from "../message";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
const safeEval = createSandbox();
|
||||
|
||||
|
@ -131,10 +131,12 @@ export async function emitArtifacts(
|
|||
}
|
||||
|
||||
/* @internal */
|
||||
export function createArtifactEmitterPlugin(inputOverride?: () => Promise<DataSource>): PipelinePlugin {
|
||||
export function createArtifactEmitterPlugin(
|
||||
inputOverride?: (context: AutorestContext) => Promise<DataSource>,
|
||||
): PipelinePlugin {
|
||||
return async (context, input) => {
|
||||
if (inputOverride) {
|
||||
input = await inputOverride();
|
||||
input = await inputOverride(context);
|
||||
}
|
||||
|
||||
// clear output-folder if requested
|
|
@ -1,6 +1,6 @@
|
|||
import { DataHandle, DataSink, DataSource, QuickDataSource } from "@azure-tools/datastore";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { PipelinePlugin } from "../../common";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../../pipeline/common";
|
||||
import { EnumDeduplicator } from "./enum-deduplicator";
|
||||
|
||||
async function deduplicateEnums(config: AutorestContext, input: DataSource, sink: DataSink) {
|
|
@ -1,7 +1,7 @@
|
|||
import { DataHandle, QuickDataSource, mergePipeStates } from "@azure-tools/datastore";
|
||||
import { Channel, Message } from "../../message";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutoRestExtension } from "../plugin-endpoint";
|
||||
import { Channel, Message } from "../message";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { AutoRestExtension } from "../pipeline/plugin-endpoint";
|
||||
|
||||
/* @internal */
|
||||
export function createExternalPlugin(host: AutoRestExtension, pluginName: string): PipelinePlugin {
|
|
@ -4,8 +4,8 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { QuickDataSource } from "@azure-tools/datastore";
|
||||
import { Help } from "../../../help";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { Help } from "../../help";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
/* @internal */
|
||||
export function createHelpPlugin(): PipelinePlugin {
|
|
@ -1,4 +1,4 @@
|
|||
import { PipelinePlugin } from "../../common";
|
||||
import { PipelinePlugin } from "../../pipeline/common";
|
||||
import { QuickDataSource } from "@azure-tools/datastore";
|
||||
|
||||
export function createIdentityPlugin(): PipelinePlugin {
|
|
@ -1,6 +1,6 @@
|
|||
import { createDataHandle } from "@autorest/test-utils";
|
||||
import { CancellationTokenSource, DataHandle, DataSink, DataStore, QuickDataSource } from "@azure-tools/datastore";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { createNormalizeIdentityPlugin } from "./normalize-identity-plugin";
|
||||
|
||||
describe("NormalizeIdentityPlugin", () => {
|
|
@ -1,8 +1,8 @@
|
|||
import { DataHandle, DataSink, DataSource, QuickDataSource, visit } from "@azure-tools/datastore";
|
||||
import { parseJsonRef, stringifyJsonRef, updateJsonRefs } from "@azure-tools/jsonschema";
|
||||
import { cloneDeep } from "lodash";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { PipelinePlugin } from "../../common";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../../pipeline/common";
|
||||
import { URL } from "url";
|
||||
import { relative, dirname, basename } from "path";
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { createDataHandle } from "@autorest/test-utils";
|
||||
import { CancellationTokenSource, DataHandle, DataSink, DataStore, QuickDataSource } from "@azure-tools/datastore";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { createIdentityResetPlugin } from "./reset-identity-plugin";
|
||||
|
||||
describe("ResetIdentityPlugin", () => {
|
|
@ -1,5 +1,5 @@
|
|||
import { PipelinePlugin } from "../../common";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { PipelinePlugin } from "../../pipeline/common";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { DataSource, DataSink, DataHandle, QuickDataSource } from "@azure-tools/datastore";
|
||||
import { uniqBy } from "lodash";
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
import { createCommonmarkProcessorPlugin } from "./commonmark";
|
||||
import { createAllOfCleaner } from "./allof-cleaner";
|
||||
import { createCommandPlugin } from "./command";
|
||||
|
||||
import { createComponentKeyRenamerPlugin } from "./component-key-renamer";
|
||||
import { createComponentsCleanerPlugin } from "./components-cleaner";
|
||||
import { createSwaggerToOpenApi3Plugin } from "./conversion";
|
||||
import { createDeduplicatorPlugin } from "./deduplicator";
|
||||
import { createArtifactEmitterPlugin } from "./emitter";
|
||||
import { createEnumDeduplicator } from "./enum-deduplication";
|
||||
import { createHelpPlugin } from "./help";
|
||||
import {
|
||||
createIdentityPlugin,
|
||||
createIdentityResetPlugin,
|
||||
createNormalizeIdentityPlugin,
|
||||
createNullPlugin,
|
||||
} from "./identity";
|
||||
import { createOpenApiLoaderPlugin, createSwaggerLoaderPlugin } from "./loaders";
|
||||
import { createMultiApiMergerPlugin } from "./merger";
|
||||
import { createNewComposerPlugin } from "./new-composer";
|
||||
import { createProfileFilterPlugin } from "./profile-filter";
|
||||
import { createQuickCheckPlugin } from "./quick-check";
|
||||
import { subsetSchemaDeduplicatorPlugin } from "./subset-schemas-deduplicator";
|
||||
import {
|
||||
createImmediateTransformerPlugin,
|
||||
createTextTransformerPlugin,
|
||||
createTransformerPlugin,
|
||||
createGraphTransformerPlugin,
|
||||
} from "./transformer";
|
||||
import { createTreeShakerPlugin } from "./tree-shaker/tree-shaker";
|
||||
import { createApiVersionParameterHandlerPlugin } from "./version-param-handler";
|
||||
import { createJsonToYamlPlugin, createYamlToJsonPlugin } from "./yaml-and-json";
|
||||
import { createOpenApiSchemaValidatorPlugin, createSwaggerSchemaValidatorPlugin } from "./schema-validation";
|
||||
import { createOpenAPIStatsCollectorPlugin } from "./openapi-stats-collector";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { QuickDataSource } from "@azure-tools/datastore";
|
||||
import { createCSharpReflectApiVersionPlugin } from "./metadata-generation";
|
||||
import { createComponentModifierPlugin } from "./component-modifier";
|
||||
|
||||
export const PLUGIN_MAP: { [name: string]: PipelinePlugin } = {
|
||||
"help": createHelpPlugin(),
|
||||
"identity": createIdentityPlugin(),
|
||||
"null": createNullPlugin(),
|
||||
"reset-identity": createIdentityResetPlugin(),
|
||||
"normalize-identity": createNormalizeIdentityPlugin(),
|
||||
"loader-swagger": createSwaggerLoaderPlugin(),
|
||||
"loader-openapi": createOpenApiLoaderPlugin(),
|
||||
"openapi-stats-collector": createOpenAPIStatsCollectorPlugin(),
|
||||
"transform": createTransformerPlugin(),
|
||||
"text-transform": createTextTransformerPlugin(),
|
||||
"new-transform": createGraphTransformerPlugin(),
|
||||
"transform-immediate": createImmediateTransformerPlugin(),
|
||||
"compose": createNewComposerPlugin(),
|
||||
"schema-validator-openapi": createOpenApiSchemaValidatorPlugin(),
|
||||
"schema-validator-swagger": createSwaggerSchemaValidatorPlugin(),
|
||||
// TODO: replace with OAV again
|
||||
"semantic-validator": createIdentityPlugin(),
|
||||
"openapi-document-converter": createSwaggerToOpenApi3Plugin(),
|
||||
"component-modifiers": createComponentModifierPlugin(),
|
||||
"yaml2jsonx": createYamlToJsonPlugin(),
|
||||
"jsonx2yaml": createJsonToYamlPlugin(),
|
||||
"reflect-api-versions-cs": createCSharpReflectApiVersionPlugin(),
|
||||
"commonmarker": createCommonmarkProcessorPlugin(),
|
||||
"profile-definition-emitter": createArtifactEmitterPlugin(),
|
||||
"emitter": createArtifactEmitterPlugin(),
|
||||
"configuration-emitter": createArtifactEmitterPlugin(
|
||||
async (context) =>
|
||||
new QuickDataSource([
|
||||
await context.DataStore.getDataSink().writeObject(
|
||||
"configuration",
|
||||
context.config.raw,
|
||||
["fix-me-4"],
|
||||
"configuration",
|
||||
),
|
||||
]),
|
||||
),
|
||||
"tree-shaker": createTreeShakerPlugin(),
|
||||
"enum-deduplicator": createEnumDeduplicator(),
|
||||
"quick-check": createQuickCheckPlugin(),
|
||||
"model-deduplicator": createDeduplicatorPlugin(),
|
||||
"subset-reducer": subsetSchemaDeduplicatorPlugin(),
|
||||
"multi-api-merger": createMultiApiMergerPlugin(),
|
||||
"components-cleaner": createComponentsCleanerPlugin(),
|
||||
"component-key-renamer": createComponentKeyRenamerPlugin(),
|
||||
"api-version-parameter-handler": createApiVersionParameterHandlerPlugin(),
|
||||
"profile-filter": createProfileFilterPlugin(),
|
||||
"allof-cleaner": createAllOfCleaner(),
|
||||
"command": createCommandPlugin(),
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
import { Channel, SourceLocation } from "../../../message";
|
||||
import { Channel, SourceLocation } from "../../message";
|
||||
import { DataHandle, IndexToPosition, StrictJsonSyntaxCheck } from "@azure-tools/datastore";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { AutorestContext } from "../../context";
|
||||
|
||||
/**
|
||||
* If a JSON file is provided, it checks that the syntax is correct.
|
|
@ -1,11 +1,11 @@
|
|||
import { PipelinePlugin } from "../../common";
|
||||
import { PipelinePlugin } from "../../pipeline/common";
|
||||
|
||||
import { Channel } from "../../../message";
|
||||
import { Channel } from "../../message";
|
||||
import { parse as ParseLiterateYaml } from "@autorest/common";
|
||||
import { CloneAst, DataHandle, DataSink, DataSource, QuickDataSource, StringifyAst } from "@azure-tools/datastore";
|
||||
import { identitySourceMapping } from "@autorest/common";
|
||||
import { crawlReferences } from "../ref-crawling";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { checkSyntaxFromData } from "./common";
|
||||
|
||||
interface OpenAPI3Spec {
|
|
@ -1,11 +1,11 @@
|
|||
import { PipelinePlugin } from "../../common";
|
||||
import { PipelinePlugin } from "../../pipeline/common";
|
||||
|
||||
import { Channel } from "../../../message";
|
||||
import { Channel } from "../../message";
|
||||
import { parse as ParseLiterateYaml } from "@autorest/common";
|
||||
import { CloneAst, DataHandle, DataSink, DataSource, QuickDataSource, StringifyAst } from "@azure-tools/datastore";
|
||||
import { identitySourceMapping } from "@autorest/common";
|
||||
import { crawlReferences } from "../ref-crawling";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { checkSyntaxFromData } from "./common";
|
||||
|
||||
export async function LoadLiterateSwaggers(
|
|
@ -12,8 +12,8 @@ import {
|
|||
import { clone, Dictionary, values, visitor } from "@azure-tools/linq";
|
||||
|
||||
import * as oai from "@azure-tools/openapi";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
/**
|
||||
* Takes multiple input OAI3 files and creates one merged one.
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { QuickDataSource } from "@azure-tools/datastore";
|
||||
import { PipelinePlugin } from "./common";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
/* @internal */
|
||||
export function createCSharpReflectApiVersionPlugin(): PipelinePlugin {
|
|
@ -10,10 +10,10 @@ import {
|
|||
} from "@azure-tools/datastore";
|
||||
import { values, Dictionary } from "@azure-tools/linq";
|
||||
import { areSimilar } from "@azure-tools/object-comparison";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { maximum, toSemver } from "@azure-tools/codegen";
|
||||
import compareVersions from "compare-versions";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { AutorestContext } from "../context";
|
||||
|
||||
/**
|
||||
* Prepares an OpenAPI document for the generation-2 code generators
|
|
@ -1,6 +1,6 @@
|
|||
import { DataSource } from "@azure-tools/datastore";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { PipelinePlugin } from "../../common";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../../pipeline/common";
|
||||
import * as oai3 from "@azure-tools/openapi";
|
||||
|
||||
export async function collectOpenAPIStats(context: AutorestContext, dataSource: DataSource) {
|
|
@ -20,8 +20,8 @@ import {
|
|||
} from "@azure-tools/datastore";
|
||||
import { Dictionary, items, values } from "@azure-tools/linq";
|
||||
import * as oai from "@azure-tools/openapi";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
type componentType =
|
||||
| "schemas"
|
|
@ -9,10 +9,10 @@ import {
|
|||
QuickDataSource,
|
||||
} from "@azure-tools/datastore";
|
||||
import { items } from "@azure-tools/linq";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { format } from "path";
|
||||
import { Channel } from "../../message";
|
||||
import { Channel } from "../message";
|
||||
|
||||
async function quickCheck(config: AutorestContext, input: DataSource, sink: DataSink) {
|
||||
const inputs = await Promise.all((await input.Enum()).map(async (x) => input.ReadStrict(x)));
|
|
@ -1,7 +1,7 @@
|
|||
import { AnyObject, DataHandle, DataSink, DataSource, Node, Transformer, visit } from "@azure-tools/datastore";
|
||||
import { resolveUri } from "@azure-tools/uri";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { Channel } from "../../message";
|
||||
import { AutorestContext } from "../context";
|
||||
import { Channel } from "../message";
|
||||
import { values, items, length } from "@azure-tools/linq";
|
||||
|
||||
export async function crawlReferences(
|
|
@ -4,9 +4,9 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
import { DataHandle } from "@azure-tools/datastore";
|
||||
import { OperationAbortedException } from "@autorest/common";
|
||||
import { Channel } from "../../../message";
|
||||
import { createPerFilePlugin, PipelinePlugin } from "../../common";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { Channel } from "../../message";
|
||||
import { createPerFilePlugin, PipelinePlugin } from "../../pipeline/common";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { SwaggerSchemaValidator } from "./swagger-schema-validator";
|
||||
import { PositionedValidationError } from "./json-schema-validator";
|
||||
import { OpenApi3SchemaValidator } from "./openapi3-schema-validator";
|
|
@ -12,10 +12,10 @@ import {
|
|||
import { clone, Dictionary, values } from "@azure-tools/linq";
|
||||
import { areSimilar } from "@azure-tools/object-comparison";
|
||||
import * as oai from "@azure-tools/openapi";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { toSemver, maximum, gt, lt } from "@azure-tools/codegen";
|
||||
import { Channel } from "../../message";
|
||||
import { Channel } from "../message";
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-use-before-define */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { createSandbox, JsonPath } from "@azure-tools/datastore";
|
||||
import { AutorestContext } from "../../../autorest-core";
|
||||
import { Channel } from "../../../message";
|
||||
import { AutorestContext } from "../../autorest-core";
|
||||
import { Channel } from "../../message";
|
||||
|
||||
const safeEval = createSandbox();
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
import { DataHandle, DataSink, nodes } from "@azure-tools/datastore";
|
||||
import { YieldCPU } from "@azure-tools/tasks";
|
||||
import { AutorestContext } from "../../../autorest-core";
|
||||
import { Channel, Message, SourceLocation } from "../../../message";
|
||||
import { AutorestContext } from "../../autorest-core";
|
||||
import { Channel, Message, SourceLocation } from "../../message";
|
||||
import { manipulateObject } from "./object-manipulator";
|
||||
import { values } from "@azure-tools/linq";
|
||||
import { evalDirectiveTest, evalDirectiveTransform } from "./eval";
|
|
@ -19,8 +19,8 @@ import {
|
|||
ToAst,
|
||||
YAMLNode,
|
||||
} from "@azure-tools/datastore";
|
||||
import { AutorestContext } from "../../../autorest-core";
|
||||
import { Channel } from "../../../message";
|
||||
import { AutorestContext } from "../../autorest-core";
|
||||
import { Channel } from "../../message";
|
||||
import { identitySourceMapping } from "@autorest/common";
|
||||
|
||||
export async function manipulateObject(
|
|
@ -1,7 +1,7 @@
|
|||
import { QuickDataSource, DataHandle, AnyObject, selectNodes } from "@azure-tools/datastore";
|
||||
import { createPerFilePlugin, PipelinePlugin } from "../../common";
|
||||
import { createPerFilePlugin, PipelinePlugin } from "../../pipeline/common";
|
||||
import { Manipulator } from "./manipulation";
|
||||
import { Channel } from "../../../message";
|
||||
import { Channel } from "../../message";
|
||||
import { evalDirectiveTransform } from "./eval";
|
||||
import { resolveDirectives } from "@autorest/configuration";
|
||||
|
|
@ -11,11 +11,11 @@ import {
|
|||
JsonPath,
|
||||
Source,
|
||||
} from "@azure-tools/datastore";
|
||||
import { AutorestContext } from "../../../context";
|
||||
import { PipelinePlugin } from "../../common";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../../pipeline/common";
|
||||
import { values, length } from "@azure-tools/linq";
|
||||
import { createHash } from "crypto";
|
||||
import { SchemaStats } from "../../../stats";
|
||||
import { SchemaStats } from "../../stats";
|
||||
|
||||
/**
|
||||
* parses a json pointer, and inserts a string into the returned array
|
|
@ -11,8 +11,8 @@ import {
|
|||
} from "@azure-tools/datastore";
|
||||
import { clone, Dictionary } from "@azure-tools/linq";
|
||||
import * as oai from "@azure-tools/openapi";
|
||||
import { AutorestContext } from "../../context";
|
||||
import { PipelinePlugin } from "../common";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
export class ApiVersionParameterHandler extends Transformer<any, oai.Model> {
|
||||
// oldRefs -> newRefs;
|
|
@ -1,5 +1,5 @@
|
|||
import { ConvertJsonx2Yaml, ConvertYaml2Jsonx, StringifyAst } from "@azure-tools/datastore";
|
||||
import { createPerFilePlugin, PipelinePlugin } from "../common";
|
||||
import { createPerFilePlugin, PipelinePlugin } from "../pipeline/common";
|
||||
|
||||
/* @internal */
|
||||
export function createYamlToJsonPlugin(): PipelinePlugin {
|
|
@ -5,7 +5,7 @@
|
|||
import { CancellationToken } from "vscode-jsonrpc";
|
||||
import assert from "assert";
|
||||
import { DataStore } from "@azure-tools/datastore";
|
||||
import { manipulateObject } from "../src/lib/pipeline/plugins/transformer/object-manipulator";
|
||||
import { manipulateObject } from "../src/lib/plugins/transformer/object-manipulator";
|
||||
import { createSandbox } from "@azure-tools/datastore";
|
||||
|
||||
const safeEval = createSandbox();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import assert from "assert";
|
||||
import { AutoRest } from "../src/lib/autorest-core";
|
||||
import { RealFileSystem } from "@azure-tools/datastore";
|
||||
import { LoadLiterateOpenAPIs } from "../src/lib/pipeline/plugins/loaders";
|
||||
import { LoadLiterateOpenAPIs } from "../src/lib/plugins/loaders";
|
||||
import { CreateFolderUri, ResolveUri } from "@azure-tools/uri";
|
||||
import { AppRoot } from "../src/lib/constants";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ComponentsCleaner } from "../../../src/lib/pipeline/plugins/components-cleaner";
|
||||
import { ComponentsCleaner } from "../../../src/lib/plugins/components-cleaner";
|
||||
import fs from "fs";
|
||||
import { CancellationTokenSource, DataStore, MemoryFileSystem } from "@azure-tools/datastore";
|
||||
import assert from "assert";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MultiAPIMerger } from "../../../src/lib/pipeline/plugins/merger";
|
||||
import { MultiAPIMerger } from "../../../src/lib/plugins/merger";
|
||||
import fs from "fs";
|
||||
import { createDataHandle } from "@autorest/test-utils";
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import * as aio from "@azure-tools/async-io";
|
||||
import * as datastore from "@azure-tools/datastore";
|
||||
import assert from "assert";
|
||||
import { ComponentKeyRenamer } from "../src/lib/pipeline/plugins/component-key-renamer";
|
||||
import { ComponentKeyRenamer } from "../src/lib/plugins/component-key-renamer";
|
||||
|
||||
const resources = `${__dirname}../../../test/resources/renamer`;
|
||||
|
||||
describe("ComponentRenaming", () => {
|
||||
// todo: fix test
|
||||
xit("Replace component keys for actual names.", async () => {
|
||||
it.skip("Replace component keys for actual names.", async () => {
|
||||
const inputUri = "mem://input.json";
|
||||
const outputUri = "mem://output.json";
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
getSubsetSchema,
|
||||
getSupersetSchema,
|
||||
SubsetSchemaDeduplicator,
|
||||
} from "../src/lib/pipeline/plugins/subset-schemas-deduplicator";
|
||||
} from "../src/lib/plugins/subset-schemas-deduplicator";
|
||||
|
||||
const resources = `${__dirname}../../../test/resources/subset-deduplication`;
|
||||
|
||||
|
@ -15,7 +15,7 @@ const skipList = ["description", "enum", "readOnly", "required"];
|
|||
const expandableFieldsList = ["properties", "allOf"];
|
||||
|
||||
describe("SubsetDeduplication", () => {
|
||||
xit("subset check function", async () => {
|
||||
it.skip("subset check function", async () => {
|
||||
const input = JSON.parse(await aio.readFile(`${resources}/schema1.json`));
|
||||
const input2 = JSON.parse(await aio.readFile(`${resources}/schema2.json`));
|
||||
const input3 = JSON.parse(await aio.readFile(`${resources}/schema3.json`));
|
||||
|
@ -29,7 +29,7 @@ describe("SubsetDeduplication", () => {
|
|||
assert.deepStrictEqual(result2, expected2);
|
||||
});
|
||||
|
||||
xit("superset schema construction", async () => {
|
||||
it.skip("superset schema construction", async () => {
|
||||
const input = JSON.parse(await aio.readFile(`${resources}/schema1.json`));
|
||||
const input2 = JSON.parse(await aio.readFile(`${resources}/schema2.json`));
|
||||
const checkResult1 = JSON.parse(await aio.readFile(`${resources}/expected-check-result1.json`));
|
||||
|
@ -39,7 +39,7 @@ describe("SubsetDeduplication", () => {
|
|||
assert.deepStrictEqual(result1, updatedSchema2);
|
||||
});
|
||||
|
||||
xit("subset schema construction", async () => {
|
||||
it.skip("subset schema construction", async () => {
|
||||
const input = JSON.parse(await aio.readFile(`${resources}/schema1.json`));
|
||||
const input2 = JSON.parse(await aio.readFile(`${resources}/schema2.json`));
|
||||
const checkResult1 = JSON.parse(await aio.readFile(`${resources}/expected-check-result1.json`));
|
||||
|
@ -49,7 +49,7 @@ describe("SubsetDeduplication", () => {
|
|||
assert.deepStrictEqual(result1, updatedSchema2);
|
||||
});
|
||||
|
||||
xit("subset deduplication in spec", async () => {
|
||||
it.skip("subset deduplication in spec", async () => {
|
||||
const inputUri = "mem://input1.json";
|
||||
const outputUri = "mem://output1.json";
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import assert from "assert";
|
|||
import { RealFileSystem } from "@azure-tools/datastore";
|
||||
import { CreateFolderUri, ResolveUri } from "@azure-tools/uri";
|
||||
import { AutoRest } from "../src/lib/autorest-core";
|
||||
import { LoadLiterateSwaggers } from "../src/lib/pipeline/plugins/loaders";
|
||||
import { LoadLiterateSwaggers } from "../src/lib/plugins/loaders";
|
||||
import { AppRoot } from "../src/lib/constants";
|
||||
|
||||
describe("SwaggerLoading", () => {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import * as aio from "@azure-tools/async-io";
|
||||
import * as datastore from "@azure-tools/datastore";
|
||||
import assert from "assert";
|
||||
import { ApiVersionParameterHandler } from "../src/lib/pipeline/plugins/version-param-handler";
|
||||
import { ApiVersionParameterHandler } from "../src/lib/plugins/version-param-handler";
|
||||
|
||||
const resources = `${__dirname}../../../test/resources/version-param-handler`;
|
||||
|
||||
describe("ApiVersionParameterHandling", () => {
|
||||
/* todo: fix test */
|
||||
xit("Remove api-version global parameter, remove references to said parameter and add metadata.", async () => {
|
||||
it.skip("Remove api-version global parameter, remove references to said parameter and add metadata.", async () => {
|
||||
const inputUri = "mem://input.json";
|
||||
const outputUri = "mem://output.json";
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче