Skip to content

Commit 785457c

Browse files
box-sdk-buildbox-sdk-build
andauthored
fix(boxsdkgen): Fix metadata template schema (box/box-openapi#596) (#1424)
Co-authored-by: box-sdk-build <box-sdk-build@box.com>
1 parent 154b7ce commit 785457c

3 files changed

Lines changed: 72 additions & 5 deletions

File tree

‎.codegen.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "c571efa", "specHash": "65c9c57", "version": "4.8.0" }
1+
{ "engineHash": "c571efa", "specHash": "fa39a3f", "version": "4.8.0" }

‎box_sdk_gen/managers/metadata_templates.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,14 @@ class CreateMetadataTemplateFields(BaseObject):
199199
_fields_to_json_mapping: Dict[str, str] = {
200200
'display_name': 'displayName',
201201
'taxonomy_key': 'taxonomyKey',
202+
'taxonomy_id': 'taxonomyId',
202203
'options_rules': 'optionsRules',
203204
**BaseObject._fields_to_json_mapping,
204205
}
205206
_json_to_fields_mapping: Dict[str, str] = {
206207
'displayName': 'display_name',
207208
'taxonomyKey': 'taxonomy_key',
209+
'taxonomyId': 'taxonomy_id',
208210
'optionsRules': 'options_rules',
209211
**BaseObject._json_to_fields_mapping,
210212
}
@@ -227,6 +229,7 @@ def __init__(
227229
hidden: Optional[bool] = None,
228230
options: Optional[List[CreateMetadataTemplateFieldsOptionsField]] = None,
229231
taxonomy_key: Optional[str] = None,
232+
taxonomy_id: Optional[str] = None,
230233
namespace: Optional[str] = None,
231234
options_rules: Optional[CreateMetadataTemplateFieldsOptionsRulesField] = None,
232235
**kwargs
@@ -237,7 +240,7 @@ def __init__(
237240
date-time picker.
238241
239242
Additionally, metadata templates support an `enum` field for a basic list
240-
of items, and ` multiSelect` field for a similar list of items where the
243+
of items, and `multiSelect` field for a similar list of items where the
241244
user can select more than one value.
242245
243246
Metadata taxonomies are also supported as a `taxonomy` field type
@@ -260,6 +263,9 @@ def __init__(
260263
:param taxonomy_key: The unique key of the metadata taxonomy to use for this taxonomy field.
261264
This property is required when the field `type` is set to `taxonomy`., defaults to None
262265
:type taxonomy_key: Optional[str], optional
266+
:param taxonomy_id: The unique ID of the metadata taxonomy to use for this taxonomy field.
267+
This property is required when the field `type` is set to `taxonomy`., defaults to None
268+
:type taxonomy_id: Optional[str], optional
263269
:param namespace: The namespace of the metadata taxonomy to use for this taxonomy field.
264270
This property is required when the field `type` is set to `taxonomy`., defaults to None
265271
:type namespace: Optional[str], optional
@@ -275,6 +281,7 @@ def __init__(
275281
self.hidden = hidden
276282
self.options = options
277283
self.taxonomy_key = taxonomy_key
284+
self.taxonomy_id = taxonomy_id
278285
self.namespace = namespace
279286
self.options_rules = options_rules
280287

‎box_sdk_gen/schemas/metadata_template.py‎

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class MetadataTemplateFieldsTypeField(str, Enum):
2121
DATE = 'date'
2222
ENUM = 'enum'
2323
MULTISELECT = 'multiSelect'
24-
INTEGER = 'integer'
2524
TAXONOMY = 'taxonomy'
25+
INTEGER = 'integer'
2626

2727

2828
class MetadataTemplateFieldsOptionsField(BaseObject):
@@ -39,13 +39,50 @@ def __init__(self, key: str, *, id: Optional[str] = None, **kwargs):
3939
self.id = id
4040

4141

42+
class MetadataTemplateFieldsOptionsRulesField(BaseObject):
43+
_fields_to_json_mapping: Dict[str, str] = {
44+
'multi_select': 'multiSelect',
45+
'selectable_levels': 'selectableLevels',
46+
**BaseObject._fields_to_json_mapping,
47+
}
48+
_json_to_fields_mapping: Dict[str, str] = {
49+
'multiSelect': 'multi_select',
50+
'selectableLevels': 'selectable_levels',
51+
**BaseObject._json_to_fields_mapping,
52+
}
53+
54+
def __init__(
55+
self,
56+
*,
57+
multi_select: Optional[bool] = None,
58+
selectable_levels: Optional[List[int]] = None,
59+
**kwargs
60+
):
61+
"""
62+
:param multi_select: Whether to allow users to select multiple values., defaults to None
63+
:type multi_select: Optional[bool], optional
64+
:param selectable_levels: An array of integers defining which levels of the taxonomy are
65+
selectable by users., defaults to None
66+
:type selectable_levels: Optional[List[int]], optional
67+
"""
68+
super().__init__(**kwargs)
69+
self.multi_select = multi_select
70+
self.selectable_levels = selectable_levels
71+
72+
4273
class MetadataTemplateFieldsField(BaseObject):
4374
_fields_to_json_mapping: Dict[str, str] = {
4475
'display_name': 'displayName',
76+
'taxonomy_key': 'taxonomyKey',
77+
'taxonomy_id': 'taxonomyId',
78+
'options_rules': 'optionsRules',
4579
**BaseObject._fields_to_json_mapping,
4680
}
4781
_json_to_fields_mapping: Dict[str, str] = {
4882
'displayName': 'display_name',
83+
'taxonomyKey': 'taxonomy_key',
84+
'taxonomyId': 'taxonomy_id',
85+
'optionsRules': 'options_rules',
4986
**BaseObject._json_to_fields_mapping,
5087
}
5188
_discriminator = 'type', {
@@ -54,8 +91,8 @@ class MetadataTemplateFieldsField(BaseObject):
5491
'date',
5592
'enum',
5693
'multiSelect',
57-
'integer',
5894
'taxonomy',
95+
'integer',
5996
}
6097

6198
def __init__(
@@ -67,6 +104,10 @@ def __init__(
67104
description: Optional[str] = None,
68105
hidden: Optional[bool] = None,
69106
options: Optional[List[MetadataTemplateFieldsOptionsField]] = None,
107+
taxonomy_key: Optional[str] = None,
108+
taxonomy_id: Optional[str] = None,
109+
namespace: Optional[str] = None,
110+
options_rules: Optional[MetadataTemplateFieldsOptionsRulesField] = None,
70111
id: Optional[str] = None,
71112
**kwargs
72113
):
@@ -76,9 +117,12 @@ def __init__(
76117
date-time picker.
77118
78119
Additionally, metadata templates support an `enum` field for a basic list
79-
of items, and ` multiSelect` field for a similar list of items where the
120+
of items, and `multiSelect` field for a similar list of items where the
80121
user can select more than one value.
81122
123+
Metadata taxonomies are also supported as a `taxonomy` field type
124+
with a specific set of additional properties, which describe its structure.
125+
82126
**Note**: The `integer` value is deprecated.
83127
It is still present in the response,
84128
but cannot be used in the POST request.
@@ -97,6 +141,18 @@ def __init__(
97141
:param options: A list of options for this field. This is used in combination
98142
with the `enum` and `multiSelect` field types., defaults to None
99143
:type options: Optional[List[MetadataTemplateFieldsOptionsField]], optional
144+
:param taxonomy_key: The unique key of the metadata taxonomy to use for this taxonomy field.
145+
This property is required when the field `type` is set to `taxonomy`., defaults to None
146+
:type taxonomy_key: Optional[str], optional
147+
:param taxonomy_id: The unique ID of the metadata taxonomy to use for this taxonomy field.
148+
This property is required when the field `type` is set to `taxonomy`., defaults to None
149+
:type taxonomy_id: Optional[str], optional
150+
:param namespace: The namespace of the metadata taxonomy to use for this taxonomy field.
151+
This property is required when the field `type` is set to `taxonomy`., defaults to None
152+
:type namespace: Optional[str], optional
153+
:param options_rules: An object defining additional rules for the options of the taxonomy field.
154+
This property is required when the field `type` is set to `taxonomy`., defaults to None
155+
:type options_rules: Optional[MetadataTemplateFieldsOptionsRulesField], optional
100156
:param id: The unique ID of the metadata template field., defaults to None
101157
:type id: Optional[str], optional
102158
"""
@@ -107,6 +163,10 @@ def __init__(
107163
self.description = description
108164
self.hidden = hidden
109165
self.options = options
166+
self.taxonomy_key = taxonomy_key
167+
self.taxonomy_id = taxonomy_id
168+
self.namespace = namespace
169+
self.options_rules = options_rules
110170
self.id = id
111171

112172

0 commit comments

Comments
 (0)