diff --git a/src/config/placeholder.json b/src/config/placeholder.json index 790b856..84ab427 100644 --- a/src/config/placeholder.json +++ b/src/config/placeholder.json @@ -445,7 +445,7 @@ "include_ext_verified_type": 1, "include_ext_profile_image_shape": 1, "skip_status": 1, - "user_id": 44196397 + "user_id": "44196397" }, "friendships/destroy.json": { "include_profile_interstitial_type": 1, @@ -461,7 +461,7 @@ "include_ext_verified_type": 1, "include_ext_profile_image_shape": 1, "skip_status": 1, - "user_id": 44196397 + "user_id": "44196397" }, "friends/following/list.json": { "include_profile_interstitial_type": 1, @@ -478,7 +478,7 @@ "include_ext_profile_image_shape": 1, "skip_status": 1, "cursor": -1, - "user_id": 17152334, + "user_id": "44196397", "count": 3, "with_total_count": true }, @@ -486,7 +486,7 @@ "include_ext_is_blue_verified": 1, "include_ext_verified_type": 1, "include_ext_profile_image_shape": 1, - "q": "aaa", + "q": "test", "src": "search_box", "result_type": "events,users,topics" }, diff --git a/tools/build.py b/tools/build.py index 3b25ddf..b61e434 100644 --- a/tools/build.py +++ b/tools/build.py @@ -6,6 +6,7 @@ import shutil import copy import re from build_config import Config +from hooks import OpenapiHookBase, RequestHookBase print("=== Build Start ===") @@ -37,6 +38,7 @@ for lang in config.main().keys(): for tag in list(load["paths"][path][method].get("tags", ["default"])): key, value = path, load["paths"][path][method] for hook in config.main()[lang]["request"][tag]: + hook: RequestHookBase key, value = hook.hook(key, value) load["paths"][path][method] = value load["paths"][key] = load["paths"].pop(path) @@ -53,6 +55,9 @@ for lang in config.main().keys(): openapi = yaml.safe_load(f) for path in paths: openapi["paths"] = paths + for hook in config.main()[lang]["openapi"]: + hook: OpenapiHookBase + openapi = hook.hook(openapi) with open(dist_replace(file), mode="w+", encoding="utf-8") as f: f.write(yaml.dump(openapi)) diff --git a/tools/build_config.py b/tools/build_config.py index 5987059..af82ae1 100644 --- a/tools/build_config.py +++ b/tools/build_config.py @@ -68,6 +68,7 @@ class Config: | { key: [ SetResponsesHeader(suffix="legacy"), + AddSecuritySchemesOnHeader(split=-1), AddParametersOnParameters( split=2, schemaType="string", @@ -78,9 +79,10 @@ class Config: | { key: [ SetResponsesHeader(suffix="legacy"), + AddSecuritySchemesOnHeader(split=-1), AddParametersOnBody( split=2, - schemaType="object", + schemaType=None, contentType="application/x-www-form-urlencoded", ), ] diff --git a/tools/hooks.py b/tools/hooks.py index dec7fec..7f91f6e 100644 --- a/tools/hooks.py +++ b/tools/hooks.py @@ -80,7 +80,7 @@ class AddSecuritySchemesOnSecuritySchemes(OpenapiHookBase): value = super().hook(value) component = self.load_component("security_schemes") param = component["components"]["securitySchemes"] - value["components"]["securitySchemes"].extend(param) + value["components"]["securitySchemes"].update(param) return value @@ -196,7 +196,7 @@ class AddParametersOnBody(RequestHookBase): "properties": { i: self.placeholder_to_yaml(data[i]) for i in data.keys() }, - # "required": [i for i in data.keys()], + "required": [i for i in data.keys()], } value["requestBody"] = { "description": "body", @@ -232,7 +232,7 @@ class AddParametersOnContent(RequestHookBase): "content": { self.contentType: { "schema": self.placeholder_to_yaml(data[key]), - # "required": [i for i in data[key]], + "required": [i for i in data[key]], } }, }