From 5eedd4146d4bf2babd8da86b0b600e8fd5eac1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Thu, 27 Apr 2023 20:18:39 +0900 Subject: [PATCH] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- src/config/parameters.yaml | 172 +++++++++++++++++++------------- src/config/placeholder.json | 18 ++-- src/config/variable.json | 13 ++- src/openapi/paths/post.yaml | 75 ++++++++++++-- src/openapi/response/error.yaml | 97 ++++++++++++++++++ src/openapi/schemas/post.yaml | 71 ------------- 6 files changed, 283 insertions(+), 163 deletions(-) create mode 100644 src/openapi/response/error.yaml delete mode 100644 src/openapi/schemas/post.yaml diff --git a/src/config/parameters.yaml b/src/config/parameters.yaml index 166bfb8..c59eea3 100644 --- a/src/config/parameters.yaml +++ b/src/config/parameters.yaml @@ -6,18 +6,6 @@ paths: /parameters: get: parameters: - - name: variables - in: query - required: true - schema: - type: string - example: "{{Variables}}" - - name: features - in: query - required: true - schema: - type: string - example: "{{Features}}" - name: queryId in: query required: true @@ -26,6 +14,45 @@ paths: default: "{{Query}}" example: "{{Query}}" + # {% if get_parameters == string %} + + - name: variables + in: query + required: true + schema: + type: string + default: "{{Variables}}" + example: "{{Variables}}" + - name: features + in: query + required: true + schema: + type: string + default: "{{Features}}" + example: "{{Features}}" + + # {% endif %} + + # {% if get_parameters == object %} + + - name: variables + in: query + required: true + schema: + type: object + - name: features + in: query + required: true + schema: + type: object + - name: queryId + in: query + required: true + schema: + type: object + + # {% endif %} + # {% if header == parameters %} - name: authorization @@ -58,62 +85,71 @@ paths: description: "UserAgent, some APIs may be rejected if changed." # {% endif %} - - post: - parameters: - - name: variables - in: query - required: true - schema: - type: object - example: "{{Variables}}" - - name: features - in: query - required: true - schema: - type: object - example: "{{Features}}" - - name: queryId - in: query - required: true - schema: - type: string - default: "{{Query}}" - example: "{{Query}}" - - # {% if header == parameters %} - - - name: authorization - in: header - required: true - schema: - type: string - default: "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA" - description: "It is a constant value and does not need to be changed." - - name: x-twitter-active-user - in: header - required: true - schema: - type: string - default: "yes" - description: "Unknown what this value means." - - name: x-twitter-client-language - in: header - required: true - schema: - type: string - default: "en" - description: "language code." - - name: user-agent - in: header - required: true - schema: - type: string - default: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" - description: "UserAgent, some APIs may be rejected if changed." - - # {% endif %} - + responses: + "200": + description: "" + + post: + # {% if header == parameters %} + + parameters: + - name: authorization + in: header + required: true + schema: + type: string + default: "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA" + description: "It is a constant value and does not need to be changed." + - name: x-twitter-active-user + in: header + required: true + schema: + type: string + default: "yes" + description: "Unknown what this value means." + - name: x-twitter-client-language + in: header + required: true + schema: + type: string + default: "en" + description: "language code." + - name: user-agent + in: header + required: true + schema: + type: string + default: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" + description: "UserAgent, some APIs may be rejected if changed." + + # {% endif %} + + # {% if post_parameters == object %} + + requestBody: + required: true + content: + application/json: + schema: + required: + - "queryId" + - "variables" + - "features" + properties: + queryId: + type: string + default: "{{Query}}" + example: "{{Query}}" + variables: + type: object + # default: "{{Variables}}" + example: "{{Variables}}" + features: + type: object + # default: "{{Features}}" + example: "{{Features}}" + + # {% endif %} responses: "200": description: "" diff --git a/src/config/placeholder.json b/src/config/placeholder.json index 0743e8b..8d3c7aa 100644 --- a/src/config/placeholder.json +++ b/src/config/placeholder.json @@ -364,29 +364,25 @@ "Query": "lI07N6Otwv1PhnEgXILM7A", "Variables": { "tweet_id": "1349129669258448897" - }, - "Features": {} + } }, "UnfavoriteTweet": { "Query": "ZYKSe-w7KEslx3JhSIk5LA", "Variables": { "tweet_id": "1349129669258448897" - }, - "Features": {} + } }, "CreateRetweet": { "Query": "ojPdsZsimiJrUGLR1sjUtA", "Variables": { "tweet_id": "1349129669258448897" - }, - "Features": {} + } }, "DeleteRetweet": { "Query": "iQtK4dl5hBmXewYZuEOKVw", "Variables": { "tweet_id": "1349129669258448897" - }, - "Features": {} + } }, "CreateTweet": { "Query": "1RyAhNwby-gzGCRVsMxKbQ", @@ -396,7 +392,8 @@ "media_entities": [], "possibly_sensitive": false }, - "semantic_annotation_ids": [] + "semantic_annotation_ids": [], + "dark_request": false }, "Features": { "tweetypie_unmention_optimization_enabled": true, @@ -424,8 +421,7 @@ "Query": "VaenaVgh5q5ih7kvyVjgtg", "Variables": { "tweet_id": "1349129669258448897" - }, - "Features": {} + } }, "Template": { "Query": "", diff --git a/src/config/variable.json b/src/config/variable.json index 63f623d..f178ee8 100644 --- a/src/config/variable.json +++ b/src/config/variable.json @@ -1,8 +1,17 @@ { "dart": { - "header": "parameters" + "header": "parameters", + "get_parameters": "string", + "post_parameters": "object" }, "typescript": { - "header": "securitySchemes" + "header": "securitySchemes", + "get_parameters": "string", + "post_parameters": "object" + }, + "test": { + "header": "securitySchemes", + "get_parameters": "string", + "post_parameters": "string" } } \ No newline at end of file diff --git a/src/openapi/paths/post.yaml b/src/openapi/paths/post.yaml index 6985d4c..b24e344 100644 --- a/src/openapi/paths/post.yaml +++ b/src/openapi/paths/post.yaml @@ -6,7 +6,7 @@ info: paths: /{{FavoriteTweetQuery}}/FavoriteTweet: post: - operationId: favoriteTweet + operationId: postFavoriteTweet description: favorite Tweet responses: "200": @@ -20,7 +20,7 @@ paths: /{{UnfavoriteTweetQuery}}/UnfavoriteTweet: post: - operationId: unfavoriteTweet + operationId: postUnfavoriteTweet description: unfavorite Tweet responses: "200": @@ -34,7 +34,7 @@ paths: /{{CreateRetweetQuery}}/CreateRetweet: post: - operationId: createRetweet + operationId: postCreateRetweet description: create Retweet responses: "200": @@ -48,7 +48,7 @@ paths: /{{DeleteRetweetQuery}}/DeleteRetweet: post: - operationId: deleteRetweet + operationId: postDeleteRetweet description: delete Retweet responses: "200": @@ -62,7 +62,7 @@ paths: /{{CreateTweetQuery}}/CreateTweet: post: - operationId: createTweet + operationId: postCreateTweet description: create Tweet responses: "200": @@ -76,7 +76,7 @@ paths: /{{DeleteTweetQuery}}/DeleteTweet: post: - operationId: deleteTweet + operationId: postDeleteTweet description: delete Retweet responses: "200": @@ -95,14 +95,28 @@ components: - "data" properties: data: - $ref: "./../schemas/post.yaml#/components/schemas/FavoriteTweet" + $ref: "#/components/schemas/FavoriteTweet" + + FavoriteTweet: + required: + - "favorite_tweet" + properties: + favorite_tweet: + type: string UnfavoriteTweetResponseData: required: - "data" properties: data: - $ref: "./../schemas/post.yaml#/components/schemas/UnfavoriteTweet" + $ref: "#/components/schemas/UnfavoriteTweet" + + UnfavoriteTweet: + required: + - "unfavorite_tweet" + properties: + unfavorite_tweet: + type: string # ---Retweet--- @@ -125,7 +139,30 @@ components: - "retweet_results" properties: retweet_results: - $ref: "./../schemas/post.yaml#/components/schemas/CreateRetweet" + $ref: "#/components/schemas/CreateRetweet" + + CreateRetweet: + required: + - "result" + properties: + result: + type: object + items: + $ref: "#/components/schemas/Retweet" + + Retweet: + required: + - "rest_id" + - "legacy" + properties: + rest_id: + type: string + legacy: + type: object + items: + properties: + full_text: + type: string DeleteRetweetResponse: required: @@ -146,7 +183,16 @@ components: - "source_tweet_results" properties: retweet_results: - $ref: "./../schemas/post.yaml#/components/schemas/DeleteRetweet" + $ref: "#/components/schemas/DeleteRetweet" + + DeleteRetweet: + required: + - "result" + properties: + result: + type: object + items: + $ref: "#/components/schemas/Retweet" # ---Tweet--- @@ -169,7 +215,14 @@ components: - "tweet_results" properties: tweet_results: - $ref: "./../schemas/post.yaml#/components/schemas/CreateTweet" + $ref: "#/components/schemas/CreateTweet" + + CreateTweet: + required: + - "result" + properties: + result: + $ref: "./../schemas/tweet.yaml#/components/schemas/Tweet" DeleteTweetResponse: required: diff --git a/src/openapi/response/error.yaml b/src/openapi/response/error.yaml new file mode 100644 index 0000000..817edb6 --- /dev/null +++ b/src/openapi/response/error.yaml @@ -0,0 +1,97 @@ +openapi: 3.0.3 +info: + title: Twitter OpenAPI + version: 0.0.1 + +paths: {} + +components: + schemas: + ErrorResponse: + type: object + required: + - errors + - data + properties: + errors: + $ref: "#/components/schemas/Errors" + + Errors: + type: array + items: + $ref: "#/components/schemas/Error" + + Error: + type: object + required: + - message + - locations + - path + - extensions + - code + - kind + - name + - source + - tracing + properties: + message: + type: string + locations: + type: array + items: + $ref: "#/components/schemas/Location" + path: + type: array + items: + type: string + extensions: + $ref: "#/components/schemas/Extensions" + code: + type: integer + kind: + type: string + name: + type: string + source: + type: string + tracing: + $ref: "#/components/schemas/Tracing" + + Location: + type: object + required: + - line + - column + properties: + line: + type: integer + column: + type: integer + + Extensions: + type: object + required: + - name + - source + - code + - kind + - tracing + properties: + name: + type: string + source: + type: string + code: + type: integer + kind: + type: string + tracing: + $ref: "#/components/schemas/Tracing" + + Tracing: + type: object + required: + - trace_id + properties: + trace_id: + type: string diff --git a/src/openapi/schemas/post.yaml b/src/openapi/schemas/post.yaml deleted file mode 100644 index 69a1f94..0000000 --- a/src/openapi/schemas/post.yaml +++ /dev/null @@ -1,71 +0,0 @@ -openapi: 3.0.3 -info: - title: Twitter OpenAPI - version: 0.0.1 - -paths: {} -components: - schemas: - FavoriteTweet: - required: - - "favorite_tweet" - properties: - favorite_tweet: - type: string - - UnfavoriteTweet: - required: - - "unfavorite_tweet" - properties: - unfavorite_tweet: - type: string - - # ---Retweet--- - - CreateRetweet: - required: - - "result" - properties: - result: - type: object - items: - $ref: "#/components/schemas/Retweet" - - DeleteRetweet: - required: - - "result" - properties: - result: - type: object - items: - $ref: "#/components/schemas/Retweet" - - Retweet: - required: - - "rest_id" - - "legacy" - properties: - rest_id: - type: string - legacy: - type: object - items: - properties: - full_text: - type: string - - # ---Tweet--- - - CreateTweet: - required: - - "result" - properties: - result: - type: object - items: - $ref: "./tweet.yaml#/components/schemas/Tweet" - - DeleteTweet: - properties: - result: - type: object