Skip to content

Commit

Permalink
making criterion to initialize models same as importing models in ope…
Browse files Browse the repository at this point in the history
…ration groups
  • Loading branch information
iscai-msft committed Mar 10, 2020
1 parent 8da8539 commit 21bccb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions autorest/codegen/serializers/operation_group_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ def _is_paging(operation):
async_mode=self.async_mode,
is_lro=_is_lro,
is_paging=_is_paging,
import_models=any(
[
operation for operation in self.operation_group.operations
if operation.parameters.has_body or operation.has_response_body or operation.exceptions
]
)
)
4 changes: 2 additions & 2 deletions autorest/codegen/templates/operations_container.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class {{ operation_group.class_name }}{{ object_base_class }}:
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.

{% if code_model.schemas %}
{% if import_models %}
:ivar models: Alias to model classes used in this operation group.
:type models: ~{{ code_model.namespace }}.models
{% endif %}
Expand All @@ -24,7 +24,7 @@ class {{ operation_group.class_name }}{{ object_base_class }}:
:param deserializer: An object model deserializer.
"""

{% if code_model.schemas %}
{% if import_models %}
models = models

{% endif %}
Expand Down

0 comments on commit 21bccb8

Please sign in to comment.