зеркало из https://github.com/Azure/autorest.git
Remove `quick-check` plugin (#4225)
* Remove quick check plugin * ADd changes
This commit is contained in:
Родитель
08b1953292
Коммит
e60e4e0866
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@autorest/configuration",
|
||||
"comment": "**Remove** quick-check plugin from defautl configuration",
|
||||
"type": "minor"
|
||||
}
|
||||
],
|
||||
"packageName": "@autorest/configuration",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@autorest/core",
|
||||
"comment": "**Remove** quick-check plugin",
|
||||
"type": "minor"
|
||||
}
|
||||
],
|
||||
"packageName": "@autorest/core",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -19,7 +19,6 @@ 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,
|
||||
|
@ -75,7 +74,6 @@ export const CORE_PLUGIN_MAP = {
|
|||
),
|
||||
"tree-shaker": createTreeShakerPlugin(),
|
||||
"enum-deduplicator": createEnumDeduplicator(),
|
||||
"quick-check": createQuickCheckPlugin(),
|
||||
"model-deduplicator": createDeduplicatorPlugin(),
|
||||
"subset-reducer": subsetSchemaDeduplicatorPlugin(),
|
||||
"multi-api-merger": createMultiApiMergerPlugin(),
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
import {
|
||||
AnyObject,
|
||||
DataHandle,
|
||||
DataSink,
|
||||
DataSource,
|
||||
Node,
|
||||
parseJsonPointer,
|
||||
Processor,
|
||||
QuickDataSource,
|
||||
} from "@azure-tools/datastore";
|
||||
import { items } from "@azure-tools/linq";
|
||||
import { AutorestContext } from "../context";
|
||||
import { PipelinePlugin } from "../pipeline/common";
|
||||
import { format } from "path";
|
||||
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)));
|
||||
for (const each of inputs) {
|
||||
const oai = await each.ReadObject<AnyObject>();
|
||||
|
||||
const models = new Map<string, Array<string>>();
|
||||
const enums = new Map<string, Array<string>>();
|
||||
// check to see if there are models with the same name
|
||||
for (const { key, value } of items(oai.components?.schemas)) {
|
||||
const schema = <AnyObject>value;
|
||||
const name = (<AnyObject>value)["x-ms-metadata"].name.toLowerCase();
|
||||
|
||||
if ((schema.type === "string" || schema.type === undefined) && schema.enum && schema.enum.length > 1) {
|
||||
// it's an enum
|
||||
if (!enums.has(name)) {
|
||||
enums.set(name, []);
|
||||
}
|
||||
(enums.get(name) || []).push(key);
|
||||
}
|
||||
|
||||
if (!schema.type || schema.type === "object") {
|
||||
// it's a model
|
||||
if (!models.has(name)) {
|
||||
models.set(name, []);
|
||||
}
|
||||
(models.get(name) || []).push(key);
|
||||
}
|
||||
}
|
||||
const failed = false;
|
||||
for (const { key, value } of items(models)) {
|
||||
if (value.length > 1) {
|
||||
//failed = true;
|
||||
// console.error(`Model ${key} has multiple implementations: ${value.join(',')}`);
|
||||
}
|
||||
}
|
||||
// console.error('--------------------------------------------------------------------');
|
||||
for (const { key, value } of items(enums)) {
|
||||
if (value.length > 1) {
|
||||
//failed = true;
|
||||
config.Message({
|
||||
Text: `Enum ${key} has multiple unmerged implementations: ${value.join(",")}`,
|
||||
Channel: Channel.Error,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (failed) {
|
||||
throw new Error("Detected Collisions.");
|
||||
}
|
||||
}
|
||||
|
||||
const result: Array<DataHandle> = [];
|
||||
|
||||
return new QuickDataSource(result, input.pipeState);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function createQuickCheckPlugin(): PipelinePlugin {
|
||||
return quickCheck;
|
||||
}
|
|
@ -51,9 +51,6 @@ pipeline:
|
|||
openapi-document/subset-reducer:
|
||||
input: enum-deduplicator
|
||||
|
||||
openapi-document/quick-check:
|
||||
input: subset-reducer
|
||||
|
||||
openapi-document/multi-api/reset-identity:
|
||||
input: subset-reducer
|
||||
to: openapi-document
|
||||
|
|
Загрузка…
Ссылка в новой задаче