@autorest/python 6.14.1 → 6.14.2
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.
- package/autorest/codegen/models/base.py +0 -2
- package/autorest/codegen/models/combined_type.py +0 -4
- package/autorest/codegen/models/constant_type.py +0 -5
- package/autorest/codegen/models/credential_types.py +0 -2
- package/autorest/codegen/models/dictionary_type.py +0 -4
- package/autorest/codegen/models/enum_type.py +0 -8
- package/autorest/codegen/models/list_type.py +0 -4
- package/autorest/codegen/models/model_type.py +0 -4
- package/autorest/codegen/models/primitive_types.py +1 -15
- package/autorest/codegen/models/property.py +0 -7
- package/package.json +1 -1
|
@@ -158,9 +158,7 @@ class BaseType(BaseModel, ABC): # pylint: disable=too-many-public-methods
|
|
|
158
158
|
def get_json_template_representation(
|
|
159
159
|
self,
|
|
160
160
|
*,
|
|
161
|
-
optional: bool = True,
|
|
162
161
|
client_default_value_declaration: Optional[str] = None,
|
|
163
|
-
description: Optional[str] = None,
|
|
164
162
|
) -> Any:
|
|
165
163
|
"""Template of what this schema would look like as JSON input"""
|
|
166
164
|
|
|
@@ -96,14 +96,10 @@ class CombinedType(BaseType):
|
|
|
96
96
|
def get_json_template_representation(
|
|
97
97
|
self,
|
|
98
98
|
*,
|
|
99
|
-
optional: bool = True,
|
|
100
99
|
client_default_value_declaration: Optional[str] = None,
|
|
101
|
-
description: Optional[str] = None,
|
|
102
100
|
) -> Any:
|
|
103
101
|
return self.types[0].get_json_template_representation(
|
|
104
|
-
optional=optional,
|
|
105
102
|
client_default_value_declaration=client_default_value_declaration,
|
|
106
|
-
description=description,
|
|
107
103
|
)
|
|
108
104
|
|
|
109
105
|
def get_polymorphic_subtypes(self, polymorphic_subtypes: List["ModelType"]) -> None:
|
|
@@ -104,15 +104,10 @@ class ConstantType(BaseType):
|
|
|
104
104
|
def get_json_template_representation(
|
|
105
105
|
self,
|
|
106
106
|
*,
|
|
107
|
-
optional: bool = True,
|
|
108
|
-
# pylint: disable=unused-argument
|
|
109
107
|
client_default_value_declaration: Optional[str] = None,
|
|
110
|
-
description: Optional[str] = None,
|
|
111
108
|
) -> Any:
|
|
112
109
|
return self.value_type.get_json_template_representation(
|
|
113
|
-
optional=optional,
|
|
114
110
|
client_default_value_declaration=self.get_declaration(),
|
|
115
|
-
description=description,
|
|
116
111
|
)
|
|
117
112
|
|
|
118
113
|
def _imports_shared(self, **kwargs: Any):
|
|
@@ -124,9 +124,7 @@ class CredentialType(Generic[CredentialPolicyType], BaseType): # pylint:disable
|
|
|
124
124
|
def get_json_template_representation(
|
|
125
125
|
self,
|
|
126
126
|
*,
|
|
127
|
-
optional: bool = True,
|
|
128
127
|
client_default_value_declaration: Optional[str] = None,
|
|
129
|
-
description: Optional[str] = None,
|
|
130
128
|
) -> Any:
|
|
131
129
|
raise TypeError("You should not try to get a JSON template representation of a CredentialSchema")
|
|
132
130
|
|
|
@@ -72,15 +72,11 @@ class DictionaryType(BaseType):
|
|
|
72
72
|
def get_json_template_representation(
|
|
73
73
|
self,
|
|
74
74
|
*,
|
|
75
|
-
optional: bool = True,
|
|
76
75
|
client_default_value_declaration: Optional[str] = None,
|
|
77
|
-
description: Optional[str] = None,
|
|
78
76
|
) -> Any:
|
|
79
77
|
return {
|
|
80
78
|
'"str"': self.element_type.get_json_template_representation(
|
|
81
|
-
optional=optional,
|
|
82
79
|
client_default_value_declaration=client_default_value_declaration,
|
|
83
|
-
description=description,
|
|
84
80
|
)
|
|
85
81
|
}
|
|
86
82
|
|
|
@@ -56,15 +56,11 @@ class EnumValue(BaseType):
|
|
|
56
56
|
def get_json_template_representation(
|
|
57
57
|
self,
|
|
58
58
|
*,
|
|
59
|
-
optional: bool = True,
|
|
60
59
|
client_default_value_declaration: Optional[str] = None,
|
|
61
|
-
description: Optional[str] = None,
|
|
62
60
|
) -> Any:
|
|
63
61
|
# for better display effect, use the only value instead of var type
|
|
64
62
|
return self.value_type.get_json_template_representation(
|
|
65
|
-
optional=optional,
|
|
66
63
|
client_default_value_declaration=client_default_value_declaration,
|
|
67
|
-
description=description,
|
|
68
64
|
)
|
|
69
65
|
|
|
70
66
|
@property
|
|
@@ -193,15 +189,11 @@ class EnumType(BaseType):
|
|
|
193
189
|
def get_json_template_representation(
|
|
194
190
|
self,
|
|
195
191
|
*,
|
|
196
|
-
optional: bool = True,
|
|
197
192
|
client_default_value_declaration: Optional[str] = None,
|
|
198
|
-
description: Optional[str] = None,
|
|
199
193
|
) -> Any:
|
|
200
194
|
# for better display effect, use the only value instead of var type
|
|
201
195
|
return self.value_type.get_json_template_representation(
|
|
202
|
-
optional=optional,
|
|
203
196
|
client_default_value_declaration=client_default_value_declaration,
|
|
204
|
-
description=description,
|
|
205
197
|
)
|
|
206
198
|
|
|
207
199
|
@property
|
|
@@ -95,15 +95,11 @@ class ListType(BaseType):
|
|
|
95
95
|
def get_json_template_representation(
|
|
96
96
|
self,
|
|
97
97
|
*,
|
|
98
|
-
optional: bool = True,
|
|
99
98
|
client_default_value_declaration: Optional[str] = None,
|
|
100
|
-
description: Optional[str] = None,
|
|
101
99
|
) -> Any:
|
|
102
100
|
return [
|
|
103
101
|
self.element_type.get_json_template_representation(
|
|
104
|
-
optional=optional,
|
|
105
102
|
client_default_value_declaration=client_default_value_declaration,
|
|
106
|
-
description=description,
|
|
107
103
|
)
|
|
108
104
|
]
|
|
109
105
|
|
|
@@ -147,9 +147,7 @@ class ModelType( # pylint: disable=abstract-method
|
|
|
147
147
|
def get_json_template_representation(
|
|
148
148
|
self,
|
|
149
149
|
*,
|
|
150
|
-
optional: bool = True,
|
|
151
150
|
client_default_value_declaration: Optional[str] = None,
|
|
152
|
-
description: Optional[str] = None,
|
|
153
151
|
) -> Any:
|
|
154
152
|
if self._created_json_template_representation:
|
|
155
153
|
return "..." # do this to avoid loop
|
|
@@ -163,9 +161,7 @@ class ModelType( # pylint: disable=abstract-method
|
|
|
163
161
|
# additional properties in the template
|
|
164
162
|
representation = {
|
|
165
163
|
f'"{prop.wire_name}"': prop.get_json_template_representation(
|
|
166
|
-
optional=optional,
|
|
167
164
|
client_default_value_declaration=client_default_value_declaration,
|
|
168
|
-
description=description,
|
|
169
165
|
)
|
|
170
166
|
for prop in [
|
|
171
167
|
p for p in self.properties if not (p.is_discriminator or p.client_name == "additional_properties")
|
|
@@ -9,7 +9,6 @@ from typing import Any, Dict, List, Optional, Union, TYPE_CHECKING
|
|
|
9
9
|
|
|
10
10
|
from .base import BaseType
|
|
11
11
|
from .imports import FileImport, ImportType, TypingSection
|
|
12
|
-
from .utils import add_to_description
|
|
13
12
|
|
|
14
13
|
if TYPE_CHECKING:
|
|
15
14
|
from .code_model import CodeModel
|
|
@@ -36,26 +35,13 @@ class PrimitiveType(BaseType): # pylint: disable=abstract-method
|
|
|
36
35
|
def get_json_template_representation(
|
|
37
36
|
self,
|
|
38
37
|
*,
|
|
39
|
-
optional: bool = True,
|
|
40
38
|
client_default_value_declaration: Optional[str] = None,
|
|
41
|
-
description: Optional[str] = None,
|
|
42
39
|
) -> Any:
|
|
43
|
-
comment = ""
|
|
44
|
-
if optional:
|
|
45
|
-
comment = add_to_description(comment, "Optional.")
|
|
46
40
|
if self.client_default_value is not None:
|
|
47
41
|
client_default_value_declaration = client_default_value_declaration or self.get_declaration(
|
|
48
42
|
self.client_default_value
|
|
49
43
|
)
|
|
50
|
-
|
|
51
|
-
comment = add_to_description(comment, f"Default value is {client_default_value_declaration}.")
|
|
52
|
-
else:
|
|
53
|
-
client_default_value_declaration = self.default_template_representation_declaration
|
|
54
|
-
if description:
|
|
55
|
-
comment = add_to_description(comment, description)
|
|
56
|
-
if comment:
|
|
57
|
-
comment = f"# {comment}"
|
|
58
|
-
return client_default_value_declaration + ("" if self.code_model.for_test else comment)
|
|
44
|
+
return client_default_value_declaration or self.default_template_representation_declaration
|
|
59
45
|
|
|
60
46
|
@property
|
|
61
47
|
def default_template_representation_declaration(self) -> str:
|
|
@@ -113,23 +113,16 @@ class Property(BaseModel): # pylint: disable=too-many-instance-attributes
|
|
|
113
113
|
def get_json_template_representation(
|
|
114
114
|
self,
|
|
115
115
|
*,
|
|
116
|
-
optional: bool = True, # pylint: disable=unused-argument
|
|
117
116
|
client_default_value_declaration: Optional[str] = None,
|
|
118
|
-
description: Optional[str] = None,
|
|
119
117
|
) -> Any:
|
|
120
118
|
if self.is_multipart_file_input:
|
|
121
119
|
file_type_str = '"filetype"' if self.code_model.for_test else "filetype"
|
|
122
120
|
return f"[{file_type_str}]" if self.type.type == "list" else file_type_str
|
|
123
121
|
if self.client_default_value:
|
|
124
122
|
client_default_value_declaration = self.get_declaration(self.client_default_value)
|
|
125
|
-
if self.description(is_operation_file=True):
|
|
126
|
-
description = self.description(is_operation_file=True)
|
|
127
123
|
# make sure there is no \n otherwise the json template will be invalid
|
|
128
|
-
description = (description or "").replace("\n", " ")
|
|
129
124
|
return self.type.get_json_template_representation(
|
|
130
|
-
optional=self.optional,
|
|
131
125
|
client_default_value_declaration=client_default_value_declaration,
|
|
132
|
-
description=description,
|
|
133
126
|
)
|
|
134
127
|
|
|
135
128
|
def get_polymorphic_subtypes(self, polymorphic_subtypes: List["ModelType"]) -> None:
|