@autorest/python 5.16.0 → 5.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/ChangeLog.md +43 -3
  2. package/README.md +30 -4
  3. package/autorest/__init__.py +1 -1
  4. package/autorest/codegen/__init__.py +48 -209
  5. package/autorest/codegen/models/__init__.py +116 -83
  6. package/autorest/codegen/models/base_builder.py +49 -88
  7. package/autorest/codegen/models/base_model.py +1 -1
  8. package/autorest/codegen/models/{base_schema.py → base_type.py} +56 -40
  9. package/autorest/codegen/models/client.py +157 -48
  10. package/autorest/codegen/models/code_model.py +108 -254
  11. package/autorest/codegen/models/combined_type.py +107 -0
  12. package/autorest/codegen/models/{constant_schema.py → constant_type.py} +49 -40
  13. package/autorest/codegen/models/credential_types.py +224 -0
  14. package/autorest/codegen/models/{dictionary_schema.py → dictionary_type.py} +41 -31
  15. package/autorest/codegen/models/enum_type.py +195 -0
  16. package/autorest/codegen/models/imports.py +23 -0
  17. package/autorest/codegen/models/list_type.py +134 -0
  18. package/autorest/codegen/models/lro_operation.py +77 -156
  19. package/autorest/codegen/models/lro_paging_operation.py +28 -11
  20. package/autorest/codegen/models/model_type.py +239 -0
  21. package/autorest/codegen/models/operation.py +303 -269
  22. package/autorest/codegen/models/operation_group.py +48 -89
  23. package/autorest/codegen/models/paging_operation.py +80 -123
  24. package/autorest/codegen/models/parameter.py +289 -396
  25. package/autorest/codegen/models/parameter_list.py +348 -360
  26. package/autorest/codegen/models/primitive_types.py +544 -0
  27. package/autorest/codegen/models/property.py +109 -139
  28. package/autorest/codegen/models/request_builder.py +105 -88
  29. package/autorest/codegen/models/request_builder_parameter.py +112 -100
  30. package/autorest/codegen/models/response.py +325 -0
  31. package/autorest/codegen/models/utils.py +12 -19
  32. package/autorest/codegen/serializers/__init__.py +46 -37
  33. package/autorest/codegen/serializers/builder_serializer.py +604 -1146
  34. package/autorest/codegen/serializers/client_serializer.py +83 -88
  35. package/autorest/codegen/serializers/general_serializer.py +5 -64
  36. package/autorest/codegen/serializers/import_serializer.py +7 -4
  37. package/autorest/codegen/serializers/metadata_serializer.py +15 -104
  38. package/autorest/codegen/serializers/model_base_serializer.py +40 -32
  39. package/autorest/codegen/serializers/model_generic_serializer.py +8 -6
  40. package/autorest/codegen/serializers/model_init_serializer.py +2 -4
  41. package/autorest/codegen/serializers/model_python3_serializer.py +22 -16
  42. package/autorest/codegen/serializers/operation_groups_serializer.py +4 -13
  43. package/autorest/codegen/serializers/parameter_serializer.py +174 -0
  44. package/autorest/codegen/serializers/request_builders_serializer.py +12 -29
  45. package/autorest/codegen/serializers/utils.py +0 -142
  46. package/autorest/codegen/templates/MANIFEST.in.jinja2 +1 -0
  47. package/autorest/codegen/templates/{service_client.py.jinja2 → client.py.jinja2} +7 -7
  48. package/autorest/codegen/templates/config.py.jinja2 +13 -13
  49. package/autorest/codegen/templates/enum.py.jinja2 +4 -4
  50. package/autorest/codegen/templates/enum_container.py.jinja2 +1 -1
  51. package/autorest/codegen/templates/init.py.jinja2 +2 -2
  52. package/autorest/codegen/templates/lro_operation.py.jinja2 +4 -1
  53. package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +4 -1
  54. package/autorest/codegen/templates/metadata.json.jinja2 +33 -33
  55. package/autorest/codegen/templates/model.py.jinja2 +23 -24
  56. package/autorest/codegen/templates/model_container.py.jinja2 +2 -1
  57. package/autorest/codegen/templates/model_init.py.jinja2 +3 -5
  58. package/autorest/codegen/templates/operation.py.jinja2 +6 -8
  59. package/autorest/codegen/templates/operation_group.py.jinja2 +7 -7
  60. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -1
  61. package/autorest/codegen/templates/operation_tools.jinja2 +8 -2
  62. package/autorest/codegen/templates/paging_operation.py.jinja2 +2 -2
  63. package/autorest/codegen/templates/request_builder.py.jinja2 +13 -11
  64. package/autorest/codegen/templates/setup.py.jinja2 +9 -3
  65. package/autorest/codegen/templates/vendor.py.jinja2 +1 -1
  66. package/autorest/jsonrpc/server.py +15 -3
  67. package/autorest/m4reformatter/__init__.py +1108 -0
  68. package/autorest/multiapi/models/code_model.py +1 -1
  69. package/autorest/multiapi/serializers/__init__.py +4 -4
  70. package/autorest/multiapi/templates/multiapi_config.py.jinja2 +3 -3
  71. package/autorest/multiapi/templates/multiapi_init.py.jinja2 +2 -2
  72. package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +3 -3
  73. package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +9 -9
  74. package/autorest/postprocess/__init__.py +202 -0
  75. package/autorest/postprocess/get_all.py +19 -0
  76. package/autorest/postprocess/venvtools.py +73 -0
  77. package/autorest/preprocess/__init__.py +209 -0
  78. package/autorest/preprocess/helpers.py +54 -0
  79. package/autorest/{namer → preprocess}/python_mappings.py +21 -16
  80. package/package.json +2 -2
  81. package/autorest/codegen/models/credential_model.py +0 -55
  82. package/autorest/codegen/models/credential_schema.py +0 -95
  83. package/autorest/codegen/models/credential_schema_policy.py +0 -73
  84. package/autorest/codegen/models/enum_schema.py +0 -225
  85. package/autorest/codegen/models/list_schema.py +0 -135
  86. package/autorest/codegen/models/object_schema.py +0 -303
  87. package/autorest/codegen/models/primitive_schemas.py +0 -495
  88. package/autorest/codegen/models/request_builder_parameter_list.py +0 -249
  89. package/autorest/codegen/models/schema_request.py +0 -55
  90. package/autorest/codegen/models/schema_response.py +0 -141
  91. package/autorest/namer/__init__.py +0 -23
  92. package/autorest/namer/name_converter.py +0 -509
@@ -5,9 +5,9 @@
5
5
  # --------------------------------------------------------------------------
6
6
  import logging
7
7
  from typing import Dict, Any, Optional, TYPE_CHECKING
8
- from .base_schema import BaseSchema
9
- from .primitive_schemas import get_primitive_schema, PrimitiveSchema
8
+ from .base_type import BaseType
10
9
  from .imports import FileImport
10
+ from .utils import add_to_description
11
11
 
12
12
  if TYPE_CHECKING:
13
13
  from .code_model import CodeModel
@@ -15,29 +15,29 @@ if TYPE_CHECKING:
15
15
  _LOGGER = logging.getLogger(__name__)
16
16
 
17
17
 
18
- class ConstantSchema(BaseSchema):
18
+ class ConstantType(BaseType):
19
19
  """Schema for constants that will be serialized.
20
20
 
21
21
  :param yaml_data: the yaml data for this schema
22
22
  :type yaml_data: dict[str, Any]
23
23
  :param str value: The actual value of this constant.
24
24
  :param schema: The schema for the value of this constant.
25
- :type schema: ~autorest.models.PrimitiveSchema
25
+ :type schema: ~autorest.models.PrimitiveType
26
26
  """
27
27
 
28
28
  def __init__(
29
29
  self,
30
30
  yaml_data: Dict[str, Any],
31
31
  code_model: "CodeModel",
32
- schema: PrimitiveSchema,
32
+ value_type: BaseType,
33
33
  value: Optional[str],
34
34
  ) -> None:
35
35
  super().__init__(yaml_data=yaml_data, code_model=code_model)
36
+ self.value_type = value_type
36
37
  self.value = value
37
- self.schema = schema
38
38
 
39
- def get_declaration(self, value: Any):
40
- if value != self.value:
39
+ def get_declaration(self, value=None):
40
+ if value and value != self.value:
41
41
  _LOGGER.warning(
42
42
  "Passed in value of %s differs from constant value of %s. Choosing constant value",
43
43
  str(value),
@@ -45,7 +45,15 @@ class ConstantSchema(BaseSchema):
45
45
  )
46
46
  if self.value is None:
47
47
  return "None"
48
- return self.schema.get_declaration(self.value)
48
+ return self.value_type.get_declaration(self.value)
49
+
50
+ def description(self, *, is_operation_file: bool) -> str:
51
+ if is_operation_file:
52
+ return ""
53
+ return add_to_description(
54
+ self.yaml_data.get("description", ""),
55
+ f"Default value is {self.get_declaration()}.",
56
+ )
49
57
 
50
58
  @property
51
59
  def serialization_type(self) -> str:
@@ -54,60 +62,61 @@ class ConstantSchema(BaseSchema):
54
62
  :return: The serialization value for msrest
55
63
  :rtype: str
56
64
  """
57
- return self.schema.serialization_type
65
+ return self.value_type.serialization_type
58
66
 
59
- @property
60
- def docstring_text(self) -> str:
67
+ def docstring_text(self, **kwargs: Any) -> str:
61
68
  return "constant"
62
69
 
63
- @property
64
- def docstring_type(self) -> str:
70
+ def docstring_type(self, **kwargs: Any) -> str:
65
71
  """The python type used for RST syntax input and type annotation.
66
72
 
67
73
  :param str namespace: Optional. The namespace for the models.
68
74
  """
69
- return self.schema.docstring_type
75
+ return self.value_type.docstring_type(**kwargs)
70
76
 
71
- def type_annotation(self, *, is_operation_file: bool = False) -> str:
72
- return self.schema.type_annotation(is_operation_file=is_operation_file)
77
+ def type_annotation(self, **kwargs: Any) -> str:
78
+ return self.value_type.type_annotation(**kwargs)
73
79
 
74
80
  @classmethod
75
81
  def from_yaml(
76
82
  cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
77
- ) -> "ConstantSchema":
78
- """Constructs a ConstantSchema from yaml data.
83
+ ) -> "ConstantType":
84
+ """Constructs a ConstantType from yaml data.
79
85
 
80
86
  :param yaml_data: the yaml data from which we will construct this schema
81
87
  :type yaml_data: dict[str, Any]
82
88
 
83
- :return: A created ConstantSchema
84
- :rtype: ~autorest.models.ConstantSchema
89
+ :return: A created ConstantType
90
+ :rtype: ~autorest.models.ConstantType
85
91
  """
86
- name = (
87
- yaml_data["language"]["python"]["name"]
88
- if yaml_data["language"]["python"].get("name")
89
- else ""
90
- )
91
- _LOGGER.debug("Parsing %s constant", name)
92
+ from . import build_type
93
+
92
94
  return cls(
93
95
  yaml_data=yaml_data,
94
96
  code_model=code_model,
95
- schema=get_primitive_schema(
96
- yaml_data=yaml_data["valueType"], code_model=code_model
97
- ),
98
- value=yaml_data.get("value", {}).get("value", None),
97
+ value_type=build_type(yaml_data["valueType"], code_model),
98
+ value=yaml_data["value"],
99
99
  )
100
100
 
101
- def get_json_template_representation(self, **kwargs: Any) -> Any:
102
- kwargs["default_value_declaration"] = self.schema.get_declaration(self.value)
103
- return self.schema.get_json_template_representation(**kwargs)
101
+ def get_json_template_representation(
102
+ self,
103
+ *,
104
+ optional: bool = True,
105
+ # pylint: disable=unused-argument
106
+ client_default_value_declaration: Optional[str] = None,
107
+ description: Optional[str] = None,
108
+ ) -> Any:
109
+ return self.value_type.get_json_template_representation(
110
+ optional=optional,
111
+ client_default_value_declaration=self.get_declaration(),
112
+ description=description,
113
+ )
104
114
 
105
- def imports(self) -> FileImport:
115
+ def imports(self, **kwargs: Any) -> FileImport:
106
116
  file_import = FileImport()
107
- file_import.merge(self.schema.imports())
117
+ file_import.merge(self.value_type.imports(**kwargs))
108
118
  return file_import
109
119
 
110
- def model_file_imports(self) -> FileImport:
111
- file_import = self.imports()
112
- file_import.merge(self.schema.model_file_imports())
113
- return file_import
120
+ @property
121
+ def instance_check_template(self) -> str:
122
+ return self.value_type.instance_check_template
@@ -0,0 +1,224 @@
1
+ # -------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for
4
+ # license information.
5
+ # --------------------------------------------------------------------------
6
+ from abc import abstractmethod
7
+ from typing import (
8
+ Optional,
9
+ Any,
10
+ Dict,
11
+ TYPE_CHECKING,
12
+ List,
13
+ Generic,
14
+ TypeVar,
15
+ Union,
16
+ cast,
17
+ )
18
+
19
+ from .imports import FileImport, ImportType, TypingSection
20
+ from .base_type import BaseType
21
+
22
+ if TYPE_CHECKING:
23
+ from .code_model import CodeModel
24
+
25
+
26
+ class _CredentialPolicyBaseType:
27
+ """Base class for our different credential policy types.
28
+
29
+ Inherited by our BearerTokenCredentialPolicy and AzureKeyCredentialPolicy types.
30
+ """
31
+
32
+ def __init__(self, yaml_data: Dict[str, Any], code_model: "CodeModel") -> None:
33
+ self.yaml_data = yaml_data
34
+ self.code_model = code_model
35
+
36
+ @abstractmethod
37
+ def call(self, async_mode: bool) -> str:
38
+ """
39
+ How to call this credential policy. Used to initialize the credential policy in the config file.
40
+ """
41
+ ...
42
+
43
+
44
+ class BearerTokenCredentialPolicyType(_CredentialPolicyBaseType):
45
+ """Credential policy type representing BearerTokenCredentialPolicy"""
46
+
47
+ def __init__(
48
+ self,
49
+ yaml_data: Dict[str, Any],
50
+ code_model: "CodeModel",
51
+ credential_scopes: List[str],
52
+ ) -> None:
53
+ super().__init__(yaml_data, code_model)
54
+ self.credential_scopes = credential_scopes
55
+
56
+ def call(self, async_mode: bool) -> str:
57
+ policy_name = f"{'Async' if async_mode else ''}BearerTokenCredentialPolicy"
58
+ return f"policies.{policy_name}(self.credential, *self.credential_scopes, **kwargs)"
59
+
60
+ @classmethod
61
+ def from_yaml(
62
+ cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
63
+ ) -> "BearerTokenCredentialPolicyType":
64
+ return cls(yaml_data, code_model, yaml_data["credentialScopes"])
65
+
66
+
67
+ class ARMChallengeAuthenticationPolicyType(BearerTokenCredentialPolicyType):
68
+ """Credential policy type representing ARMChallengeAuthenticationPolicy"""
69
+
70
+ def call(self, async_mode: bool) -> str:
71
+ policy_name = f"{'Async' if async_mode else ''}ARMChallengeAuthenticationPolicy"
72
+ return f"{policy_name}(self.credential, *self.credential_scopes, **kwargs)"
73
+
74
+
75
+ class AzureKeyCredentialPolicyType(_CredentialPolicyBaseType):
76
+ def __init__(
77
+ self, yaml_data: Dict[str, Any], code_model: "CodeModel", key: str
78
+ ) -> None:
79
+ super().__init__(yaml_data, code_model)
80
+ self.key = key
81
+
82
+ def call(self, async_mode: bool) -> str:
83
+ return f'policies.AzureKeyCredentialPolicy(self.credential, "{self.key}", **kwargs)'
84
+
85
+ @classmethod
86
+ def from_yaml(
87
+ cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
88
+ ) -> "AzureKeyCredentialPolicyType":
89
+ return cls(yaml_data, code_model, yaml_data["key"])
90
+
91
+
92
+ CredentialPolicyType = TypeVar(
93
+ "CredentialPolicyType",
94
+ bound=Union[
95
+ BearerTokenCredentialPolicyType,
96
+ ARMChallengeAuthenticationPolicyType,
97
+ AzureKeyCredentialPolicyType,
98
+ ],
99
+ )
100
+
101
+
102
+ class CredentialType(
103
+ Generic[CredentialPolicyType], BaseType
104
+ ): # pylint:disable=abstract-method
105
+ """Store info about the type of the credential. Can be either an AzureKeyCredential or a TokenCredential"""
106
+
107
+ def __init__(
108
+ self,
109
+ yaml_data: Dict[str, Any],
110
+ code_model: "CodeModel",
111
+ policy: CredentialPolicyType,
112
+ ) -> None:
113
+ super().__init__(yaml_data, code_model)
114
+ self.policy = policy
115
+
116
+ def description(
117
+ self, *, is_operation_file: bool # pylint: disable=unused-argument
118
+ ) -> str:
119
+ return ""
120
+
121
+ def get_json_template_representation(
122
+ self,
123
+ *,
124
+ optional: bool = True,
125
+ client_default_value_declaration: Optional[str] = None,
126
+ description: Optional[str] = None,
127
+ ) -> Any:
128
+ raise TypeError(
129
+ "You should not try to get a JSON template representation of a CredentialSchema"
130
+ )
131
+
132
+ def docstring_text(self, **kwargs: Any) -> str:
133
+ return "credential"
134
+
135
+ @property
136
+ def serialization_type(self) -> str:
137
+ return self.docstring_type()
138
+
139
+ @classmethod
140
+ def from_yaml(
141
+ cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
142
+ ) -> "CredentialType":
143
+ from . import build_type
144
+
145
+ return cls(
146
+ yaml_data,
147
+ code_model,
148
+ policy=cast(
149
+ CredentialPolicyType, build_type(yaml_data["policy"], code_model)
150
+ ),
151
+ )
152
+
153
+
154
+ class TokenCredentialType(
155
+ CredentialType[ # pylint: disable=unsubscriptable-object
156
+ Union[BearerTokenCredentialPolicyType, ARMChallengeAuthenticationPolicyType]
157
+ ]
158
+ ):
159
+ """Type of a token credential. Used by BearerAuth and ARMChallenge policies"""
160
+
161
+ def type_annotation(self, **kwargs: Any) -> str: # pylint: disable=no-self-use
162
+ if kwargs.pop("async_mode"):
163
+ return '"AsyncTokenCredential"'
164
+ return '"TokenCredential"'
165
+
166
+ def docstring_type(self, **kwargs: Any) -> str: # pylint: disable=no-self-use
167
+ if kwargs.pop("async_mode"):
168
+ return "~azure.core.credentials_async.AsyncTokenCredential"
169
+ return "~azure.core.credentials.TokenCredential"
170
+
171
+ def imports(self, **kwargs: Any) -> FileImport: # pylint: disable=no-self-use
172
+ file_import = FileImport()
173
+ if kwargs.pop("async_mode"):
174
+ file_import.add_submodule_import(
175
+ "azure.core.credentials_async",
176
+ "AsyncTokenCredential",
177
+ ImportType.AZURECORE,
178
+ typing_section=TypingSection.TYPING,
179
+ )
180
+ else:
181
+ file_import.add_submodule_import(
182
+ "azure.core.credentials",
183
+ "TokenCredential",
184
+ ImportType.AZURECORE,
185
+ typing_section=TypingSection.TYPING,
186
+ )
187
+ return file_import
188
+
189
+ @property
190
+ def instance_check_template(self) -> str:
191
+ return "hasattr({}, get_token)"
192
+
193
+
194
+ class AzureKeyCredentialType(
195
+ # pylint: disable=unsubscriptable-object
196
+ CredentialType[AzureKeyCredentialPolicyType]
197
+ ):
198
+ """Type for an AzureKeyCredential"""
199
+
200
+ def docstring_type( # pylint: disable=no-self-use
201
+ self, **kwargs: Any # pylint: disable=unused-argument
202
+ ) -> str:
203
+ return "~azure.core.credentials.AzureKeyCredential"
204
+
205
+ def type_annotation( # pylint: disable=no-self-use
206
+ self, **kwargs: Any # pylint: disable=unused-argument
207
+ ) -> str:
208
+ return "AzureKeyCredential"
209
+
210
+ @property
211
+ def instance_check_template(self) -> str:
212
+ return "isinstance({}, AzureKeyCredential)"
213
+
214
+ def imports( # pylint: disable=no-self-use
215
+ self, **kwargs: Any # pylint: disable=unused-argument
216
+ ) -> FileImport:
217
+ file_import = FileImport()
218
+ file_import.add_submodule_import(
219
+ "azure.core.credentials",
220
+ "AzureKeyCredential",
221
+ ImportType.AZURECORE,
222
+ typing_section=TypingSection.CONDITIONAL,
223
+ )
224
+ return file_import
@@ -4,27 +4,27 @@
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
6
  from typing import Any, Dict, Optional, TYPE_CHECKING
7
- from .base_schema import BaseSchema
7
+ from .base_type import BaseType
8
8
  from .imports import FileImport, ImportType, TypingSection
9
9
 
10
10
  if TYPE_CHECKING:
11
11
  from .code_model import CodeModel
12
12
 
13
13
 
14
- class DictionarySchema(BaseSchema):
14
+ class DictionaryType(BaseType):
15
15
  """Schema for dictionaries that will be serialized.
16
16
 
17
17
  :param yaml_data: the yaml data for this schema
18
18
  :type yaml_data: dict[str, Any]
19
19
  :param element_type: The type of the value for the dictionary
20
- :type element_type: ~autorest.models.BaseSchema
20
+ :type element_type: ~autorest.models.BaseType
21
21
  """
22
22
 
23
23
  def __init__(
24
24
  self,
25
25
  yaml_data: Dict[str, Any],
26
26
  code_model: "CodeModel",
27
- element_type: "BaseSchema",
27
+ element_type: BaseType,
28
28
  ) -> None:
29
29
  super().__init__(yaml_data=yaml_data, code_model=code_model)
30
30
  self.element_type = element_type
@@ -38,53 +38,64 @@ class DictionarySchema(BaseSchema):
38
38
  """
39
39
  return f"{{{self.element_type.serialization_type}}}"
40
40
 
41
- def type_annotation(self, *, is_operation_file: bool = False) -> str:
41
+ def type_annotation(self, **kwargs: Any) -> str:
42
42
  """The python type used for type annotation
43
43
 
44
44
  :return: The type annotation for this schema
45
45
  :rtype: str
46
46
  """
47
- return f"Dict[str, {self.element_type.type_annotation(is_operation_file=is_operation_file)}]"
47
+ return f"Dict[str, {self.element_type.type_annotation(**kwargs)}]"
48
48
 
49
- @property
50
- def docstring_text(self) -> str:
51
- return f"dict mapping str to {self.element_type.docstring_text}"
49
+ def description(self, *, is_operation_file: bool) -> str:
50
+ return "" if is_operation_file else self.yaml_data.get("description", "")
51
+
52
+ def docstring_text(self, **kwargs: Any) -> str:
53
+ return f"dict mapping str to {self.element_type.docstring_text(**kwargs)}"
52
54
 
53
55
  @property
54
- def docstring_type(self) -> str:
56
+ def xml_serialization_ctxt(self) -> Optional[str]:
57
+ """No serialization ctxt for dictionaries"""
58
+ return None
59
+
60
+ def docstring_type(self, **kwargs: Any) -> str:
55
61
  """The python type used for RST syntax input and type annotation.
56
62
 
57
63
  :param str namespace: Optional. The namespace for the models.
58
64
  """
59
- return f"dict[str, {self.element_type.docstring_type}]"
60
-
61
- def xml_serialization_ctxt(self) -> Optional[str]:
62
- raise NotImplementedError(
63
- "Dictionary schema does not support XML serialization."
64
- )
65
+ return f"dict[str, {self.element_type.docstring_type(**kwargs)}]"
65
66
 
66
- def get_json_template_representation(self, **kwargs: Any) -> Any:
67
+ def get_json_template_representation(
68
+ self,
69
+ *,
70
+ optional: bool = True,
71
+ client_default_value_declaration: Optional[str] = None,
72
+ description: Optional[str] = None,
73
+ ) -> Any:
67
74
  return {
68
- f'"{"str"}"': self.element_type.get_json_template_representation(**kwargs)
75
+ f'"str"': self.element_type.get_json_template_representation(
76
+ optional=optional,
77
+ client_default_value_declaration=client_default_value_declaration,
78
+ description=description,
79
+ )
69
80
  }
70
81
 
71
82
  @classmethod
72
83
  def from_yaml(
73
84
  cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
74
- ) -> "DictionarySchema":
75
- """Constructs a DictionarySchema from yaml data.
85
+ ) -> "DictionaryType":
86
+ """Constructs a DictionaryType from yaml data.
76
87
 
77
88
  :param yaml_data: the yaml data from which we will construct this schema
78
89
  :type yaml_data: dict[str, Any]
79
90
 
80
- :return: A created DictionarySchema
81
- :rtype: ~autorest.models.DictionarySchema
91
+ :return: A created DictionaryType
92
+ :rtype: ~autorest.models.DictionaryType
82
93
  """
83
- element_schema = yaml_data["elementType"]
94
+ element_schema: Dict[str, Any] = yaml_data["elementType"]
84
95
 
85
- from . import build_schema # pylint: disable=import-outside-toplevel
96
+ from . import build_type # pylint: disable=import-outside-toplevel
86
97
 
87
- element_type = build_schema(yaml_data=element_schema, code_model=code_model)
98
+ element_type = build_type(yaml_data=element_schema, code_model=code_model)
88
99
 
89
100
  return cls(
90
101
  yaml_data=yaml_data,
@@ -92,15 +103,14 @@ class DictionarySchema(BaseSchema):
92
103
  element_type=element_type,
93
104
  )
94
105
 
95
- def imports(self) -> FileImport:
106
+ def imports(self, **kwargs: Any) -> FileImport:
96
107
  file_import = FileImport()
97
108
  file_import.add_submodule_import(
98
109
  "typing", "Dict", ImportType.STDLIB, TypingSection.CONDITIONAL
99
110
  )
100
- file_import.merge(self.element_type.imports())
111
+ file_import.merge(self.element_type.imports(**kwargs))
101
112
  return file_import
102
113
 
103
- def model_file_imports(self) -> FileImport:
104
- file_import = self.imports()
105
- file_import.merge(self.element_type.model_file_imports())
106
- return file_import
114
+ @property
115
+ def instance_check_template(self) -> str:
116
+ return "isinstance({}, dict)"