From 08c033fbdbbf9480806a0db95c90d1fddf152e34 Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Tue, 21 Jul 2020 16:41:10 -0700 Subject: [PATCH 1/5] Escape single-quote in regexp --- autorest/codegen/models/primitive_schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorest/codegen/models/primitive_schemas.py b/autorest/codegen/models/primitive_schemas.py index 80945cd21ba..a25c08c2ef9 100644 --- a/autorest/codegen/models/primitive_schemas.py +++ b/autorest/codegen/models/primitive_schemas.py @@ -19,7 +19,7 @@ def __init__(self, string: str) -> None: self.string = string def __repr__(self) -> str: - return f"r'{self.string}'" + return f"r'{self.string.replace('\'', '\\\'')}'" class PrimitiveSchema(BaseSchema): From d42f91f97db98d2b94f0e54b87f93619f504f6b5 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 22 Jul 2020 12:22:42 -0400 Subject: [PATCH 2/5] switch to format string --- autorest/codegen/models/primitive_schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorest/codegen/models/primitive_schemas.py b/autorest/codegen/models/primitive_schemas.py index a25c08c2ef9..e54a99653af 100644 --- a/autorest/codegen/models/primitive_schemas.py +++ b/autorest/codegen/models/primitive_schemas.py @@ -19,7 +19,7 @@ def __init__(self, string: str) -> None: self.string = string def __repr__(self) -> str: - return f"r'{self.string.replace('\'', '\\\'')}'" + return "r'{}'".format(self.string.replace('\'', '\\\'')) class PrimitiveSchema(BaseSchema): From 06c9e2aec57252a840531bd0bf5df810db116846 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 22 Jul 2020 12:27:41 -0400 Subject: [PATCH 3/5] update changelog --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 5f8dfb65c0a..5d3b9e956a3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -10,6 +10,7 @@ Modelerfour version: 4.15.378 (taken from m4 update - perks PR #118) - Fix bug when generating parameters with client default value and constant schema #707 - Fix name in setup.py to default to `package-name` if set #721 +- Allowing single quote in regexp #726 ### 2020-07-07 - 5.1.0-preview.4 Modelerfour version: 4.15.378 From e3392bf22622cf3d31649be067a23d2b13de7611 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 22 Jul 2020 12:29:24 -0400 Subject: [PATCH 4/5] regenerate with testserver test --- .../_auto_rest_validation_test_operations_async.py | 2 +- .../operations/_auto_rest_validation_test_operations.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/operations_async/_auto_rest_validation_test_operations_async.py b/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/operations_async/_auto_rest_validation_test_operations_async.py index 3cb23964368..734d1fc5b74 100644 --- a/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/operations_async/_auto_rest_validation_test_operations_async.py +++ b/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/operations_async/_auto_rest_validation_test_operations_async.py @@ -47,7 +47,7 @@ async def validation_of_method_parameters( url = self.validation_of_method_parameters.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9]+'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9\']+'), 'id': self._serialize.url("id", id, 'int', maximum=1000, minimum=100, multiple=10), } url = self._client.format_url(url, **path_format_arguments) diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py b/test/vanilla/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py index cd5d314195d..146409d1d50 100644 --- a/test/vanilla/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py @@ -52,7 +52,7 @@ def validation_of_method_parameters( url = self.validation_of_method_parameters.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9]+'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9\']+'), 'id': self._serialize.url("id", id, 'int', maximum=1000, minimum=100, multiple=10), } url = self._client.format_url(url, **path_format_arguments) From fb118f607c90aa71fa48d90b208de3ce44dfbcfc Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Tue, 28 Jul 2020 13:15:50 -0400 Subject: [PATCH 5/5] update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d33fb31359..21fa4aa62ca 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@autorest/autorest": "^3.0.0", - "@microsoft.azure/autorest.testserver": "^2.10.54" + "@microsoft.azure/autorest.testserver": "^2.10.55" }, "files": [ "autorest/**/*.py",