From 9a732698951353b1362110defb25f945cee3f753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 5 May 2023 19:35:31 +0900 Subject: [PATCH] update hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- dist/typescript/paths/v1.1.yaml | 28 ++++++--------- src/config/component/response_header.yaml | 9 ----- .../component/response_header_v1.1.yaml | 35 +++++++++++++++++++ tools/build_config.py | 17 ++++++--- tools/hooks.py | 8 ++++- 5 files changed, 66 insertions(+), 31 deletions(-) create mode 100644 src/config/component/response_header_v1.1.yaml diff --git a/dist/typescript/paths/v1.1.yaml b/dist/typescript/paths/v1.1.yaml index 5598145..ed5a1fa 100644 --- a/dist/typescript/paths/v1.1.yaml +++ b/dist/typescript/paths/v1.1.yaml @@ -110,38 +110,32 @@ paths: '200': description: Successful operation headers: + status: + schema: + type: string + x-access-level: + schema: + type: string + x-client-event-enabled: + schema: + type: boolean x-connection-hash: schema: type: string x-content-type-options: schema: type: string - x-frame-options: - schema: - type: string - x-rate-limit-limit: - schema: - type: integer - x-rate-limit-remaining: - schema: - type: integer - x-rate-limit-reset: - schema: - type: integer x-response-time: schema: type: integer - x-tfe-preserve-body: + x-transaction: schema: - type: boolean + type: string x-transaction-id: schema: type: string x-twitter-response-tags: schema: type: string - x-xss-protection: - schema: - type: integer tags: - v1.1 diff --git a/src/config/component/response_header.yaml b/src/config/component/response_header.yaml index e7c2a23..2e908c0 100644 --- a/src/config/component/response_header.yaml +++ b/src/config/component/response_header.yaml @@ -9,12 +9,6 @@ components: x-connection-hash: schema: type: string - x-content-type-options: - schema: - type: string - x-frame-options: - schema: - type: string x-rate-limit-limit: schema: type: integer @@ -36,6 +30,3 @@ components: x-twitter-response-tags: schema: type: string - x-xss-protection: - schema: - type: integer diff --git a/src/config/component/response_header_v1.1.yaml b/src/config/component/response_header_v1.1.yaml new file mode 100644 index 0000000..b2fc658 --- /dev/null +++ b/src/config/component/response_header_v1.1.yaml @@ -0,0 +1,35 @@ +openapi: 3.0.3 +info: + title: Twitter OpenAPI + version: 0.0.1 +paths: {} + +components: + headers: + status: + schema: + type: string + x-access-level: + schema: + type: string + x-client-event-enabled: + schema: + type: boolean + x-connection-hash: + schema: + type: string + x-content-type-options: + schema: + type: string + x-response-time: + schema: + type: integer + x-transaction: + schema: + type: string + x-transaction-id: + schema: + type: string + x-twitter-response-tags: + schema: + type: string diff --git a/tools/build_config.py b/tools/build_config.py index 728a9ed..77d0243 100644 --- a/tools/build_config.py +++ b/tools/build_config.py @@ -23,7 +23,7 @@ class Config: SetResponsesHeader(), AddParametersOnParameters(), ], - "v1.1": [SetResponsesHeader(), AddParametersOnParameters()], + "v1.1": [SetResponsesHeader("v1.1"), AddParametersOnParameters()], }, }, "dart": { @@ -44,7 +44,10 @@ class Config: SetResponsesHeader(), AddParametersOnParametersAsObject(), ], - "v1.1": [SetResponsesHeader(), AddParametersOnParametersAsObject()], + "v1.1": [ + SetResponsesHeader("v1.1"), + AddParametersOnParametersAsObject(), + ], }, }, "typescript": { @@ -63,7 +66,10 @@ class Config: SetResponsesHeader(), AddParametersOnParametersAsObject(), ], - "v1.1": [SetResponsesHeader(), AddParametersOnParametersAsObject()], + "v1.1": [ + SetResponsesHeader("v1.1"), + AddParametersOnParametersAsObject(), + ], }, }, "test": { @@ -82,7 +88,10 @@ class Config: SetResponsesHeader(), AddParametersOnParametersAsString(), ], - "v1.1": [SetResponsesHeader(), AddParametersOnParametersAsString()], + "v1.1": [ + SetResponsesHeader("v1.1"), + AddParametersOnParametersAsString(), + ], }, }, } diff --git a/tools/hooks.py b/tools/hooks.py index a9fcffa..dcdff9b 100644 --- a/tools/hooks.py +++ b/tools/hooks.py @@ -85,8 +85,14 @@ class ReplaceQueryIdPlaceholder(RequestHookBase): class SetResponsesHeader(RequestHookBase): + prexix: str + + def __init__(self, prexix: str = ""): + super().__init__() + self.prexix = prexix if prexix == "" else "_" + prexix + def hook(self, path: str, value: dict): - component = self.load_component("response_header") + component = self.load_component("response_header" + self.prexix) value["responses"]["200"]["headers"] = component["components"]["headers"] return path, value