twitter-openapi-typescript-generated 0.0.17 → 0.0.18

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.
Files changed (41) hide show
  1. package/.openapi-generator/FILES +1 -0
  2. package/README.md +2 -2
  3. package/dist/models/Entities.d.ts +7 -0
  4. package/dist/models/Entities.d.ts.map +1 -1
  5. package/dist/models/Entities.js +3 -0
  6. package/dist/models/Entities.js.map +1 -1
  7. package/dist/models/Timestamp.d.ts +44 -0
  8. package/dist/models/Timestamp.d.ts.map +1 -0
  9. package/dist/models/Timestamp.js +57 -0
  10. package/dist/models/Timestamp.js.map +1 -0
  11. package/dist/models/TweetLegacy.d.ts +2 -1
  12. package/dist/models/TweetLegacy.d.ts.map +1 -1
  13. package/dist/models/TweetLegacy.js +3 -2
  14. package/dist/models/TweetLegacy.js.map +1 -1
  15. package/dist/models/UserUnavailable.d.ts +6 -0
  16. package/dist/models/UserUnavailable.d.ts.map +1 -1
  17. package/dist/models/UserUnavailable.js +3 -0
  18. package/dist/models/UserUnavailable.js.map +1 -1
  19. package/dist/models/index.d.ts +1 -0
  20. package/dist/models/index.d.ts.map +1 -1
  21. package/dist/models/index.js +1 -0
  22. package/dist/models/index.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/models/Entities.ts +14 -0
  25. package/src/models/Timestamp.ts +84 -0
  26. package/src/models/TweetLegacy.ts +3 -2
  27. package/src/models/UserUnavailable.ts +8 -0
  28. package/src/models/index.ts +1 -0
  29. package/tools/openapi-generator-config.yaml +1 -1
  30. package/twitter-openapi/.vscode/launch.json +2 -1
  31. package/twitter-openapi/.vscode/tasks.json +0 -2
  32. package/twitter-openapi/dist/compatible/openapi-3.0.yaml +22 -1
  33. package/twitter-openapi/dist/compatible_discriminator/openapi-3.0.yaml +6149 -0
  34. package/twitter-openapi/dist/docs/openapi-3.0.yaml +22 -1
  35. package/twitter-openapi/src/openapi/schemas/tweet.yaml +22 -2
  36. package/twitter-openapi/src/openapi/schemas/user.yaml +2 -0
  37. package/twitter-openapi/test/python/openapi-generator-config.yaml +1 -1
  38. package/twitter-openapi/test/python/test_serialize.py +1 -0
  39. package/twitter-openapi/tools/build_config.py +28 -3
  40. package/twitter-openapi/tools/hooks.py +9 -1
  41. 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'
@@ -1793,6 +1797,20 @@ components:
1793
1797
  $ref: '#/components/schemas/Timeline'
1794
1798
  required:
1795
1799
  - timeline
1800
+ Timestamp:
1801
+ properties:
1802
+ indices:
1803
+ items:
1804
+ type: integer
1805
+ type: array
1806
+ seconds:
1807
+ type: integer
1808
+ text:
1809
+ type: string
1810
+ required:
1811
+ - indices
1812
+ - seconds
1813
+ - text
1796
1814
  TopicContext:
1797
1815
  properties:
1798
1816
  description:
@@ -2159,10 +2177,11 @@ components:
2159
2177
  limited_actions:
2160
2178
  enum:
2161
2179
  - limited_replies
2162
- - community_tweet_non_member_public_community
2163
2180
  - non_compliant
2164
2181
  - dynamic_product_ad
2165
2182
  - stale_tweet
2183
+ - community_tweet_non_member_public_community
2184
+ - community_tweet_non_member_closed_community
2166
2185
  type: string
2167
2186
  place:
2168
2187
  additionalProperties: true
@@ -2790,6 +2809,8 @@ components:
2790
2809
  properties:
2791
2810
  __typename:
2792
2811
  $ref: '#/components/schemas/TypeName'
2812
+ message:
2813
+ type: string
2793
2814
  reason:
2794
2815
  type: string
2795
2816
  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
 
@@ -927,6 +927,7 @@ components:
927
927
  - "symbols"
928
928
  - "user_mentions"
929
929
  - "urls"
930
+ - "timestamps"
930
931
  properties:
931
932
  hashtags:
932
933
  type: array
@@ -948,6 +949,10 @@ components:
948
949
  type: array
949
950
  items:
950
951
  $ref: "#/components/schemas/Media"
952
+ timestamps:
953
+ type: array
954
+ items:
955
+ $ref: "#/components/schemas/Timestamp"
951
956
 
952
957
  Hashtag:
953
958
  type: object
@@ -1293,3 +1298,18 @@ components:
1293
1298
  resize:
1294
1299
  type: string
1295
1300
  enum: [crop, fit]
1301
+
1302
+ Timestamp:
1303
+ required:
1304
+ - "indices"
1305
+ - "seconds"
1306
+ - "text"
1307
+ properties:
1308
+ indices:
1309
+ type: array
1310
+ items:
1311
+ type: integer
1312
+ seconds:
1313
+ type: integer
1314
+ text:
1315
+ type: string
@@ -356,3 +356,5 @@ components:
356
356
  $ref: "./typename.yaml#/components/schemas/TypeName" # UserUnavailable
357
357
  reason:
358
358
  type: string
359
+ message:
360
+ type: string
@@ -1,4 +1,4 @@
1
- inputSpec: dist/compatible/openapi-3.0.yaml
1
+ inputSpec: dist/compatible_discriminator/openapi-3.0.yaml
2
2
  outputDir: python_generated
3
3
 
4
4
  useOneOfDiscriminatorLookup: true
@@ -326,6 +326,7 @@ if __name__ == "__main__":
326
326
  "1697450269259522256",
327
327
  "1697450278742884799",
328
328
  "1749500209061663043",
329
+ "1759056048764469303",
329
330
  ]
330
331
  for id in ids:
331
332
  try:
@@ -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(self, queryParameterJson=True):
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(queryParameterJson=False),
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)