twitter-openapi-typescript-generated 0.0.17 → 0.0.19
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/.openapi-generator/FILES +1 -0
- package/README.md +2 -2
- package/dist/models/Entities.d.ts +7 -0
- package/dist/models/Entities.d.ts.map +1 -1
- package/dist/models/Entities.js +3 -0
- package/dist/models/Entities.js.map +1 -1
- package/dist/models/TimelineTerminateTimeline.d.ts +1 -0
- package/dist/models/TimelineTerminateTimeline.d.ts.map +1 -1
- package/dist/models/TimelineTerminateTimeline.js +2 -1
- package/dist/models/TimelineTerminateTimeline.js.map +1 -1
- package/dist/models/Timestamp.d.ts +44 -0
- package/dist/models/Timestamp.d.ts.map +1 -0
- package/dist/models/Timestamp.js +57 -0
- package/dist/models/Timestamp.js.map +1 -0
- package/dist/models/TweetLegacy.d.ts +2 -1
- package/dist/models/TweetLegacy.d.ts.map +1 -1
- package/dist/models/TweetLegacy.js +3 -2
- package/dist/models/TweetLegacy.js.map +1 -1
- package/dist/models/UserUnavailable.d.ts +6 -0
- package/dist/models/UserUnavailable.d.ts.map +1 -1
- package/dist/models/UserUnavailable.js +3 -0
- package/dist/models/UserUnavailable.js.map +1 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -0
- package/dist/models/index.js.map +1 -1
- package/package.json +1 -1
- package/src/models/Entities.ts +14 -0
- package/src/models/TimelineTerminateTimeline.ts +2 -1
- package/src/models/Timestamp.ts +84 -0
- package/src/models/TweetLegacy.ts +3 -2
- package/src/models/UserUnavailable.ts +8 -0
- package/src/models/index.ts +1 -0
- package/tools/openapi-generator-config.yaml +1 -1
- package/twitter-openapi/.vscode/launch.json +2 -1
- package/twitter-openapi/.vscode/tasks.json +0 -2
- package/twitter-openapi/dist/compatible/openapi-3.0.yaml +23 -1
- package/twitter-openapi/dist/compatible_discriminator/openapi-3.0.yaml +6150 -0
- package/twitter-openapi/dist/docs/openapi-3.0.yaml +23 -1
- package/twitter-openapi/src/openapi/schemas/instruction.yaml +1 -1
- package/twitter-openapi/src/openapi/schemas/tweet.yaml +21 -2
- package/twitter-openapi/src/openapi/schemas/user.yaml +2 -0
- package/twitter-openapi/test/python/openapi-generator-config.yaml +1 -1
- package/twitter-openapi/test/python/test_serialize.py +1 -0
- package/twitter-openapi/test/python/test_serialize_guest.py +49 -0
- package/twitter-openapi/tools/build_config.py +28 -3
- package/twitter-openapi/tools/hooks.py +9 -1
- package/twitter-openapi/test/python/replace.py +0 -23
|
@@ -564,6 +564,10 @@ components:
|
|
|
564
564
|
items:
|
|
565
565
|
$ref: '#/components/schemas/Symbol'
|
|
566
566
|
type: array
|
|
567
|
+
timestamps:
|
|
568
|
+
items:
|
|
569
|
+
$ref: '#/components/schemas/Timestamp'
|
|
570
|
+
type: array
|
|
567
571
|
urls:
|
|
568
572
|
items:
|
|
569
573
|
$ref: '#/components/schemas/Url'
|
|
@@ -1656,6 +1660,7 @@ components:
|
|
|
1656
1660
|
enum:
|
|
1657
1661
|
- Top
|
|
1658
1662
|
- Bottom
|
|
1663
|
+
- TopAndBottom
|
|
1659
1664
|
type: string
|
|
1660
1665
|
type:
|
|
1661
1666
|
$ref: '#/components/schemas/InstructionType'
|
|
@@ -1793,6 +1798,20 @@ components:
|
|
|
1793
1798
|
$ref: '#/components/schemas/Timeline'
|
|
1794
1799
|
required:
|
|
1795
1800
|
- timeline
|
|
1801
|
+
Timestamp:
|
|
1802
|
+
properties:
|
|
1803
|
+
indices:
|
|
1804
|
+
items:
|
|
1805
|
+
type: integer
|
|
1806
|
+
type: array
|
|
1807
|
+
seconds:
|
|
1808
|
+
type: integer
|
|
1809
|
+
text:
|
|
1810
|
+
type: string
|
|
1811
|
+
required:
|
|
1812
|
+
- indices
|
|
1813
|
+
- seconds
|
|
1814
|
+
- text
|
|
1796
1815
|
TopicContext:
|
|
1797
1816
|
properties:
|
|
1798
1817
|
description:
|
|
@@ -2159,10 +2178,11 @@ components:
|
|
|
2159
2178
|
limited_actions:
|
|
2160
2179
|
enum:
|
|
2161
2180
|
- limited_replies
|
|
2162
|
-
- community_tweet_non_member_public_community
|
|
2163
2181
|
- non_compliant
|
|
2164
2182
|
- dynamic_product_ad
|
|
2165
2183
|
- stale_tweet
|
|
2184
|
+
- community_tweet_non_member_public_community
|
|
2185
|
+
- community_tweet_non_member_closed_community
|
|
2166
2186
|
type: string
|
|
2167
2187
|
place:
|
|
2168
2188
|
additionalProperties: true
|
|
@@ -2790,6 +2810,8 @@ components:
|
|
|
2790
2810
|
properties:
|
|
2791
2811
|
__typename:
|
|
2792
2812
|
$ref: '#/components/schemas/TypeName'
|
|
2813
|
+
message:
|
|
2814
|
+
type: string
|
|
2793
2815
|
reason:
|
|
2794
2816
|
type: string
|
|
2795
2817
|
required:
|
|
@@ -680,7 +680,6 @@ components:
|
|
|
680
680
|
$ref: "#/components/schemas/BirdwatchEntity"
|
|
681
681
|
|
|
682
682
|
BirdwatchPivotCallToAction:
|
|
683
|
-
# {'prompt': 'Do you find this helpful?', 'title': 'Rate it', 'destinationUrl': 'https://twitter.com/i/birdwatch/n/1710821689636934115'}
|
|
684
683
|
required:
|
|
685
684
|
- "prompt"
|
|
686
685
|
- "title"
|
|
@@ -906,10 +905,11 @@ components:
|
|
|
906
905
|
type: string
|
|
907
906
|
enum:
|
|
908
907
|
- "limited_replies"
|
|
909
|
-
- "community_tweet_non_member_public_community"
|
|
910
908
|
- "non_compliant"
|
|
911
909
|
- "dynamic_product_ad"
|
|
912
910
|
- "stale_tweet"
|
|
911
|
+
- "community_tweet_non_member_public_community"
|
|
912
|
+
- "community_tweet_non_member_closed_community"
|
|
913
913
|
place:
|
|
914
914
|
additionalProperties: true # todo
|
|
915
915
|
|
|
@@ -948,6 +948,10 @@ components:
|
|
|
948
948
|
type: array
|
|
949
949
|
items:
|
|
950
950
|
$ref: "#/components/schemas/Media"
|
|
951
|
+
timestamps:
|
|
952
|
+
type: array
|
|
953
|
+
items:
|
|
954
|
+
$ref: "#/components/schemas/Timestamp"
|
|
951
955
|
|
|
952
956
|
Hashtag:
|
|
953
957
|
type: object
|
|
@@ -1293,3 +1297,18 @@ components:
|
|
|
1293
1297
|
resize:
|
|
1294
1298
|
type: string
|
|
1295
1299
|
enum: [crop, fit]
|
|
1300
|
+
|
|
1301
|
+
Timestamp:
|
|
1302
|
+
required:
|
|
1303
|
+
- "indices"
|
|
1304
|
+
- "seconds"
|
|
1305
|
+
- "text"
|
|
1306
|
+
properties:
|
|
1307
|
+
indices:
|
|
1308
|
+
type: array
|
|
1309
|
+
items:
|
|
1310
|
+
type: integer
|
|
1311
|
+
seconds:
|
|
1312
|
+
type: integer
|
|
1313
|
+
text:
|
|
1314
|
+
type: string
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import openapi_client as pt
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_kwargs(key, additional):
|
|
8
|
+
kwargs = {"path_query_id": placeholder[key]["queryId"]}
|
|
9
|
+
if placeholder[key].get("variables") is not None:
|
|
10
|
+
kwargs["variables"] = json.dumps(placeholder[key]["variables"] | additional)
|
|
11
|
+
if placeholder[key].get("features") is not None:
|
|
12
|
+
kwargs["features"] = json.dumps(placeholder[key]["features"])
|
|
13
|
+
if placeholder[key].get("fieldToggles") is not None:
|
|
14
|
+
kwargs["field_toggles"] = json.dumps(placeholder[key]["fieldToggles"])
|
|
15
|
+
return kwargs
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if __name__ == "__main__":
|
|
19
|
+
if Path("cookie.json").exists():
|
|
20
|
+
with open("cookie.json", "r") as f:
|
|
21
|
+
cookies = json.load(f)
|
|
22
|
+
cookies_str = "; ".join([f"{k}={v}" for k, v in cookies.items()])
|
|
23
|
+
|
|
24
|
+
with open("src/config/placeholder.json", "r") as f:
|
|
25
|
+
placeholder = json.load(f)
|
|
26
|
+
|
|
27
|
+
api_conf = pt.Configuration(
|
|
28
|
+
api_key={
|
|
29
|
+
"ClientLanguage": "en",
|
|
30
|
+
"ActiveUser": "yes",
|
|
31
|
+
"GuestToken": cookies["gt"],
|
|
32
|
+
},
|
|
33
|
+
)
|
|
34
|
+
api_conf.access_token = "AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA"
|
|
35
|
+
api_client = pt.ApiClient(configuration=api_conf, cookie=cookies_str)
|
|
36
|
+
api_client.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
|
|
37
|
+
|
|
38
|
+
pt.TweetApi(api_client).get_user_tweets_with_http_info(
|
|
39
|
+
**get_kwargs("UserTweets", {}),
|
|
40
|
+
)
|
|
41
|
+
pt.TweetApi(api_client).get_user_highlights_tweets_with_http_info(
|
|
42
|
+
**get_kwargs("UserHighlightsTweets", {}),
|
|
43
|
+
)
|
|
44
|
+
pt.DefaultApi(api_client).get_tweet_result_by_rest_id_with_http_info(
|
|
45
|
+
**get_kwargs("TweetResultByRestId", {}),
|
|
46
|
+
)
|
|
47
|
+
pt.UserApi(api_client).get_user_by_screen_name_with_http_info(
|
|
48
|
+
**get_kwargs("UserByScreenName", {})
|
|
49
|
+
)
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
from hooks import
|
|
1
|
+
from hooks import (
|
|
2
|
+
AddParametersOnBody,
|
|
3
|
+
AddParametersOnContent,
|
|
4
|
+
AddParametersOnParameters,
|
|
5
|
+
AddPathQueryIdOnParameters,
|
|
6
|
+
AddSecuritySchemesOnSecuritySchemes,
|
|
7
|
+
RemoveErrorHandle,
|
|
8
|
+
SetResponsesHeader,
|
|
9
|
+
)
|
|
2
10
|
|
|
3
11
|
|
|
4
12
|
class Config:
|
|
5
13
|
OUTPUT_DIR = "dist/{0}"
|
|
6
14
|
INPUT_DIR = "src/openapi"
|
|
7
15
|
|
|
8
|
-
def hooks_generator(
|
|
16
|
+
def hooks_generator(
|
|
17
|
+
self,
|
|
18
|
+
queryParameterJson=True,
|
|
19
|
+
removeLegacyDiscriminatorBehavior=False,
|
|
20
|
+
):
|
|
9
21
|
# https://stackoverflow.com/questions/34820064/defining-an-api-with-swagger-get-call-that-uses-json-in-parameters/45223964
|
|
10
22
|
if queryParameterJson:
|
|
11
23
|
# ["parameters"][0]["content"]["application/json"]["schema"]
|
|
@@ -22,6 +34,11 @@ class Config:
|
|
|
22
34
|
ignoreKeys=["queryId"],
|
|
23
35
|
)
|
|
24
36
|
|
|
37
|
+
# https://github.com/OpenAPITools/openapi-generator/issues/15373
|
|
38
|
+
additionalHooks = []
|
|
39
|
+
if removeLegacyDiscriminatorBehavior:
|
|
40
|
+
additionalHooks.append(RemoveErrorHandle())
|
|
41
|
+
|
|
25
42
|
return {
|
|
26
43
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
|
27
44
|
"schemas": [],
|
|
@@ -31,6 +48,7 @@ class Config:
|
|
|
31
48
|
SetResponsesHeader(suffix=None),
|
|
32
49
|
AddPathQueryIdOnParameters(split=-1),
|
|
33
50
|
getParamHook,
|
|
51
|
+
*additionalHooks,
|
|
34
52
|
]
|
|
35
53
|
for key in ["default", "user", "users", "user-list", "tweet"]
|
|
36
54
|
}
|
|
@@ -43,6 +61,7 @@ class Config:
|
|
|
43
61
|
schemaType=None,
|
|
44
62
|
contentType="application/json",
|
|
45
63
|
),
|
|
64
|
+
*additionalHooks,
|
|
46
65
|
]
|
|
47
66
|
for key in ["post"]
|
|
48
67
|
}
|
|
@@ -70,5 +89,11 @@ class Config:
|
|
|
70
89
|
def main(self):
|
|
71
90
|
return {
|
|
72
91
|
"docs": self.hooks_generator(),
|
|
73
|
-
"compatible": self.hooks_generator(
|
|
92
|
+
"compatible": self.hooks_generator(
|
|
93
|
+
queryParameterJson=False,
|
|
94
|
+
),
|
|
95
|
+
"compatible_discriminator": self.hooks_generator(
|
|
96
|
+
queryParameterJson=False,
|
|
97
|
+
removeLegacyDiscriminatorBehavior=True,
|
|
98
|
+
),
|
|
74
99
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import yaml
|
|
2
1
|
import json
|
|
3
2
|
|
|
3
|
+
import yaml
|
|
4
|
+
|
|
4
5
|
|
|
5
6
|
class HookBase:
|
|
6
7
|
PLACEHOLDER: dict
|
|
@@ -193,6 +194,13 @@ class AddPathQueryIdOnParameters(RequestHookBase):
|
|
|
193
194
|
return path, value
|
|
194
195
|
|
|
195
196
|
|
|
197
|
+
class RemoveErrorHandle(RequestHookBase):
|
|
198
|
+
def hook(self, path: str, value: dict):
|
|
199
|
+
content = value["responses"]["200"]["content"]["application/json"]
|
|
200
|
+
content["schema"] = content["schema"]["oneOf"][0]
|
|
201
|
+
return path, value
|
|
202
|
+
|
|
203
|
+
|
|
196
204
|
# OnParameters
|
|
197
205
|
|
|
198
206
|
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import glob
|
|
2
|
-
|
|
3
|
-
for file in glob.glob("python_generated/openapi_client/models/*.py"):
|
|
4
|
-
with open(file, "r") as f:
|
|
5
|
-
text = f.read()
|
|
6
|
-
|
|
7
|
-
indent = " "
|
|
8
|
-
|
|
9
|
-
text = text.replace(
|
|
10
|
-
f"{indent}{indent}try:",
|
|
11
|
-
f"{indent}{indent}if match == 0:",
|
|
12
|
-
)
|
|
13
|
-
text = text.replace(
|
|
14
|
-
f"{indent}{indent}except (ValidationError, ValueError) as e:",
|
|
15
|
-
f"{indent}{indent}else:",
|
|
16
|
-
)
|
|
17
|
-
text = text.replace(
|
|
18
|
-
f"{indent}{indent}{indent}error_messages.append(str(e))",
|
|
19
|
-
f"{indent}{indent}{indent}pass",
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
with open(file, "w") as f:
|
|
23
|
-
f.write(text)
|