mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-10 15:20:26 +01:00
Merge branch 'main' into dev
Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
commit
6394006bc1
22 changed files with 140 additions and 47 deletions
2
.github/workflows/test-build.yaml
vendored
2
.github/workflows/test-build.yaml
vendored
|
|
@ -39,7 +39,7 @@ jobs:
|
|||
|
||||
- name: Get Openapi Generator
|
||||
run: |
|
||||
wget https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.2.0/openapi-generator-cli.jar -O openapi-generator-cli.jar --no-verbose
|
||||
wget https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.3.0/openapi-generator-cli.jar -O openapi-generator-cli.jar --no-verbose
|
||||
if: steps.openapi-generator-cache.outputs.cache-hit != 'true'
|
||||
|
||||
# Python Setup
|
||||
|
|
|
|||
5
.github/workflows/test-python.yaml
vendored
5
.github/workflows/test-python.yaml
vendored
|
|
@ -3,6 +3,7 @@ name: test-python
|
|||
on:
|
||||
pull_request_target:
|
||||
types: [labeled]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build_and_preview:
|
||||
|
|
@ -12,6 +13,8 @@ jobs:
|
|||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: "${{ github.event.pull_request.merge_commit_sha }}"
|
||||
|
||||
# Openapi Generator Setup
|
||||
- name: Get OpenJDK 11
|
||||
|
|
@ -37,7 +40,7 @@ jobs:
|
|||
|
||||
- name: Get Openapi Generator
|
||||
run: |
|
||||
wget https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.2.0/openapi-generator-cli.jar -O openapi-generator-cli.jar --no-verbose
|
||||
wget https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.3.0/openapi-generator-cli.jar -O openapi-generator-cli.jar --no-verbose
|
||||
if: steps.openapi-generator-cache.outputs.cache-hit != 'true'
|
||||
|
||||
# Python Setup
|
||||
|
|
|
|||
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
|
|
@ -33,14 +33,14 @@
|
|||
"command": [
|
||||
"python3 -m venv .venv;",
|
||||
".venv/bin/python3 -m pip install -r requirements.txt;",
|
||||
"wget https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.2.0/openapi-generator-cli.jar -O openapi-generator-cli.jar;"
|
||||
"wget https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.3.0/openapi-generator-cli.jar -O openapi-generator-cli.jar;"
|
||||
]
|
||||
},
|
||||
"windows": {
|
||||
"command": [
|
||||
"python -m venv .venv;",
|
||||
".venv/Scripts/python -m pip install -r requirements.txt;",
|
||||
"Invoke-WebRequest https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.2.0/openapi-generator-cli.jar -OutFile openapi-generator-cli.jar;"
|
||||
"Invoke-WebRequest https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.3.0/openapi-generator-cli.jar -OutFile openapi-generator-cli.jar;"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
Twitter OpenAPI(Swagger) specification
|
||||
|
||||
- [Python](https://github.com/fa0311/twitter_openapi_python)
|
||||
- [Dart](https://github.com/fa0311/twitter_openapi_dart)
|
||||
- [TypeScript](https://github.com/fa0311/twitter-openapi-typescript)
|
||||
- [React Documents](https://github.com/fa0311/twitter-openapi-docs)
|
||||
|
|
|
|||
8
dist/compatible/openapi-3.0.yaml
vendored
8
dist/compatible/openapi-3.0.yaml
vendored
|
|
@ -137,11 +137,13 @@ security:
|
|||
servers:
|
||||
- url: https://twitter.com/i/api
|
||||
tags:
|
||||
- description: response User
|
||||
- description: Responses containing User objects.
|
||||
name: user
|
||||
- description: response User list
|
||||
- description: Responses containing List[User] objects.
|
||||
name: users
|
||||
- description: Responses containing instruction objects.
|
||||
name: user-list
|
||||
- description: response tweet
|
||||
- description: Responses containing instruction objects.
|
||||
name: tweet
|
||||
- description: post
|
||||
name: post
|
||||
|
|
|
|||
1
dist/compatible/paths/other.yaml
vendored
1
dist/compatible/paths/other.yaml
vendored
|
|
@ -94,7 +94,6 @@ paths:
|
|||
schema:
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/OtherResponse'
|
||||
- $ref: ./../schemas/error.yaml#/components/schemas/Errors
|
||||
description: Successful operation
|
||||
tags:
|
||||
- other
|
||||
|
|
|
|||
2
dist/compatible/paths/user.yaml
vendored
2
dist/compatible/paths/user.yaml
vendored
|
|
@ -230,4 +230,4 @@ paths:
|
|||
schema:
|
||||
type: string
|
||||
tags:
|
||||
- user
|
||||
- users
|
||||
|
|
|
|||
1
dist/compatible/schemas/typename.yaml
vendored
1
dist/compatible/schemas/typename.yaml
vendored
|
|
@ -14,6 +14,7 @@ components:
|
|||
- TweetUnavailable
|
||||
- Tweet
|
||||
- User
|
||||
- UserUnavailable
|
||||
type: string
|
||||
info:
|
||||
title: Twitter OpenAPI
|
||||
|
|
|
|||
25
dist/compatible/schemas/user.yaml
vendored
25
dist/compatible/schemas/user.yaml
vendored
|
|
@ -165,10 +165,7 @@ components:
|
|||
- entities
|
||||
- fast_followers_count
|
||||
- favourites_count
|
||||
- follow_request_sent
|
||||
- followed_by
|
||||
- followers_count
|
||||
- following
|
||||
- friends_count
|
||||
- has_custom_timelines
|
||||
- is_translator
|
||||
|
|
@ -178,12 +175,10 @@ components:
|
|||
- muting
|
||||
- name
|
||||
- normal_followers_count
|
||||
- notifications
|
||||
- pinned_tweet_ids_str
|
||||
- possibly_sensitive
|
||||
- profile_image_url_https
|
||||
- profile_interstitial_type
|
||||
- protected
|
||||
- screen_name
|
||||
- status
|
||||
- statuses_count
|
||||
|
|
@ -199,9 +194,27 @@ components:
|
|||
UserResults:
|
||||
properties:
|
||||
result:
|
||||
$ref: '#/components/schemas/User'
|
||||
$ref: '#/components/schemas/UserUnion'
|
||||
required:
|
||||
- result
|
||||
UserUnavailable:
|
||||
properties:
|
||||
__typename:
|
||||
$ref: ./typename.yaml#/components/schemas/TypeName
|
||||
reason:
|
||||
type: string
|
||||
required:
|
||||
- __typename
|
||||
- reason
|
||||
UserUnion:
|
||||
discriminator:
|
||||
mapping":
|
||||
User: '#/components/schemas/User'
|
||||
UserUnavailable: '#/components/schemas/UserUnavailable'
|
||||
propertyName: __typename
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/User'
|
||||
- $ref: '#/components/schemas/UserUnavailable'
|
||||
info:
|
||||
title: Twitter OpenAPI
|
||||
version: 0.0.1
|
||||
|
|
|
|||
8
dist/docs/openapi-3.0.yaml
vendored
8
dist/docs/openapi-3.0.yaml
vendored
|
|
@ -137,11 +137,13 @@ security:
|
|||
servers:
|
||||
- url: https://twitter.com/i/api
|
||||
tags:
|
||||
- description: response User
|
||||
- description: Responses containing User objects.
|
||||
name: user
|
||||
- description: response User list
|
||||
- description: Responses containing List[User] objects.
|
||||
name: users
|
||||
- description: Responses containing instruction objects.
|
||||
name: user-list
|
||||
- description: response tweet
|
||||
- description: Responses containing instruction objects.
|
||||
name: tweet
|
||||
- description: post
|
||||
name: post
|
||||
|
|
|
|||
1
dist/docs/paths/other.yaml
vendored
1
dist/docs/paths/other.yaml
vendored
|
|
@ -94,7 +94,6 @@ paths:
|
|||
schema:
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/OtherResponse'
|
||||
- $ref: ./../schemas/error.yaml#/components/schemas/Errors
|
||||
description: Successful operation
|
||||
tags:
|
||||
- other
|
||||
|
|
|
|||
2
dist/docs/paths/user.yaml
vendored
2
dist/docs/paths/user.yaml
vendored
|
|
@ -335,4 +335,4 @@ paths:
|
|||
schema:
|
||||
type: string
|
||||
tags:
|
||||
- user
|
||||
- users
|
||||
|
|
|
|||
1
dist/docs/schemas/typename.yaml
vendored
1
dist/docs/schemas/typename.yaml
vendored
|
|
@ -14,6 +14,7 @@ components:
|
|||
- TweetUnavailable
|
||||
- Tweet
|
||||
- User
|
||||
- UserUnavailable
|
||||
type: string
|
||||
info:
|
||||
title: Twitter OpenAPI
|
||||
|
|
|
|||
25
dist/docs/schemas/user.yaml
vendored
25
dist/docs/schemas/user.yaml
vendored
|
|
@ -165,10 +165,7 @@ components:
|
|||
- entities
|
||||
- fast_followers_count
|
||||
- favourites_count
|
||||
- follow_request_sent
|
||||
- followed_by
|
||||
- followers_count
|
||||
- following
|
||||
- friends_count
|
||||
- has_custom_timelines
|
||||
- is_translator
|
||||
|
|
@ -178,12 +175,10 @@ components:
|
|||
- muting
|
||||
- name
|
||||
- normal_followers_count
|
||||
- notifications
|
||||
- pinned_tweet_ids_str
|
||||
- possibly_sensitive
|
||||
- profile_image_url_https
|
||||
- profile_interstitial_type
|
||||
- protected
|
||||
- screen_name
|
||||
- status
|
||||
- statuses_count
|
||||
|
|
@ -199,9 +194,27 @@ components:
|
|||
UserResults:
|
||||
properties:
|
||||
result:
|
||||
$ref: '#/components/schemas/User'
|
||||
$ref: '#/components/schemas/UserUnion'
|
||||
required:
|
||||
- result
|
||||
UserUnavailable:
|
||||
properties:
|
||||
__typename:
|
||||
$ref: ./typename.yaml#/components/schemas/TypeName
|
||||
reason:
|
||||
type: string
|
||||
required:
|
||||
- __typename
|
||||
- reason
|
||||
UserUnion:
|
||||
discriminator:
|
||||
mapping":
|
||||
User: '#/components/schemas/User'
|
||||
UserUnavailable: '#/components/schemas/UserUnavailable'
|
||||
propertyName: __typename
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/User'
|
||||
- $ref: '#/components/schemas/UserUnavailable'
|
||||
info:
|
||||
title: Twitter OpenAPI
|
||||
version: 0.0.1
|
||||
|
|
|
|||
|
|
@ -56,11 +56,13 @@ security:
|
|||
- AuthType: []
|
||||
tags:
|
||||
- name: user
|
||||
description: response User
|
||||
description: Responses containing User objects.
|
||||
- name: users
|
||||
description: Responses containing List[User] objects.
|
||||
- name: user-list
|
||||
description: response User list
|
||||
description: Responses containing instruction objects.
|
||||
- name: tweet
|
||||
description: response tweet
|
||||
description: Responses containing instruction objects.
|
||||
- name: post
|
||||
description: post
|
||||
- name: v1.1-get
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ paths:
|
|||
schema:
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/OtherResponse"
|
||||
- $ref: "./../schemas/error.yaml#/components/schemas/Errors"
|
||||
tags:
|
||||
- "other"
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ paths:
|
|||
- $ref: "#/components/schemas/UsersResponse"
|
||||
- $ref: "./../schemas/error.yaml#/components/schemas/Errors"
|
||||
tags:
|
||||
- "user"
|
||||
- "users"
|
||||
|
||||
components:
|
||||
schemas:
|
||||
|
|
|
|||
|
|
@ -21,4 +21,5 @@ components:
|
|||
TweetUnavailable,
|
||||
Tweet,
|
||||
User,
|
||||
UserUnavailable,
|
||||
]
|
||||
|
|
|
|||
|
|
@ -17,7 +17,17 @@ components:
|
|||
- "result"
|
||||
properties:
|
||||
result:
|
||||
$ref: "#/components/schemas/User"
|
||||
$ref: "#/components/schemas/UserUnion"
|
||||
|
||||
UserUnion:
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/User"
|
||||
- $ref: "#/components/schemas/UserUnavailable"
|
||||
discriminator:
|
||||
propertyName: __typename
|
||||
mapping": # deprecated
|
||||
User: "#/components/schemas/User"
|
||||
UserUnavailable: "#/components/schemas/UserUnavailable"
|
||||
|
||||
User:
|
||||
required:
|
||||
|
|
@ -79,10 +89,10 @@ components:
|
|||
- "entities"
|
||||
- "fast_followers_count"
|
||||
- "favourites_count"
|
||||
- "follow_request_sent"
|
||||
- "followed_by"
|
||||
# 31 # - "follow_request_sent"
|
||||
# 31 # - "followed_by"
|
||||
- "followers_count"
|
||||
- "following"
|
||||
# 31 # - "following"
|
||||
- "friends_count"
|
||||
- "has_custom_timelines"
|
||||
- "is_translator"
|
||||
|
|
@ -92,12 +102,12 @@ components:
|
|||
- "muting"
|
||||
- "name"
|
||||
- "normal_followers_count"
|
||||
- "notifications"
|
||||
# 31 # - "notifications"
|
||||
- "pinned_tweet_ids_str"
|
||||
- "possibly_sensitive"
|
||||
- "profile_image_url_https"
|
||||
- "profile_interstitial_type"
|
||||
- "protected"
|
||||
# 31 # - "protected"
|
||||
- "screen_name"
|
||||
- "status"
|
||||
- "statuses_count"
|
||||
|
|
@ -211,3 +221,13 @@ components:
|
|||
want_retweets:
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
UserUnavailable:
|
||||
required:
|
||||
- "__typename"
|
||||
- "reason"
|
||||
properties:
|
||||
__typename:
|
||||
$ref: "./typename.yaml#/components/schemas/TypeName" # UserUnavailable
|
||||
reason:
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -131,6 +131,17 @@ for file in glob.glob("cache/*.json"):
|
|||
logger.info(f"Success: {len(glob.glob('cache/*.json'))}")
|
||||
|
||||
|
||||
def error_dump(e):
|
||||
if ERROR_UNCATCHED:
|
||||
raise
|
||||
import traceback
|
||||
|
||||
logger.error("==========[STACK TRACE]==========")
|
||||
for trace in traceback.format_exc().split("\n"):
|
||||
logger.error(trace)
|
||||
logger.info("================================")
|
||||
|
||||
|
||||
api_conf = pt.Configuration(
|
||||
api_key={
|
||||
"ClientLanguage": "en",
|
||||
|
|
@ -147,7 +158,7 @@ api_client.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/5
|
|||
|
||||
error_count = 0
|
||||
|
||||
for x in [pt.DefaultApi, pt.TweetApi, pt.UserApi, pt.UserListApi]:
|
||||
for x in [pt.DefaultApi, pt.TweetApi, pt.UserApi, pt.UsersApi, pt.UserListApi]:
|
||||
for props, fn in x.__dict__.items():
|
||||
if not callable(fn):
|
||||
continue
|
||||
|
|
@ -185,15 +196,27 @@ for x in [pt.DefaultApi, pt.TweetApi, pt.UserApi, pt.UserListApi]:
|
|||
time.sleep(SLEEP_TIME)
|
||||
|
||||
except Exception as e:
|
||||
if ERROR_UNCATCHED:
|
||||
raise
|
||||
import traceback
|
||||
|
||||
logger.error("==========[STACK TRACE]==========")
|
||||
for trace in traceback.format_exc().split("\n"):
|
||||
logger.error(trace)
|
||||
logger.info("================================")
|
||||
error_dump(e)
|
||||
error_count += 1
|
||||
|
||||
|
||||
try:
|
||||
logger.info(f"Try: Self UserByScreenName Test")
|
||||
kwargs = get_kwargs("UserByScreenName", {"screen_name": "a810810931931"})
|
||||
res = pt.UserApi(api_client).get_user_by_screen_name(**kwargs).to_dict()
|
||||
if not res["data"]["user"]["result"]["legacy"]["screen_name"] == "a810810931931":
|
||||
raise Exception("UserByScreenName failed")
|
||||
except Exception as e:
|
||||
error_dump(e)
|
||||
error_count += 1
|
||||
|
||||
try:
|
||||
logger.info(f"Try: Self UserTweets Test")
|
||||
kwargs = get_kwargs("UserTweets", {"userId": "1180389371481976833"})
|
||||
pt.TweetApi(api_client).get_user_tweets(**kwargs)
|
||||
except Exception as e:
|
||||
error_dump(e)
|
||||
error_count += 1
|
||||
|
||||
if error_count > 0:
|
||||
exit(1)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Config:
|
|||
AddPathQueryIdOnParameters(split=-1),
|
||||
getParamHook,
|
||||
]
|
||||
for key in ["default", "user", "user-list", "tweet"]
|
||||
for key in ["default", "user", "users", "user-list", "tweet"]
|
||||
}
|
||||
| {
|
||||
key: [
|
||||
|
|
|
|||
|
|
@ -118,6 +118,20 @@ class SchemasCheck(SchemasHookBase):
|
|||
return value
|
||||
|
||||
|
||||
class RequiredCheck(SchemasHookBase):
|
||||
def hook(self, value: dict):
|
||||
required = value.get("required", [])
|
||||
|
||||
for key, property in value.get("properties", {}).items():
|
||||
if key in required and property.get("default") is not None:
|
||||
print(f"{key} is required and has default value")
|
||||
d = property.get("default") is None and property.get("nullable", False)
|
||||
if property not in required and d:
|
||||
print(f"{key} is not required and has no default value")
|
||||
|
||||
return value
|
||||
|
||||
|
||||
# RequestHookBase extends
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue