diff --git a/common/changes/@autorest/configuration/patch-1_2021-09-18-00-38.json b/common/changes/@autorest/configuration/patch-1_2021-09-18-00-38.json deleted file mode 100644 index c1a314f17..000000000 --- a/common/changes/@autorest/configuration/patch-1_2021-09-18-00-38.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "changes": [ - { - "packageName": "@autorest/configuration", - "comment": "Added missing help text for command line arguments", - "type": "patch" - } - ], - "packageName": "@autorest/configuration", - "email": "chlowe@microsoft.com" -} \ No newline at end of file diff --git a/eng/pipelines/templates/regression-tests.yaml b/eng/pipelines/templates/regression-tests.yaml index 788e0c201..909a6621d 100644 --- a/eng/pipelines/templates/regression-tests.yaml +++ b/eng/pipelines/templates/regression-tests.yaml @@ -46,7 +46,12 @@ jobs: npm link --force displayName: Install autorest-compare - - script: npm install + - script: | + npm install + + echo "Autorest TestServer Version" + npm ls "@microsoft.azure/autorest.testserver" + displayName: Install dependencies workingDirectory: regression-tests diff --git a/packages/apps/autorest/package.json b/packages/apps/autorest/package.json index 39fd0a16e..1f81f9c4a 100644 --- a/packages/apps/autorest/package.json +++ b/packages/apps/autorest/package.json @@ -40,8 +40,8 @@ }, "typings": "./dist/exports.d.ts", "devDependencies": { - "@autorest/configuration": "~1.7.0", - "@autorest/core": "~3.6.2", + "@autorest/configuration": "~1.7.2", + "@autorest/core": "~3.6.3", "@autorest/common": "~1.3.0", "@azure-tools/async-io": "~3.0.0", "@azure-tools/extension": "~3.3.1", diff --git a/packages/extensions/core/CHANGELOG.json b/packages/extensions/core/CHANGELOG.json index 1bd7a2c5c..edf6260b5 100644 --- a/packages/extensions/core/CHANGELOG.json +++ b/packages/extensions/core/CHANGELOG.json @@ -1,6 +1,23 @@ { "name": "@autorest/core", "entries": [ + { + "version": "3.6.3", + "tag": "@autorest/core_v3.6.3", + "date": "Thu, 23 Sep 2021 19:51:32 GMT", + "comments": { + "patch": [ + { + "comment": "**Added** `include-x-ms-examples-original-file` flag to activate `x-ms-original-file` injection in `x-ms-examples`" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@autorest/configuration\" from `~1.7.1` to `~1.7.2`" + } + ] + } + }, { "version": "3.6.2", "tag": "@autorest/core_v3.6.2", diff --git a/packages/extensions/core/CHANGELOG.md b/packages/extensions/core/CHANGELOG.md index 0f3f0b6f4..acaf79f39 100644 --- a/packages/extensions/core/CHANGELOG.md +++ b/packages/extensions/core/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @autorest/core -This log was last generated on Fri, 17 Sep 2021 17:52:01 GMT and should not be manually modified. +This log was last generated on Thu, 23 Sep 2021 19:51:32 GMT and should not be manually modified. + +## 3.6.3 +Thu, 23 Sep 2021 19:51:32 GMT + +### Patches + +- **Added** `include-x-ms-examples-original-file` flag to activate `x-ms-original-file` injection in `x-ms-examples` ## 3.6.2 Fri, 17 Sep 2021 17:52:01 GMT diff --git a/packages/extensions/core/package.json b/packages/extensions/core/package.json index a0cbf7004..759133595 100644 --- a/packages/extensions/core/package.json +++ b/packages/extensions/core/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/core", - "version": "3.6.2", + "version": "3.6.3", "description": "AutoRest core module", "engines": { "node": ">=12.0.0" @@ -43,7 +43,7 @@ "typings": "./dist/exports.d.ts", "devDependencies": { "@autorest/common": "~1.3.0", - "@autorest/configuration": "~1.7.0", + "@autorest/configuration": "~1.7.2", "@autorest/schemas": "~1.3.1", "@autorest/test-utils": "~0.4.0", "@azure-tools/async-io": "~3.0.0", diff --git a/packages/extensions/core/src/lib/plugins/ref-crawling.ts b/packages/extensions/core/src/lib/plugins/ref-crawling.ts index d0b4be95d..b36b4042f 100644 --- a/packages/extensions/core/src/lib/plugins/ref-crawling.ts +++ b/packages/extensions/core/src/lib/plugins/ref-crawling.ts @@ -1,10 +1,9 @@ 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"; export async function crawlReferences( - config: AutorestContext, + context: AutorestContext, inputScope: DataSource, filesToCrawl: Array, sink: DataSink, @@ -21,13 +20,15 @@ export async function crawlReferences( /** crawls a file for $refs and then recurses to get the $ref'd files */ async function crawl(file: DataHandle) { - const refProcessor = new RefProcessor(file, inputScope); + const refProcessor = new RefProcessor(file, inputScope, { + includeXmsExamplesOriginalFileLocation: context.config["include-x-ms-examples-original-file"], + }); const output = await refProcessor.getOutput(); for (const fileUri of [...refProcessor.filesReferenced].filter((each) => !queued.has(each))) { queued.add(fileUri); - config.verbose(`Reading $ref'd file ${fileUri}`); + context.verbose(`Reading $ref'd file ${fileUri}`); const secondaryFile = await inputScope.readStrict(fileUri); // mark secondary files with a tag so that we don't process operations for them. @@ -77,12 +78,16 @@ export async function crawlReferences( return [...primary, ...secondary]; } +interface RefProcessorOptions { + includeXmsExamplesOriginalFileLocation?: boolean; +} + class RefProcessor extends Transformer { public promises = new Array>(); public filesReferenced = new Set(); private originalFileLocation: string; - constructor(originalFile: DataHandle, private inputScope: DataSource) { + constructor(originalFile: DataHandle, private inputScope: DataSource, private options: RefProcessorOptions = {}) { super(originalFile); this.originalFileLocation = resolveUri(originalFile.originalDirectory, originalFile.identity[0]); @@ -98,7 +103,9 @@ class RefProcessor extends Transformer { const refUri = resolveUri(this.originalFileLocation, refPath); const handle = await this.inputScope.readStrict(refUri); const exampleData = await handle.readObject(); - xmsExamples[key] = { ...exampleData, "x-ms-original-file": refUri }; + xmsExamples[key] = this.options.includeXmsExamplesOriginalFileLocation + ? { ...exampleData, "x-ms-original-file": refUri } + : exampleData; } catch { // skip examples that are not nice to us. } diff --git a/packages/extensions/modelerfour/CHANGELOG.json b/packages/extensions/modelerfour/CHANGELOG.json index 2f7e3f845..5715ce2db 100644 --- a/packages/extensions/modelerfour/CHANGELOG.json +++ b/packages/extensions/modelerfour/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@autorest/modelerfour", "entries": [ + { + "version": "4.21.2", + "tag": "@autorest/modelerfour_v4.21.2", + "date": "Wed, 22 Sep 2021 15:23:39 GMT", + "comments": { + "patch": [ + { + "comment": "**Fix** log error when using parameter with `content.` as not being supported" + } + ] + } + }, { "version": "4.21.1", "tag": "@autorest/modelerfour_v4.21.1", diff --git a/packages/extensions/modelerfour/CHANGELOG.md b/packages/extensions/modelerfour/CHANGELOG.md index 34952aeec..842274ab2 100644 --- a/packages/extensions/modelerfour/CHANGELOG.md +++ b/packages/extensions/modelerfour/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @autorest/modelerfour -This log was last generated on Thu, 16 Sep 2021 18:49:17 GMT and should not be manually modified. +This log was last generated on Wed, 22 Sep 2021 15:23:39 GMT and should not be manually modified. + +## 4.21.2 +Wed, 22 Sep 2021 15:23:39 GMT + +### Patches + +- **Fix** log error when using parameter with `content.` as not being supported ## 4.21.1 Thu, 16 Sep 2021 18:49:17 GMT diff --git a/packages/extensions/modelerfour/package.json b/packages/extensions/modelerfour/package.json index 62f2d16e0..12eeb9677 100644 --- a/packages/extensions/modelerfour/package.json +++ b/packages/extensions/modelerfour/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/modelerfour", - "version": "4.21.1", + "version": "4.21.2", "description": "AutoRest Modeler Version Four (component)", "directories": { "doc": "docs" diff --git a/packages/extensions/modelerfour/src/modeler/modelerfour.ts b/packages/extensions/modelerfour/src/modeler/modelerfour.ts index 6fae76378..a95e25fc7 100644 --- a/packages/extensions/modelerfour/src/modeler/modelerfour.ts +++ b/packages/extensions/modelerfour/src/modeler/modelerfour.ts @@ -2039,7 +2039,10 @@ export class ModelerFour { style: (parameter.style), explode: parameter.explode, } - : undefined, + : { + style: contentType as any, + explode: parameter.explode, + }, ), }, language: { diff --git a/packages/libs/configuration/CHANGELOG.json b/packages/libs/configuration/CHANGELOG.json index 266af9a1f..4ece0346a 100644 --- a/packages/libs/configuration/CHANGELOG.json +++ b/packages/libs/configuration/CHANGELOG.json @@ -1,6 +1,30 @@ { "name": "@autorest/configuration", "entries": [ + { + "version": "1.7.2", + "tag": "@autorest/configuration_v1.7.2", + "date": "Thu, 23 Sep 2021 19:51:32 GMT", + "comments": { + "patch": [ + { + "comment": "**Added** `include-x-ms-examples-original-file` flag to activate `x-ms-original-file` injection in `x-ms-examples`" + } + ] + } + }, + { + "version": "1.7.1", + "tag": "@autorest/configuration_v1.7.1", + "date": "Wed, 22 Sep 2021 15:23:39 GMT", + "comments": { + "patch": [ + { + "comment": "Added missing help text for command line arguments" + } + ] + } + }, { "version": "1.7.0", "tag": "@autorest/configuration_v1.7.0", diff --git a/packages/libs/configuration/CHANGELOG.md b/packages/libs/configuration/CHANGELOG.md index f5de4daa3..8e6bb04ec 100644 --- a/packages/libs/configuration/CHANGELOG.md +++ b/packages/libs/configuration/CHANGELOG.md @@ -1,6 +1,20 @@ # Change Log - @autorest/configuration -This log was last generated on Wed, 08 Sep 2021 15:39:22 GMT and should not be manually modified. +This log was last generated on Thu, 23 Sep 2021 19:51:32 GMT and should not be manually modified. + +## 1.7.2 +Thu, 23 Sep 2021 19:51:32 GMT + +### Patches + +- **Added** `include-x-ms-examples-original-file` flag to activate `x-ms-original-file` injection in `x-ms-examples` + +## 1.7.1 +Wed, 22 Sep 2021 15:23:39 GMT + +### Patches + +- Added missing help text for command line arguments ## 1.7.0 Wed, 08 Sep 2021 15:39:22 GMT diff --git a/packages/libs/configuration/package.json b/packages/libs/configuration/package.json index 70974b696..060577be3 100644 --- a/packages/libs/configuration/package.json +++ b/packages/libs/configuration/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/configuration", - "version": "1.7.0", + "version": "1.7.2", "description": "Autorest configuration", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/libs/configuration/src/autorest-normalized-configuration.ts b/packages/libs/configuration/src/autorest-normalized-configuration.ts index 2401eb089..a412c07c2 100644 --- a/packages/libs/configuration/src/autorest-normalized-configuration.ts +++ b/packages/libs/configuration/src/autorest-normalized-configuration.ts @@ -86,6 +86,11 @@ export interface AutorestNormalizedConfiguration extends AutorestRawConfiguratio */ eol?: "default" | "lf" | "crlf"; + /** + * Include x-ms-original-file property to x-ms-examples to get path to the original file where example was. + */ + "include-x-ms-examples-original-file"?: boolean; + /** * Feature flags. Those flags enable/disable certain features */ diff --git a/packages/libs/configuration/src/configuration-schema/autorest-configuration-schema.ts b/packages/libs/configuration/src/configuration-schema/autorest-configuration-schema.ts index 37d6f3df3..4d488d431 100644 --- a/packages/libs/configuration/src/configuration-schema/autorest-configuration-schema.ts +++ b/packages/libs/configuration/src/configuration-schema/autorest-configuration-schema.ts @@ -66,6 +66,10 @@ export const AUTOREST_CONFIGURATION_SCHEMA = { description: "Force updating the version of core even if there is a local version satisfying the requirement.", }, memory: { type: "string", description: "Configure max memory allowed for autorest process(s)" }, + "include-x-ms-examples-original-file": { + type: "boolean", + description: "Include x-ms-original-file property in x-ms-examples", + }, // Feature flags "deduplicate-inline-models": { type: "boolean" }, diff --git a/packages/testing/test-public-packages/package.json b/packages/testing/test-public-packages/package.json index 79b340044..43b8d32f0 100644 --- a/packages/testing/test-public-packages/package.json +++ b/packages/testing/test-public-packages/package.json @@ -30,7 +30,7 @@ }, "homepage": "https://github.com/Azure/autorest#readme", "dependencies": { - "@autorest/core": "~3.6.2", + "@autorest/core": "~3.6.3", "autorest": "~3.4.0", "source-map-support": "^0.5.19" }, diff --git a/packages/tools/compare/CHANGELOG.json b/packages/tools/compare/CHANGELOG.json index 5398773ba..faf822619 100644 --- a/packages/tools/compare/CHANGELOG.json +++ b/packages/tools/compare/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@autorest/compare", "entries": [ + { + "version": "0.4.2", + "tag": "@autorest/compare_v0.4.2", + "date": "Wed, 22 Sep 2021 20:33:38 GMT", + "comments": { + "patch": [ + { + "comment": "**Fix** Issue when parsing parameter with public/private and default value" + } + ] + } + }, { "version": "0.4.1", "tag": "@autorest/compare_v0.4.1", diff --git a/packages/tools/compare/CHANGELOG.md b/packages/tools/compare/CHANGELOG.md index 3ee3d4280..8f23f2889 100644 --- a/packages/tools/compare/CHANGELOG.md +++ b/packages/tools/compare/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @autorest/compare -This log was last generated on Wed, 08 Sep 2021 15:39:22 GMT and should not be manually modified. +This log was last generated on Wed, 22 Sep 2021 20:33:38 GMT and should not be manually modified. + +## 0.4.2 +Wed, 22 Sep 2021 20:33:38 GMT + +### Patches + +- **Fix** Issue when parsing parameter with public/private and default value ## 0.4.1 Wed, 08 Sep 2021 15:39:22 GMT diff --git a/packages/tools/compare/package.json b/packages/tools/compare/package.json index dbdf98674..fbf45e61c 100644 --- a/packages/tools/compare/package.json +++ b/packages/tools/compare/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/compare", - "version": "0.4.1", + "version": "0.4.2", "description": "Compares the output between two AutoRest runs to check for material differences.", "main": "dist/index.js", "bin": { diff --git a/packages/tools/compare/src/languages/typescript.ts b/packages/tools/compare/src/languages/typescript.ts index 54da4bfb8..04148f725 100644 --- a/packages/tools/compare/src/languages/typescript.ts +++ b/packages/tools/compare/src/languages/typescript.ts @@ -108,10 +108,7 @@ function extractField(fieldNode: Parser.SyntaxNode): FieldDetails { } function extractParameter(parameterNode: Parser.SyntaxNode, ordinal: number): ParameterDetails { - const children = - parameterNode.namedChildren.length === 3 ? parameterNode.namedChildren.slice(1) : parameterNode.namedChildren; - - const [nameNode, typeNode] = children; + const { nameNode, typeNode } = parseParameterNode(parameterNode); return { name: nameNode.text, type: typeNode ? typeNode.children[1].text : "any", @@ -120,6 +117,23 @@ function extractParameter(parameterNode: Parser.SyntaxNode, ordinal: number): Pa }; } +function parseParameterNode(parameterNode: Parser.SyntaxNode) { + // For private options: MyType; + if (parameterNode.namedChildren.length === 3) { + const [accessibility, nameNode, typeNode] = parameterNode.namedChildren; + return { nameNode, typeNode }; + } + // For private options: MyType = initialValue; + if (parameterNode.namedChildren.length === 4) { + const [accessibility, nameNode, typeNode, value] = parameterNode.namedChildren; + return { nameNode, typeNode }; + } + + // For options: MyType; + const [nameNode, typeNode] = parameterNode.namedChildren; + return { nameNode, typeNode }; +} + function extractGenericParameter(genericParamNode: Parser.SyntaxNode, ordinal: number): GenericTypeParameterDetails { return { name: genericParamNode.namedChildren[0].text, diff --git a/regression-tests/package.json b/regression-tests/package.json index 4c96919a6..cc4fa3221 100644 --- a/regression-tests/package.json +++ b/regression-tests/package.json @@ -9,6 +9,6 @@ "url": "https://github.com/Azure/autorest/issues" }, "devDependencies": { - "@microsoft.azure/autorest.testserver": "^3.0.21" + "@microsoft.azure/autorest.testserver": "^3.0.40" } } diff --git a/regression-tests/regression-compare.yaml b/regression-tests/regression-compare.yaml index 4ce1e2c5f..38130aaf6 100644 --- a/regression-tests/regression-compare.yaml +++ b/regression-tests/regression-compare.yaml @@ -62,27 +62,26 @@ languages: - language: python outputPath: ./output/python oldArgs: - - --version:3.3.2 - - --use:@autorest/modelerfour@4.18.4 - - --use:@autorest/python@5.7.0 + - --version:3.6.2 + - --use:@autorest/modelerfour@4.21.1 + - --use:@autorest/python@5.8.4 - --modelerfour.treat-type-object-as-anything newArgs: - --version:../packages/extensions/core - --use:../packages/extensions/modelerfour - - --use:@autorest/python@5.7.0 + - --use:@autorest/python@5.8.4 - --modelerfour.treat-type-object-as-anything - - --modelerfour.seal-single-value-enum-by-default - language: typescript outputPath: ./output/typescript oldArgs: - --v3 - - --version:3.3.2 - - --use:@autorest/modelerfour@4.18.4 + - --version:3.6.2 + - --use:@autorest/modelerfour@4.21.1 - --modelerfour.treat-type-object-as-anything - --package-name:test-package - --title:TestClient - - --use:@autorest/typescript@6.0.0-beta.5 + - --use:@autorest/typescript@6.0.0-beta.13 newArgs: - --v3 - --version:../packages/extensions/core @@ -90,5 +89,4 @@ languages: - --modelerfour.treat-type-object-as-anything - --package-name:test-package - --title:TestClient - - --modelerfour.seal-single-value-enum-by-default - - --use:@autorest/typescript@6.0.0-beta.5 + - --use:@autorest/typescript@6.0.0-beta.13