зеркало из https://github.com/Azure/autorest.git
Fix tree shaked number enum to follow same logic as string enums (#4100)
This commit is contained in:
Родитель
6d994fd0a5
Коммит
8579200012
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@autorest/configuration",
|
||||
"comment": "",
|
||||
"type": "none"
|
||||
}
|
||||
],
|
||||
"packageName": "@autorest/configuration",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@autorest/core",
|
||||
"comment": "**Fix** Tree Shaking number enums same as string enum. This allows those enum to get a better auto generated name if no name is provided",
|
||||
"type": "patch"
|
||||
}
|
||||
],
|
||||
"packageName": "@autorest/core",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -179,7 +179,6 @@ async function currentMain(autorestArgs: Array<string>): Promise<number> {
|
|||
|
||||
const logger = new RootLogger();
|
||||
const args = parseAutorestCliArgs([...autorestArgs, ...more], { logger });
|
||||
console.error("Try require", more, args);
|
||||
|
||||
if (!args.options["message-format"] || args.options["message-format"] === "regular") {
|
||||
console.log(color(`> Loading AutoRest core '${__dirname}' (${VERSION})`));
|
||||
|
|
|
@ -101,7 +101,7 @@ export class AutorestContextLoader {
|
|||
...configs: AutorestRawConfiguration[]
|
||||
): Promise<AutorestContext> {
|
||||
const logger: AutorestLogger = new AutorestCoreLogger(
|
||||
mergeConfigurations(...configs) as any,
|
||||
mergeConfigurations(configs) as any,
|
||||
messageEmitter,
|
||||
AutorestLoggingSession,
|
||||
);
|
||||
|
|
|
@ -5,7 +5,6 @@ import {
|
|||
DataSink,
|
||||
DataSource,
|
||||
Node,
|
||||
parseJsonPointer,
|
||||
Transformer,
|
||||
QuickDataSource,
|
||||
JsonPath,
|
||||
|
@ -16,6 +15,7 @@ import { PipelinePlugin } from "../../pipeline/common";
|
|||
import { values, length } from "@azure-tools/linq";
|
||||
import { createHash } from "crypto";
|
||||
import { SchemaStats } from "../../stats";
|
||||
import { parseJsonPointer } from "@azure-tools/json";
|
||||
|
||||
/**
|
||||
* parses a json pointer, and inserts a string into the returned array
|
||||
|
@ -509,11 +509,13 @@ export class OAI3Shaker extends Transformer<AnyObject, AnyObject> {
|
|||
|
||||
visitProperties(targetParent: AnyObject, originalNodes: Iterable<Node>, requiredProperties: Array<string>) {
|
||||
for (const { value, key, pointer, children } of originalNodes) {
|
||||
// if the property has a schema that type 'boolean', 'integer', 'number' then we'll just leave it inline
|
||||
// we will leave strings inlined only if they ask for simple-tree-shake. Also, if it's a string + enum + required + single val enum
|
||||
// if the property has a schema that type 'boolean' then we'll just leave it inline
|
||||
// we will leave strings, number and integer inlined only if they ask for simple-tree-shake. Also, if it's a string + enum + required + single val enum
|
||||
// reason: old modeler does not handle non-inlined string properties.
|
||||
switch (value.type) {
|
||||
case "string":
|
||||
case "integer":
|
||||
case "number":
|
||||
if (this.isSimpleTreeShake) {
|
||||
this.clone(targetParent, key, pointer, value);
|
||||
} else {
|
||||
|
@ -532,8 +534,6 @@ export class OAI3Shaker extends Transformer<AnyObject, AnyObject> {
|
|||
}
|
||||
break;
|
||||
case "boolean":
|
||||
case "integer":
|
||||
case "number":
|
||||
this.clone(targetParent, key, pointer, value);
|
||||
break;
|
||||
case "array":
|
||||
|
|
|
@ -22,7 +22,9 @@ export function parseAutorestCliArgs(cliArgs: string[], options: ParseAutorestCl
|
|||
const configFileOrFolder = parsedArgs.positional[0];
|
||||
|
||||
const optionsAsObjects = parsedArgs.optionList.map(({ key, value }) => CreateObject(key.split("."), value));
|
||||
const config = mergeConfigurations(AUTOREST_INITIAL_CONFIG, ...optionsAsObjects);
|
||||
const config = mergeConfigurations([AUTOREST_INITIAL_CONFIG, ...optionsAsObjects.reverse()], {
|
||||
arrayMergeStrategy: "low-pri-first",
|
||||
});
|
||||
const result = autorestConfigurationProcessor.processConfiguration(config, {
|
||||
logger: options.logger,
|
||||
});
|
||||
|
|
|
@ -110,7 +110,7 @@ export const extendAutorestConfiguration = (
|
|||
config: AutorestConfiguration,
|
||||
overrides: AutorestNormalizedConfiguration[],
|
||||
): AutorestConfiguration => {
|
||||
const rawConfig = mergeConfigurations(...overrides, config.raw);
|
||||
const rawConfig = mergeConfigurations([...overrides, config.raw]);
|
||||
const newConfig = createConfigFromRawConfig(config.configFileFolderUri, rawConfig, config.configurationFiles);
|
||||
newConfig.inputFileUris = config.inputFileUris;
|
||||
return newConfig;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { mergeOverwriteOrAppend } from "@autorest/common";
|
||||
import { MergeOptions, mergeOverwriteOrAppend } from "@autorest/common";
|
||||
|
||||
export function mergeConfigurations<T>(...configs: Array<T>): T {
|
||||
return configs.reduce((result, config) => mergeOverwriteOrAppend(result, config), {}) as T;
|
||||
export function mergeConfigurations<T>(configs: Array<T>, options: MergeOptions = {}): T {
|
||||
return configs.reduce((result, config) => mergeOverwriteOrAppend(result, config), options) as T;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче