Skip to content

Commit

Permalink
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python
Browse files Browse the repository at this point in the history
…into verify_multipart

* 'autorestv3' of https://github.com/Azure/autorest.python:
  Introduce explode into autorest (#705)
  update azure-core and msrest versions (#747)
  • Loading branch information
iscai-msft committed Aug 12, 2020
2 parents 934e947 + 1fe8a1a commit ed75005
Show file tree
Hide file tree
Showing 65 changed files with 132 additions and 99 deletions.
8 changes: 7 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

### 2020-xx-xx - 5.1.0-preview.8
Autorest Core version: 3.0.6302
Modelerfour version: 4.15.407
Modelerfour version: 4.15.400

**New Features**

- Updated minimum `azure-core` version to 1.8.0 #747
- Updated minimum `msrest` version to 0.6.18 #747
- Support for `multipart/form-data` #746

**Bug fixes**

- Fix "multi" in Swagger (will generate correctly multiple query param now)

### 2020-08-07 - 5.1.0-preview.7
Autorest Core version: 3.0.6302
Modelerfour version: 4.15.400
Expand Down
32 changes: 24 additions & 8 deletions autorest/codegen/models/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .schema_request import SchemaRequest
from .object_schema import ObjectSchema
from .constant_schema import ConstantSchema
from .list_schema import ListSchema


_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -199,7 +200,7 @@ def build_serialize_data_call(parameter: Parameter, function_name: str) -> str:
if parameter.skip_url_encoding:
optional_parameters.append("skip_quote=True")

if parameter.style:
if parameter.style and not parameter.explode:
if parameter.style in [ParameterStyle.simple, ParameterStyle.form]:
div_char = ","
elif parameter.style in [ParameterStyle.spaceDelimited]:
Expand All @@ -212,17 +213,32 @@ def build_serialize_data_call(parameter: Parameter, function_name: str) -> str:
raise ValueError(f"Do not support {parameter.style} yet")
optional_parameters.append(f"div='{div_char}'")

serialization_constraints = parameter.schema.serialization_constraints
optional_parameters += serialization_constraints if serialization_constraints else ""
if parameter.explode:
if not isinstance(parameter.schema, ListSchema):
raise ValueError("Got a explode boolean on a non-array schema")
serialization_schema = parameter.schema.element_type
else:
serialization_schema = parameter.schema

optional_parameters_string = "" if not optional_parameters else ", " + ", ".join(optional_parameters)
serialization_constraints = serialization_schema.serialization_constraints
if serialization_constraints:
optional_parameters += serialization_constraints

origin_name = parameter.full_serialized_name

return (
f"""self._serialize.{function_name}("{origin_name.lstrip('_')}", {origin_name}, """
+ f"""'{parameter.schema.serialization_type}'{optional_parameters_string})"""
)
parameters = [
f'"{origin_name.lstrip("_")}"',
"q" if parameter.explode else origin_name,
f"'{serialization_schema.serialization_type}'",
*optional_parameters
]
parameters_line = ', '.join(parameters)

serialize_line = f'self._serialize.{function_name}({parameters_line})'

if parameter.explode:
return f"[{serialize_line} if q is not None else '' for q in {origin_name}]"
return serialize_line

@property
def serialization_context(self) -> str:
Expand Down
3 changes: 3 additions & 0 deletions autorest/codegen/models/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(
constraints: List[Any],
target_property_name: Optional[Union[int, str]] = None, # first uses id as placeholder
style: Optional[ParameterStyle] = None,
explode: Optional[bool] = False,
*,
flattened: bool = False,
grouped_by: Optional["Parameter"] = None,
Expand All @@ -73,6 +74,7 @@ def __init__(
self.constraints = constraints
self.target_property_name = target_property_name
self.style = style
self.explode = explode
self.flattened = flattened
self.grouped_by = grouped_by
self.original_parameter = original_parameter
Expand Down Expand Up @@ -195,6 +197,7 @@ def from_yaml(cls, yaml_data: Dict[str, Any]) -> "Parameter":
constraints=[], # FIXME constraints
target_property_name=id(yaml_data["targetProperty"]) if yaml_data.get("targetProperty") else None,
style=ParameterStyle(http_protocol["style"]) if "style" in http_protocol else None,
explode=http_protocol.get("explode", False),
grouped_by=yaml_data.get("groupedBy", None),
original_parameter=yaml_data.get("originalParameter", None),
flattened=yaml_data.get("flattened", False),
Expand Down
2 changes: 1 addition & 1 deletion autorest/codegen/templates/setup.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ VERSION = "{{ code_model.options.get('package_version', '0.0.0') }}"
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"{{ azure_mgmt_core_import }}]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"{{ azure_mgmt_core_import }}]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/azure/Expected/AcceptanceTests/AzureReport/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/azure/Expected/AcceptanceTests/AzureSpecials/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0", "azure-mgmt-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0", "azure-mgmt-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/azure/Expected/AcceptanceTests/CustomBaseUri/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0", "azure-mgmt-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0", "azure-mgmt-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/azure/Expected/AcceptanceTests/Head/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0", "azure-mgmt-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0", "azure-mgmt-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0", "azure-mgmt-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0", "azure-mgmt-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0", "azure-mgmt-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0", "azure-mgmt-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/azure/Expected/AcceptanceTests/Lro/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0", "azure-mgmt-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0", "azure-mgmt-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/azure/Expected/AcceptanceTests/Paging/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0", "azure-mgmt-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0", "azure-mgmt-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0", "azure-mgmt-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0", "azure-mgmt-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0", "azure-mgmt-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0", "azure-mgmt-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/vanilla/Expected/AcceptanceTests/BodyArray/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/vanilla/Expected/AcceptanceTests/BodyBoolean/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/vanilla/Expected/AcceptanceTests/BodyByte/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/vanilla/Expected/AcceptanceTests/BodyComplex/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/vanilla/Expected/AcceptanceTests/BodyDate/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/vanilla/Expected/AcceptanceTests/BodyFile/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion test/vanilla/Expected/AcceptanceTests/BodyInteger/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"]

setup(
name=NAME,
Expand Down
Loading

0 comments on commit ed75005

Please sign in to comment.