Skip to content

Commit 8feb60f

Browse files
author
Zafer Genckaya
committed
Temporarily stop using discriminator logics for the inheritance
It may be re-enable when we pull updates from openapi-generator project
1 parent e5cda1a commit 8feb60f

File tree

7 files changed

+103
-24
lines changed

7 files changed

+103
-24
lines changed

docs/TeamResponder.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## Properties
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6+
**type** | **str** | |
7+
**id** | **str** | |
68
**name** | **str** | | [optional]
79

810
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

docs/UserResponder.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
## Properties
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6-
**id** | **str** | | [optional]
6+
**type** | **str** | |
7+
**id** | **str** | |
78

89
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
910

opsgenie-oas.json

-3
Original file line numberDiff line numberDiff line change
@@ -4518,7 +4518,6 @@
45184518
"Responder": {
45194519
"x-opsgenie-domain": "common",
45204520
"type": "object",
4521-
"discriminator": "type",
45224521
"required": [
45234522
"type",
45244523
"id"
@@ -4538,7 +4537,6 @@
45384537
},
45394538
"UserResponder": {
45404539
"x-opsgenie-domain": "common",
4541-
"x-discriminator-value": "user",
45424540
"description": "User responder",
45434541
"allOf": [
45444542
{
@@ -4556,7 +4554,6 @@
45564554
},
45574555
"TeamResponder": {
45584556
"x-opsgenie-domain": "common",
4559-
"x-discriminator-value": "team",
45604557
"description": "Team responder",
45614558
"allOf": [
45624559
{

opsgenie-oas.yml

-4
Original file line numberDiff line numberDiff line change
@@ -9217,8 +9217,6 @@ components:
92179217
- team
92189218
id:
92199219
type: string
9220-
discriminator:
9221-
propertyName: type
92229220
x-opsgenie-domain: common
92239221
AssignAlertPayload:
92249222
allOf:
@@ -9239,7 +9237,6 @@ components:
92399237
id:
92409238
type: string
92419239
x-opsgenie-domain: common
9242-
x-discriminator-value: user
92439240
AddTagsToAlertPayload:
92449241
allOf:
92459242
- $ref: '#/components/schemas/AlertActionPayload'
@@ -9337,7 +9334,6 @@ components:
93379334
name:
93389335
type: string
93399336
x-opsgenie-domain: common
9340-
x-discriminator-value: team
93419337
WeekdayTimeRestrictionInterval:
93429338
description: Weekday time restriction interval
93439339
allOf:

opsgenie_sdk/models/responder.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,12 @@ class Responder(object):
4141
'id': 'id'
4242
}
4343

44-
discriminator_value_class_map = {
45-
'user': 'UserResponder',
46-
'team': 'TeamResponder'
47-
}
48-
4944
def __init__(self, type=None, id=None): # noqa: E501
5045
"""Responder - a model defined in OpenAPI""" # noqa: E501
5146

5247
self._type = None
5348
self._id = None
54-
self.discriminator = 'type'
49+
self.discriminator = None
5550

5651
self.type = type
5752
self.id = id
@@ -108,12 +103,6 @@ def id(self, id):
108103

109104
self._id = id
110105

111-
def get_real_child_model(self, data):
112-
"""Returns the real base class specified by the discriminator"""
113-
discriminator_key = self.attribute_map[self.discriminator]
114-
discriminator_value = data[discriminator_key]
115-
return self.discriminator_value_class_map.get(discriminator_value)
116-
117106
def to_dict(self):
118107
"""Returns the model properties as a dict"""
119108
result = {}

opsgenie_sdk/models/team_responder.py

+61-1
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,82 @@ class TeamResponder(object):
3232
and the value is json key in definition.
3333
"""
3434
openapi_types = {
35+
'type': 'str',
36+
'id': 'str',
3537
'name': 'str'
3638
}
3739

3840
attribute_map = {
41+
'type': 'type',
42+
'id': 'id',
3943
'name': 'name'
4044
}
4145

42-
def __init__(self, name=None): # noqa: E501
46+
def __init__(self, type=None, id=None, name=None): # noqa: E501
4347
"""TeamResponder - a model defined in OpenAPI""" # noqa: E501
4448

49+
self._type = None
50+
self._id = None
4551
self._name = None
4652
self.discriminator = None
4753

54+
self.type = type
55+
self.id = id
4856
if name is not None:
4957
self.name = name
5058

59+
@property
60+
def type(self):
61+
"""Gets the type of this TeamResponder. # noqa: E501
62+
63+
64+
:return: The type of this TeamResponder. # noqa: E501
65+
:rtype: str
66+
"""
67+
return self._type
68+
69+
@type.setter
70+
def type(self, type):
71+
"""Sets the type of this TeamResponder.
72+
73+
74+
:param type: The type of this TeamResponder. # noqa: E501
75+
:type: str
76+
"""
77+
if type is None:
78+
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
79+
allowed_values = ["user", "team"] # noqa: E501
80+
if type not in allowed_values:
81+
raise ValueError(
82+
"Invalid value for `type` ({0}), must be one of {1}" # noqa: E501
83+
.format(type, allowed_values)
84+
)
85+
86+
self._type = type
87+
88+
@property
89+
def id(self):
90+
"""Gets the id of this TeamResponder. # noqa: E501
91+
92+
93+
:return: The id of this TeamResponder. # noqa: E501
94+
:rtype: str
95+
"""
96+
return self._id
97+
98+
@id.setter
99+
def id(self, id):
100+
"""Sets the id of this TeamResponder.
101+
102+
103+
:param id: The id of this TeamResponder. # noqa: E501
104+
:type: str
105+
"""
106+
if id is None:
107+
raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501
108+
109+
self._id = id
110+
51111
@property
52112
def name(self):
53113
"""Gets the name of this TeamResponder. # noqa: E501

opsgenie_sdk/models/user_responder.py

+37-3
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,53 @@ class UserResponder(object):
3232
and the value is json key in definition.
3333
"""
3434
openapi_types = {
35+
'type': 'str',
3536
'id': 'str'
3637
}
3738

3839
attribute_map = {
40+
'type': 'type',
3941
'id': 'id'
4042
}
4143

42-
def __init__(self, id=None): # noqa: E501
44+
def __init__(self, type=None, id=None): # noqa: E501
4345
"""UserResponder - a model defined in OpenAPI""" # noqa: E501
4446

47+
self._type = None
4548
self._id = None
4649
self.discriminator = None
4750

48-
if id is not None:
49-
self.id = id
51+
self.type = type
52+
self.id = id
53+
54+
@property
55+
def type(self):
56+
"""Gets the type of this UserResponder. # noqa: E501
57+
58+
59+
:return: The type of this UserResponder. # noqa: E501
60+
:rtype: str
61+
"""
62+
return self._type
63+
64+
@type.setter
65+
def type(self, type):
66+
"""Sets the type of this UserResponder.
67+
68+
69+
:param type: The type of this UserResponder. # noqa: E501
70+
:type: str
71+
"""
72+
if type is None:
73+
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
74+
allowed_values = ["user", "team"] # noqa: E501
75+
if type not in allowed_values:
76+
raise ValueError(
77+
"Invalid value for `type` ({0}), must be one of {1}" # noqa: E501
78+
.format(type, allowed_values)
79+
)
80+
81+
self._type = type
5082

5183
@property
5284
def id(self):
@@ -66,6 +98,8 @@ def id(self, id):
6698
:param id: The id of this UserResponder. # noqa: E501
6799
:type: str
68100
"""
101+
if id is None:
102+
raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501
69103

70104
self._id = id
71105

0 commit comments

Comments
 (0)