mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-11 23:50:26 +01:00
commit
68def8cc73
10 changed files with 51 additions and 36 deletions
2
.github/workflows/test-build.yaml
vendored
2
.github/workflows/test-build.yaml
vendored
|
|
@ -39,7 +39,7 @@ jobs:
|
||||||
|
|
||||||
- name: Get Openapi Generator
|
- name: Get Openapi Generator
|
||||||
run: |
|
run: |
|
||||||
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
|
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.2.0/openapi-generator-cli-7.2.0.jar -O openapi-generator-cli.jar --no-verbose
|
||||||
if: steps.openapi-generator-cache.outputs.cache-hit != 'true'
|
if: steps.openapi-generator-cache.outputs.cache-hit != 'true'
|
||||||
|
|
||||||
# Python Setup
|
# Python Setup
|
||||||
|
|
|
||||||
2
.github/workflows/test-python.yaml
vendored
2
.github/workflows/test-python.yaml
vendored
|
|
@ -40,7 +40,7 @@ jobs:
|
||||||
|
|
||||||
- name: Get Openapi Generator
|
- name: Get Openapi Generator
|
||||||
run: |
|
run: |
|
||||||
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
|
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.2.0/openapi-generator-cli-7.2.0.jar -O openapi-generator-cli.jar --no-verbose
|
||||||
if: steps.openapi-generator-cache.outputs.cache-hit != 'true'
|
if: steps.openapi-generator-cache.outputs.cache-hit != 'true'
|
||||||
|
|
||||||
# Python Setup
|
# Python Setup
|
||||||
|
|
|
||||||
8
.vscode/extensions.json
vendored
8
.vscode/extensions.json
vendored
|
|
@ -1,3 +1,9 @@
|
||||||
{
|
{
|
||||||
"recommendations": ["redhat.vscode-yaml"]
|
"recommendations": [
|
||||||
|
"redhat.vscode-yaml",
|
||||||
|
"ms-python.vscode-pylance",
|
||||||
|
"ms-python.python",
|
||||||
|
"ms-python.debugpy",
|
||||||
|
"charliermarsh.ruff"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
|
|
@ -3,7 +3,7 @@
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Python: 現在のファイル",
|
"name": "Python: 現在のファイル",
|
||||||
"type": "python",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${file}",
|
"program": "${file}",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "build",
|
"name": "build",
|
||||||
"type": "python",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "tools/build.py",
|
"program": "tools/build.py",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "test",
|
"name": "test",
|
||||||
"type": "python",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "test/python/test_serialize.py",
|
"program": "test/python/test_serialize.py",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
|
|
|
||||||
10
.vscode/settings.json
vendored
10
.vscode/settings.json
vendored
|
|
@ -5,5 +5,15 @@
|
||||||
"yaml.hover": true,
|
"yaml.hover": true,
|
||||||
"yaml.schemas": {
|
"yaml.schemas": {
|
||||||
"https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json": "src/**/*.yaml"
|
"https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json": "src/**/*.yaml"
|
||||||
|
},
|
||||||
|
"[yaml]": {
|
||||||
|
"editor.defaultFormatter": "redhat.vscode-yaml"
|
||||||
|
},
|
||||||
|
// "python.analysis.typeCheckingMode": "basic",
|
||||||
|
"[python]": {
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.organizeImports": "explicit",
|
||||||
|
"source.fixAll": "explicit",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
5
.vscode/tasks.json
vendored
5
.vscode/tasks.json
vendored
|
|
@ -17,6 +17,7 @@
|
||||||
"command": [
|
"command": [
|
||||||
".venv/Scripts/activate;",
|
".venv/Scripts/activate;",
|
||||||
"python tools/build.py;",
|
"python tools/build.py;",
|
||||||
|
"scoop reset temurin11-jdk;",
|
||||||
"java -jar openapi-generator-cli.jar generate -c test/python/openapi-generator-config.yaml -g python;",
|
"java -jar openapi-generator-cli.jar generate -c test/python/openapi-generator-config.yaml -g python;",
|
||||||
"python test/python/replace.py;",
|
"python test/python/replace.py;",
|
||||||
"python -m pip install ./python_generated;"
|
"python -m pip install ./python_generated;"
|
||||||
|
|
@ -33,14 +34,14 @@
|
||||||
"command": [
|
"command": [
|
||||||
"python3 -m venv .venv;",
|
"python3 -m venv .venv;",
|
||||||
".venv/bin/python3 -m pip install -r requirements.txt;",
|
".venv/bin/python3 -m pip install -r requirements.txt;",
|
||||||
"wget https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.3.0/openapi-generator-cli.jar -O openapi-generator-cli.jar;"
|
"wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.2.0/openapi-generator-cli-7.2.0.jar -O openapi-generator-cli.jar;"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"windows": {
|
"windows": {
|
||||||
"command": [
|
"command": [
|
||||||
"python -m venv .venv;",
|
"python -m venv .venv;",
|
||||||
".venv/Scripts/python -m pip install -r requirements.txt;",
|
".venv/Scripts/python -m pip install -r requirements.txt;",
|
||||||
"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;"
|
"Invoke-WebRequest https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.2.0/openapi-generator-cli-7.2.0.jar -OutFile openapi-generator-cli.jar;"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
dist/compatible/openapi-3.0.yaml
vendored
2
dist/compatible/openapi-3.0.yaml
vendored
|
|
@ -759,7 +759,6 @@ components:
|
||||||
itemContent:
|
itemContent:
|
||||||
$ref: '#/components/schemas/ItemContentUnion'
|
$ref: '#/components/schemas/ItemContentUnion'
|
||||||
required:
|
required:
|
||||||
- clientEventInfo
|
|
||||||
- itemContent
|
- itemContent
|
||||||
ModuleItem:
|
ModuleItem:
|
||||||
properties:
|
properties:
|
||||||
|
|
@ -1270,6 +1269,7 @@ components:
|
||||||
enum:
|
enum:
|
||||||
- Vertical
|
- Vertical
|
||||||
- VerticalConversation
|
- VerticalConversation
|
||||||
|
- VerticalGrid
|
||||||
- Carousel
|
- Carousel
|
||||||
type: string
|
type: string
|
||||||
entryType:
|
entryType:
|
||||||
|
|
|
||||||
2
dist/docs/openapi-3.0.yaml
vendored
2
dist/docs/openapi-3.0.yaml
vendored
|
|
@ -759,7 +759,6 @@ components:
|
||||||
itemContent:
|
itemContent:
|
||||||
$ref: '#/components/schemas/ItemContentUnion'
|
$ref: '#/components/schemas/ItemContentUnion'
|
||||||
required:
|
required:
|
||||||
- clientEventInfo
|
|
||||||
- itemContent
|
- itemContent
|
||||||
ModuleItem:
|
ModuleItem:
|
||||||
properties:
|
properties:
|
||||||
|
|
@ -1270,6 +1269,7 @@ components:
|
||||||
enum:
|
enum:
|
||||||
- Vertical
|
- Vertical
|
||||||
- VerticalConversation
|
- VerticalConversation
|
||||||
|
- VerticalGrid
|
||||||
- Carousel
|
- Carousel
|
||||||
type: string
|
type: string
|
||||||
entryType:
|
entryType:
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ components:
|
||||||
$ref: "#/components/schemas/ContentEntryType" # TimelineTimelineCursor
|
$ref: "#/components/schemas/ContentEntryType" # TimelineTimelineCursor
|
||||||
displayType:
|
displayType:
|
||||||
type: string
|
type: string
|
||||||
enum: [Vertical, VerticalConversation, Carousel]
|
enum: [Vertical, VerticalConversation, VerticalGrid, Carousel]
|
||||||
items:
|
items:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
|
@ -108,7 +108,6 @@ components:
|
||||||
|
|
||||||
ModuleEntry:
|
ModuleEntry:
|
||||||
required:
|
required:
|
||||||
- "clientEventInfo"
|
|
||||||
- "itemContent"
|
- "itemContent"
|
||||||
properties:
|
properties:
|
||||||
clientEventInfo:
|
clientEventInfo:
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import logging
|
|
||||||
import base64
|
import base64
|
||||||
import openapi_client as pt
|
|
||||||
from pathlib import Path
|
|
||||||
import time
|
|
||||||
import glob
|
|
||||||
import aenum
|
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
|
import glob
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import aenum
|
||||||
|
import openapi_client as pt
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s")
|
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s")
|
||||||
logger = logging.getLogger("test_serialize")
|
logger = logging.getLogger("test_serialize")
|
||||||
|
|
@ -28,14 +28,14 @@ def get_key(snake_str):
|
||||||
|
|
||||||
def get_cursor(obj, fn):
|
def get_cursor(obj, fn):
|
||||||
res = []
|
res = []
|
||||||
if type(obj) == dict:
|
if isinstance(obj, dict):
|
||||||
callback = fn(obj)
|
callback = fn(obj)
|
||||||
if callback is not None:
|
if callback is not None:
|
||||||
res.extend(callback)
|
res.extend(callback)
|
||||||
else:
|
else:
|
||||||
for v in obj.values():
|
for v in obj.values():
|
||||||
res.extend(get_cursor(v, fn))
|
res.extend(get_cursor(v, fn))
|
||||||
elif type(obj) == list:
|
elif isinstance(obj, list):
|
||||||
for v in obj:
|
for v in obj:
|
||||||
res.extend(get_cursor(v, fn))
|
res.extend(get_cursor(v, fn))
|
||||||
return res
|
return res
|
||||||
|
|
@ -77,9 +77,8 @@ def match_rate(a, b, key=""):
|
||||||
return 1
|
return 1
|
||||||
if a is False and b is None:
|
if a is False and b is None:
|
||||||
return 1
|
return 1
|
||||||
if type(a) != type(b):
|
if isinstance(a, list):
|
||||||
return match_rate_zero(key)
|
data = [match_rate(a[i], b[i], key=f"{key}[{i}]") for i in range(len(a))]
|
||||||
if type(a) == dict and type(b) == dict:
|
|
||||||
if len(a) == 0 and len(b) == 0:
|
if len(a) == 0 and len(b) == 0:
|
||||||
return 1
|
return 1
|
||||||
if len(a) == 0 or len(b) == 0:
|
if len(a) == 0 or len(b) == 0:
|
||||||
|
|
@ -88,16 +87,16 @@ def match_rate(a, b, key=""):
|
||||||
data = [match_rate(a.get(k), b.get(k), key=f"{key}.{k}") for k in a.keys()]
|
data = [match_rate(a.get(k), b.get(k), key=f"{key}.{k}") for k in a.keys()]
|
||||||
|
|
||||||
return sum(data) / len(a)
|
return sum(data) / len(a)
|
||||||
if type(a) == list and type(b) == list:
|
if isinstance(a, list) and isinstance(b, list):
|
||||||
if len(a) == 0 and len(b) == 0:
|
if len(a) == 0 and len(b) == 0:
|
||||||
return 1
|
return 1
|
||||||
if len(a) != len(b):
|
if len(a) != len(b):
|
||||||
return match_rate_zero(a, b, key=key)
|
return match_rate_zero(key)
|
||||||
data = [match_rate(a[i], b[i], key=f"{key}[{i}]") for i in range(len(a))]
|
data = [match_rate(a[i], b[i], key=f"{key}[{i}]") for i in range(len(a))]
|
||||||
return sum(data) / len(a)
|
return sum(data) / len(a)
|
||||||
if a == b:
|
if a == b:
|
||||||
return 1
|
return 1
|
||||||
return match_rate_zero(a, b, key=key)
|
return match_rate_zero(key)
|
||||||
|
|
||||||
|
|
||||||
def save_cache(data):
|
def save_cache(data):
|
||||||
|
|
@ -114,7 +113,7 @@ def task_callback(file, thread=True):
|
||||||
data = pt.__dict__[cache["type"]].from_json(cache["raw"])
|
data = pt.__dict__[cache["type"]].from_json(cache["raw"])
|
||||||
rate = match_rate(data.to_dict(), json.loads(cache["raw"]))
|
rate = match_rate(data.to_dict(), json.loads(cache["raw"]))
|
||||||
return rate, file
|
return rate, file
|
||||||
except Exception as e:
|
except Exception:
|
||||||
if thread:
|
if thread:
|
||||||
return 0, file
|
return 0, file
|
||||||
else:
|
else:
|
||||||
|
|
@ -205,7 +204,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
save_cache(
|
save_cache(
|
||||||
{
|
{
|
||||||
"raw": res.raw_data,
|
"raw": res.raw_data.decode("utf-8"),
|
||||||
"type": res.data.__class__.__name__,
|
"type": res.data.__class__.__name__,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -229,7 +228,7 @@ if __name__ == "__main__":
|
||||||
error_count += 1
|
error_count += 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.info(f"Try: Self UserByScreenName Test")
|
logger.info("Try: Self UserByScreenName Test")
|
||||||
kwargs = get_kwargs("UserByScreenName", {"screen_name": "a810810931931"})
|
kwargs = get_kwargs("UserByScreenName", {"screen_name": "a810810931931"})
|
||||||
res = pt.UserApi(api_client).get_user_by_screen_name_with_http_info(**kwargs)
|
res = pt.UserApi(api_client).get_user_by_screen_name_with_http_info(**kwargs)
|
||||||
data = res.data.to_dict()
|
data = res.data.to_dict()
|
||||||
|
|
@ -244,7 +243,7 @@ if __name__ == "__main__":
|
||||||
error_count += 1
|
error_count += 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.info(f"Try: Self UserTweets Test")
|
logger.info("Try: Self UserTweets Test")
|
||||||
kwargs = get_kwargs("UserTweets", {"userId": "1180389371481976833"})
|
kwargs = get_kwargs("UserTweets", {"userId": "1180389371481976833"})
|
||||||
res = pt.TweetApi(api_client).get_user_tweets_with_http_info(**kwargs)
|
res = pt.TweetApi(api_client).get_user_tweets_with_http_info(**kwargs)
|
||||||
data = res.data.to_dict()
|
data = res.data.to_dict()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue