mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-11 15:40:26 +01:00
update
Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
parent
e76db523f3
commit
f707403009
9 changed files with 30 additions and 21 deletions
4
dist/dart/paths/other.yaml
vendored
4
dist/dart/paths/other.yaml
vendored
|
|
@ -16,10 +16,8 @@ components:
|
||||||
type: object
|
type: object
|
||||||
OtherResponse:
|
OtherResponse:
|
||||||
properties:
|
properties:
|
||||||
session:
|
Session:
|
||||||
$ref: '#/components/schemas/Session'
|
$ref: '#/components/schemas/Session'
|
||||||
required:
|
|
||||||
- session
|
|
||||||
type: object
|
type: object
|
||||||
Session:
|
Session:
|
||||||
properties:
|
properties:
|
||||||
|
|
|
||||||
4
dist/docs/paths/other.yaml
vendored
4
dist/docs/paths/other.yaml
vendored
|
|
@ -16,10 +16,8 @@ components:
|
||||||
type: object
|
type: object
|
||||||
OtherResponse:
|
OtherResponse:
|
||||||
properties:
|
properties:
|
||||||
session:
|
Session:
|
||||||
$ref: '#/components/schemas/Session'
|
$ref: '#/components/schemas/Session'
|
||||||
required:
|
|
||||||
- session
|
|
||||||
type: object
|
type: object
|
||||||
Session:
|
Session:
|
||||||
properties:
|
properties:
|
||||||
|
|
|
||||||
4
dist/test/paths/other.yaml
vendored
4
dist/test/paths/other.yaml
vendored
|
|
@ -16,10 +16,8 @@ components:
|
||||||
type: object
|
type: object
|
||||||
OtherResponse:
|
OtherResponse:
|
||||||
properties:
|
properties:
|
||||||
session:
|
Session:
|
||||||
$ref: '#/components/schemas/Session'
|
$ref: '#/components/schemas/Session'
|
||||||
required:
|
|
||||||
- session
|
|
||||||
type: object
|
type: object
|
||||||
Session:
|
Session:
|
||||||
properties:
|
properties:
|
||||||
|
|
|
||||||
4
dist/typescript/paths/other.yaml
vendored
4
dist/typescript/paths/other.yaml
vendored
|
|
@ -16,10 +16,8 @@ components:
|
||||||
type: object
|
type: object
|
||||||
OtherResponse:
|
OtherResponse:
|
||||||
properties:
|
properties:
|
||||||
session:
|
Session:
|
||||||
$ref: '#/components/schemas/Session'
|
$ref: '#/components/schemas/Session'
|
||||||
required:
|
|
||||||
- session
|
|
||||||
type: object
|
type: object
|
||||||
Session:
|
Session:
|
||||||
properties:
|
properties:
|
||||||
|
|
|
||||||
|
|
@ -428,7 +428,7 @@
|
||||||
"dark_request": false
|
"dark_request": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"=====v1.1====": {
|
"#=====v1.1====": {
|
||||||
"url": "https://twitter.com/i/api/1.1/"
|
"url": "https://twitter.com/i/api/1.1/"
|
||||||
},
|
},
|
||||||
"friendships/create.json": {
|
"friendships/create.json": {
|
||||||
|
|
@ -490,7 +490,7 @@
|
||||||
"src": "search_box",
|
"src": "search_box",
|
||||||
"result_type": "events,users,topics"
|
"result_type": "events,users,topics"
|
||||||
},
|
},
|
||||||
"=====v2====": {
|
"#=====v2====": {
|
||||||
"url": "https://twitter.com/i/api/2"
|
"url": "https://twitter.com/i/api/2"
|
||||||
},
|
},
|
||||||
"search/adaptive.json": {
|
"search/adaptive.json": {
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,8 @@ components:
|
||||||
schemas:
|
schemas:
|
||||||
OtherResponse:
|
OtherResponse:
|
||||||
type: object
|
type: object
|
||||||
required:
|
|
||||||
- "session"
|
|
||||||
properties:
|
properties:
|
||||||
session:
|
Session:
|
||||||
$ref: "#/components/schemas/Session" # window.__INITIAL_STATE__
|
$ref: "#/components/schemas/Session" # window.__INITIAL_STATE__
|
||||||
Session:
|
Session:
|
||||||
type: object
|
type: object
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import shutil
|
||||||
import copy
|
import copy
|
||||||
import re
|
import re
|
||||||
from build_config import Config
|
from build_config import Config
|
||||||
from hooks import OpenapiHookBase, RequestHookBase, SchemasHookBase
|
from hooks import OpenapiHookBase, RequestHookBase, SchemasHookBase,OtherHookBase
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -54,6 +54,14 @@ for lang, profile in tqdm(config.main().items(), leave=False):
|
||||||
hook: SchemasHookBase
|
hook: SchemasHookBase
|
||||||
value = hook.hook(value)
|
value = hook.hook(value)
|
||||||
load["components"]["schemas"][name] = value
|
load["components"]["schemas"][name] = value
|
||||||
|
if file == "src/openapi/paths/other.yaml":
|
||||||
|
for hook in profile["other"]:
|
||||||
|
hook: OtherHookBase
|
||||||
|
key, value = hook.hook()
|
||||||
|
load["components"]["schemas"][key] = value
|
||||||
|
load["components"]["schemas"]["OtherResponse"]["properties"][key] = {
|
||||||
|
"$ref": f"#/components/schemas/{key}"
|
||||||
|
}
|
||||||
with open(dist_replace(file), mode="w+", encoding="utf-8") as f:
|
with open(dist_replace(file), mode="w+", encoding="utf-8") as f:
|
||||||
f.write(yaml.dump(load))
|
f.write(yaml.dump(load))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ class Config:
|
||||||
"docs": {
|
"docs": {
|
||||||
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
||||||
"schemas": [],
|
"schemas": [],
|
||||||
|
"other":[],
|
||||||
"request": {
|
"request": {
|
||||||
key: [
|
key: [
|
||||||
ReplaceQueryIdPlaceholder(split=-1),
|
ReplaceQueryIdPlaceholder(split=-1),
|
||||||
|
|
@ -57,6 +58,7 @@ class Config:
|
||||||
"dart": {
|
"dart": {
|
||||||
"openapi": [],
|
"openapi": [],
|
||||||
"schemas": [],
|
"schemas": [],
|
||||||
|
"other":[],
|
||||||
"request": {
|
"request": {
|
||||||
key: [
|
key: [
|
||||||
ReplaceQueryIdPlaceholder(split=-1),
|
ReplaceQueryIdPlaceholder(split=-1),
|
||||||
|
|
@ -110,6 +112,7 @@ class Config:
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
||||||
"schemas": [RemoveDiscriminator()],
|
"schemas": [RemoveDiscriminator()],
|
||||||
|
"other":[],
|
||||||
"request": {
|
"request": {
|
||||||
key: [
|
key: [
|
||||||
ReplaceQueryIdPlaceholder(split=-1),
|
ReplaceQueryIdPlaceholder(split=-1),
|
||||||
|
|
@ -159,6 +162,7 @@ class Config:
|
||||||
"test": {
|
"test": {
|
||||||
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
||||||
"schemas": [],
|
"schemas": [],
|
||||||
|
"other":[],
|
||||||
"request": {
|
"request": {
|
||||||
key: [
|
key: [
|
||||||
ReplaceQueryIdPlaceholder(split=-1),
|
ReplaceQueryIdPlaceholder(split=-1),
|
||||||
|
|
|
||||||
|
|
@ -49,17 +49,24 @@ class HookBase:
|
||||||
with open(f"src/config/component/{name}.yaml", mode="r", encoding="utf-8") as f:
|
with open(f"src/config/component/{name}.yaml", mode="r", encoding="utf-8") as f:
|
||||||
return yaml.safe_load(f)
|
return yaml.safe_load(f)
|
||||||
|
|
||||||
|
def load_placeholder(self) -> dict:
|
||||||
|
with open("src/config/placeholder.json", mode="r", encoding="utf-8") as f:
|
||||||
|
return yaml.safe_load(f)
|
||||||
|
|
||||||
|
|
||||||
# HookBase extends
|
# HookBase extends
|
||||||
|
|
||||||
|
|
||||||
class OpenapiHookBase(HookBase):
|
class OpenapiHookBase(HookBase):
|
||||||
def hook(self, value: dict):
|
def hook(self, value: dict)->dict:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
class OtherHookBase(HookBase):
|
||||||
|
def hook(self)->tuple[str, dict]:
|
||||||
|
return "", {}
|
||||||
|
|
||||||
class SchemasHookBase(HookBase):
|
class SchemasHookBase(HookBase):
|
||||||
def hook(self, value: dict):
|
def hook(self, value: dict)->dict:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -71,7 +78,7 @@ class RequestHookBase(HookBase):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.split = split
|
self.split = split
|
||||||
|
|
||||||
def hook(self, path: str, value: dict):
|
def hook(self, path: str, value: dict)->tuple[str, dict]:
|
||||||
value["parameters"] = value.get("parameters", [])
|
value["parameters"] = value.get("parameters", [])
|
||||||
self.path_name = "/".join(path.split("/")[self.split :])
|
self.path_name = "/".join(path.split("/")[self.split :])
|
||||||
return path, value
|
return path, value
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue