Skip to content

Commit a5381f2

Browse files
Apply suggestion from #83 to make the timestamp field mixed (#102)
* Apply suggestion from #83 to make the timestamp field mixed * Fix old PHPUNIT compatibility
1 parent 981a282 commit a5381f2

File tree

8 files changed

+268
-164
lines changed

8 files changed

+268
-164
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
* **Specification override** Fix some `timestamp` from integer to mixed string and integer to support old messages
6+
57
## 4.0.0 (2020-12-28)
68

79
* **Breaking** Specification update to latest Slack official version - see slackapi/slack-api-specs#44

generated/Model/ObjsComment.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ObjsComment
5252
*/
5353
protected $reactions;
5454
/**
55-
* @var int|null
55+
* @var string|int|null
5656
*/
5757
protected $timestamp;
5858
/**
@@ -186,12 +186,18 @@ public function setReactions(?array $reactions): self
186186
return $this;
187187
}
188188

189-
public function getTimestamp(): ?int
189+
/**
190+
* @return string|int|null
191+
*/
192+
public function getTimestamp()
190193
{
191194
return $this->timestamp;
192195
}
193196

194-
public function setTimestamp(?int $timestamp): self
197+
/**
198+
* @param string|int|null $timestamp
199+
*/
200+
public function setTimestamp($timestamp): self
195201
{
196202
$this->timestamp = $timestamp;
197203

generated/Model/ObjsFile.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class ObjsFile
276276
*/
277277
protected $thumbTiny;
278278
/**
279-
* @var int|null
279+
* @var string|int|null
280280
*/
281281
protected $timestamp;
282282
/**
@@ -1124,12 +1124,18 @@ public function setThumbTiny(?string $thumbTiny): self
11241124
return $this;
11251125
}
11261126

1127-
public function getTimestamp(): ?int
1127+
/**
1128+
* @return string|int|null
1129+
*/
1130+
public function getTimestamp()
11281131
{
11291132
return $this->timestamp;
11301133
}
11311134

1132-
public function setTimestamp(?int $timestamp): self
1135+
/**
1136+
* @param string|int|null $timestamp
1137+
*/
1138+
public function setTimestamp($timestamp): self
11331139
{
11341140
$this->timestamp = $timestamp;
11351141

generated/Normalizer/ObjsCommentNormalizer.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ public function denormalize($data, $class, $format = null, array $context = [])
104104
$object->setReactions(null);
105105
}
106106
if (\array_key_exists('timestamp', $data) && null !== $data['timestamp']) {
107-
$object->setTimestamp($data['timestamp']);
107+
$value_2 = $data['timestamp'];
108+
if (\is_string($data['timestamp'])) {
109+
$value_2 = $data['timestamp'];
110+
} elseif (\is_int($data['timestamp'])) {
111+
$value_2 = $data['timestamp'];
112+
}
113+
$object->setTimestamp($value_2);
108114
} elseif (\array_key_exists('timestamp', $data) && null === $data['timestamp']) {
109115
$object->setTimestamp(null);
110116
}
@@ -147,7 +153,13 @@ public function normalize($object, $format = null, array $context = [])
147153
}
148154
$data['reactions'] = $values_1;
149155
}
150-
$data['timestamp'] = $object->getTimestamp();
156+
$value_2 = $object->getTimestamp();
157+
if (\is_string($object->getTimestamp())) {
158+
$value_2 = $object->getTimestamp();
159+
} elseif (\is_int($object->getTimestamp())) {
160+
$value_2 = $object->getTimestamp();
161+
}
162+
$data['timestamp'] = $value_2;
151163
$data['user'] = $object->getUser();
152164

153165
return $data;

generated/Normalizer/ObjsFileNormalizer.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,13 @@ public function denormalize($data, $class, $format = null, array $context = [])
396396
$object->setThumbTiny(null);
397397
}
398398
if (\array_key_exists('timestamp', $data) && null !== $data['timestamp']) {
399-
$object->setTimestamp($data['timestamp']);
399+
$value_5 = $data['timestamp'];
400+
if (\is_string($data['timestamp'])) {
401+
$value_5 = $data['timestamp'];
402+
} elseif (\is_int($data['timestamp'])) {
403+
$value_5 = $data['timestamp'];
404+
}
405+
$object->setTimestamp($value_5);
400406
} elseif (\array_key_exists('timestamp', $data) && null === $data['timestamp']) {
401407
$object->setTimestamp(null);
402408
}
@@ -658,7 +664,13 @@ public function normalize($object, $format = null, array $context = [])
658664
$data['thumb_tiny'] = $object->getThumbTiny();
659665
}
660666
if (null !== $object->getTimestamp()) {
661-
$data['timestamp'] = $object->getTimestamp();
667+
$value_5 = $object->getTimestamp();
668+
if (\is_string($object->getTimestamp())) {
669+
$value_5 = $object->getTimestamp();
670+
} elseif (\is_int($object->getTimestamp())) {
671+
$value_5 = $object->getTimestamp();
672+
}
673+
$data['timestamp'] = $value_5;
662674
}
663675
if (null !== $object->getTitle()) {
664676
$data['title'] = $object->getTitle();

resources/slack-openapi-patched.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,10 @@
404404
"type": "array"
405405
},
406406
"timestamp": {
407-
"type": "integer"
407+
"type": [
408+
"integer",
409+
"string"
410+
]
408411
},
409412
"user": {
410413
"$ref": "#/definitions/defs_user_id"
@@ -1072,7 +1075,10 @@
10721075
"type": "string"
10731076
},
10741077
"timestamp": {
1075-
"type": "integer"
1078+
"type": [
1079+
"integer",
1080+
"string"
1081+
]
10761082
},
10771083
"title": {
10781084
"type": "string"

0 commit comments

Comments
 (0)