Add new error when using `content.<mediaType>` on a parameter as its not supported (#4304)

* Content parameter error

* Publish

* update core/m4 baseline

* update core/m4 baseline

* Tweaks

* Tweaks

* Tweaks

* Tweaks

* Fix

* Fix

* Fix
This commit is contained in:
Timothee Guerin 2021-09-22 16:40:01 -07:00 коммит произвёл GitHub
Родитель 99360079f0
Коммит e2acd6c223
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 106 добавлений и 36 удалений

Просмотреть файл

@ -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"
}

Просмотреть файл

@ -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

Просмотреть файл

@ -40,7 +40,7 @@
},
"typings": "./dist/exports.d.ts",
"devDependencies": {
"@autorest/configuration": "~1.7.0",
"@autorest/configuration": "~1.7.1",
"@autorest/core": "~3.6.2",
"@autorest/common": "~1.3.0",
"@azure-tools/async-io": "~3.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.1",
"@autorest/schemas": "~1.3.1",
"@autorest/test-utils": "~0.4.0",
"@azure-tools/async-io": "~3.0.0",

Просмотреть файл

@ -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.<mediaType>` as not being supported"
}
]
}
},
{
"version": "4.21.1",
"tag": "@autorest/modelerfour_v4.21.1",

Просмотреть файл

@ -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.<mediaType>` as not being supported
## 4.21.1
Thu, 16 Sep 2021 18:49:17 GMT

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "@autorest/modelerfour",
"version": "4.21.1",
"version": "4.21.2",
"description": "AutoRest Modeler Version Four (component)",
"directories": {
"doc": "docs"

Просмотреть файл

@ -1967,7 +1967,14 @@ export class ModelerFour {
for (const pp of parameters) {
const parameter = pp.instance;
if (parameter.content) {
this.session.error(
`Parameter '${parameter.name}' in '${parameter.in}' has content.<mediaType> which is not supported right now. Use schema instead. See https://github.com/Azure/autorest/issues/4303`,
["Modelerfour/ParameterContentNotSupported"],
parameter,
);
continue;
}
this.use(parameter.schema, (name, schema) => {
if (this.apiVersionMode !== "none" && this.interpret.isApiVersionParameter(parameter)) {
return this.processApiVersionParameter(parameter, operation, pathItem);

Просмотреть файл

@ -1,6 +1,18 @@
{
"name": "@autorest/configuration",
"entries": [
{
"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",

Просмотреть файл

@ -1,6 +1,13 @@
# 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 Wed, 22 Sep 2021 15:23:39 GMT and should not be manually modified.
## 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

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "@autorest/configuration",
"version": "1.7.0",
"version": "1.7.1",
"description": "Autorest configuration",
"main": "dist/index.js",
"typings": "dist/index.d.ts",

Просмотреть файл

@ -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",

Просмотреть файл

@ -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

Просмотреть файл

@ -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": {

Просмотреть файл

@ -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,

Просмотреть файл

@ -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"
}
}

Просмотреть файл

@ -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