From 4379e0b89b94ba02207ba43d16b20b717196a9de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Tue, 21 Nov 2023 09:40:40 +0900 Subject: [PATCH 1/4] add Carousel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- dist/compatible/openapi-3.0.yaml | 1 + dist/docs/openapi-3.0.yaml | 1 + src/openapi/schemas/content.yaml | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/compatible/openapi-3.0.yaml b/dist/compatible/openapi-3.0.yaml index 96f8a5c..5c4c13b 100644 --- a/dist/compatible/openapi-3.0.yaml +++ b/dist/compatible/openapi-3.0.yaml @@ -1270,6 +1270,7 @@ components: enum: - Vertical - VerticalConversation + - Carousel type: string entryType: $ref: '#/components/schemas/ContentEntryType' diff --git a/dist/docs/openapi-3.0.yaml b/dist/docs/openapi-3.0.yaml index c8b671f..db97d5b 100644 --- a/dist/docs/openapi-3.0.yaml +++ b/dist/docs/openapi-3.0.yaml @@ -1270,6 +1270,7 @@ components: enum: - Vertical - VerticalConversation + - Carousel type: string entryType: $ref: '#/components/schemas/ContentEntryType' diff --git a/src/openapi/schemas/content.yaml b/src/openapi/schemas/content.yaml index 4e6352c..62c1ed3 100644 --- a/src/openapi/schemas/content.yaml +++ b/src/openapi/schemas/content.yaml @@ -60,7 +60,7 @@ components: $ref: "#/components/schemas/ContentEntryType" # TimelineTimelineCursor displayType: type: string - enum: [Vertical, VerticalConversation] + enum: [Vertical, VerticalConversation, Carousel] items: type: array items: From 5c36043f3afcfb350b20fd67d8fe752ee68ee4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Tue, 21 Nov 2023 09:42:57 +0900 Subject: [PATCH 2/4] update test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- test/python/test_serialize.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/python/test_serialize.py b/test/python/test_serialize.py index 1438c61..d0b27af 100644 --- a/test/python/test_serialize.py +++ b/test/python/test_serialize.py @@ -256,7 +256,11 @@ if __name__ == "__main__": error_dump(e) error_count += 1 - ids = ["1720975693524377759", "1720818185186791678", "1721006592303251551"] + ids = [ + "1720975693524377759", + "1721006592303251551", + "1606661809075019776", + ] for id in ids: try: logger.info(f"Try: Self TweetDetail {id} Test") From 37276039e91bcdf9baaa4a404ae254d65c27337b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Tue, 21 Nov 2023 10:25:16 +0900 Subject: [PATCH 3/4] update hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- tools/hooks.py | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/tools/hooks.py b/tools/hooks.py index 4546554..405e3fc 100644 --- a/tools/hooks.py +++ b/tools/hooks.py @@ -10,19 +10,25 @@ class HookBase: self.PLACEHOLDER = json.load(f) def placeholder_to_yaml(self, obj, default=False, example=False) -> dict: - fn = lambda x: self.placeholder_to_yaml(x, default=default, example=example) - if type(obj) is dict: - properties = {i: fn(obj[i]) for i in obj} + def mine(x): + return self.placeholder_to_yaml(x, default=default, example=example) + + def fn(x: str): + return x[:-1] if x.endswith("?") else x + + if isinstance(obj, dict): + req = {k: v for k, v in obj.items() if not k.endswith("?")} + properties = {fn(k): mine(v) for k, v in obj.items()} value = { "type": "object", "properties": properties, } - value.update({"required": [i for i in obj]} if len(obj) > 0 else {}) + value.update({"required": [i for i in req]} if len(req) > 0 else {}) value.update({"default": properties} if default else {}) value.update({"example": properties} if example else {}) return value - elif type(obj) is list and len(obj) > 0: - properties = fn(obj[0]) + elif isinstance(obj, list) and len(obj) > 0: + properties = mine(obj[0]) value = { "type": "array", "items": properties, @@ -30,7 +36,7 @@ class HookBase: value.update({"default": [properties]} if default else {}) value.update({"example": [properties]} if example else {}) return value - elif type(obj) is list and len(obj) == 0: + elif isinstance(obj, list) and len(obj) == 0: value = { "type": "array", "items": {"type": "object"}, @@ -38,11 +44,11 @@ class HookBase: value.update({"default": []} if default else {}) value.update({"example": []} if example else {}) return value - elif type(obj) is str: + elif isinstance(obj, str): return {"type": "string", "example": obj, "default": obj} - elif type(obj) is bool: + elif isinstance(obj, bool): return {"type": "boolean", "example": obj, "default": obj} - elif type(obj) is int: + elif isinstance(obj, int): return {"type": "integer", "example": obj, "default": obj} def load_component(self, name: str) -> dict: @@ -112,7 +118,7 @@ class RemoveDiscriminator(SchemasHookBase): class SchemasCheck(SchemasHookBase): def hook(self, value: dict): if value.get("allOf") is not None: - print(f"allOf is used") + print("allOf is used") if value.get("type") is None: print("Type is None") return value @@ -211,14 +217,18 @@ class AddParametersOnParameters(RequestHookBase): for key in data.keys(): if self.schemaType == "string": - example = data[key] if type(data[key]) is str else json.dumps(data[key]) + example = ( + data[key] if isinstance(data[key], str) else json.dumps(data[key]) + ) schema = { "type": "string", "default": example, "example": example, } elif self.schemaType == "object": - example = data[key] if type(data[key]) is str else json.dumps(data[key]) + example = ( + data[key] if isinstance(data[key], str) else json.dumps(data[key]) + ) schema = { "type": "object", "default": example, @@ -259,18 +269,18 @@ class AddParametersOnBody(RequestHookBase): def hook(self, path: str, value: dict): path, value = super().hook(path, value) - data = self.PLACEHOLDER[self.path_name] - data = {key: data[key] for key in data.keys() if key not in self.ignoreKeys} + data: dict[str, dict] = self.PLACEHOLDER[self.path_name] + data = {k: v for k, v in data.items() if k not in self.ignoreKeys} if self.schemaType == "string": - example = data if type(data) is str else json.dumps(data) + example = data if isinstance(data, str) else json.dumps(data) schema = { "type": "string", "default": example, "example": example, } elif self.schemaType == "object": - example = data if type(data) is str else json.dumps(data) + example = data if isinstance(data, str) else json.dumps(data) schema = { "type": "object", "default": example, @@ -278,10 +288,8 @@ class AddParametersOnBody(RequestHookBase): } else: schema = { - "properties": { - i: self.placeholder_to_yaml(data[i]) for i in data.keys() - }, - "required": [i for i in data.keys()], + "properties": {k: self.placeholder_to_yaml(v) for k, v in data.items()}, + "required": [k for k in data.keys()], } value["requestBody"] = { "description": "body", From c0ad260ab63a3b2c8a61f591ed2da3251d98a8b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Tue, 21 Nov 2023 10:25:48 +0900 Subject: [PATCH 4/4] update reply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- dist/compatible/openapi-3.0.yaml | 14 ++++++++++++++ dist/docs/openapi-3.0.yaml | 14 ++++++++++++++ src/config/placeholder.json | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/dist/compatible/openapi-3.0.yaml b/dist/compatible/openapi-3.0.yaml index 5c4c13b..aadda8c 100644 --- a/dist/compatible/openapi-3.0.yaml +++ b/dist/compatible/openapi-3.0.yaml @@ -3239,6 +3239,20 @@ paths: - media_entities - possibly_sensitive type: object + reply: + properties: + exclude_reply_user_ids: + items: + type: object + type: array + in_reply_to_tweet_id: + default: '1111111111111111111' + example: '1111111111111111111' + type: string + required: + - in_reply_to_tweet_id + - exclude_reply_user_ids + type: object semantic_annotation_ids: items: type: object diff --git a/dist/docs/openapi-3.0.yaml b/dist/docs/openapi-3.0.yaml index db97d5b..9557df0 100644 --- a/dist/docs/openapi-3.0.yaml +++ b/dist/docs/openapi-3.0.yaml @@ -3331,6 +3331,20 @@ paths: - media_entities - possibly_sensitive type: object + reply: + properties: + exclude_reply_user_ids: + items: + type: object + type: array + in_reply_to_tweet_id: + default: '1111111111111111111' + example: '1111111111111111111' + type: string + required: + - in_reply_to_tweet_id + - exclude_reply_user_ids + type: object semantic_annotation_ids: items: type: object diff --git a/src/config/placeholder.json b/src/config/placeholder.json index baf28de..bef3c50 100644 --- a/src/config/placeholder.json +++ b/src/config/placeholder.json @@ -625,6 +625,10 @@ "possibly_sensitive": false }, "semantic_annotation_ids": [], + "reply?": { + "in_reply_to_tweet_id": "1111111111111111111", + "exclude_reply_user_ids": [] + }, "dark_request": false }, "features": {