mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-11 15:40:26 +01:00
update builder
Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
parent
c22926614e
commit
3419b5c0ab
19 changed files with 539 additions and 480 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
.venv
|
.venv
|
||||||
|
__pycache__/
|
||||||
61
src/config/component/security_schemes.yaml
Normal file
61
src/config/component/security_schemes.yaml
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
openapi: 3.0.3
|
||||||
|
info:
|
||||||
|
title: Twitter OpenAPI
|
||||||
|
version: 0.0.1
|
||||||
|
paths:
|
||||||
|
/parameters:
|
||||||
|
get:
|
||||||
|
parameters:
|
||||||
|
- 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."
|
||||||
|
- 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."
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
|
||||||
|
components:
|
||||||
|
securitySchemes:
|
||||||
|
UserAgent:
|
||||||
|
description: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
|
||||||
|
in: header
|
||||||
|
name: user-agent
|
||||||
|
type: apiKey
|
||||||
|
BearerAuth:
|
||||||
|
description: AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA
|
||||||
|
scheme: bearer
|
||||||
|
type: http
|
||||||
|
ActiveUser:
|
||||||
|
description: "yes"
|
||||||
|
in: header
|
||||||
|
name: x-twitter-active-user
|
||||||
|
type: apiKey
|
||||||
|
ClientLanguage:
|
||||||
|
description: en
|
||||||
|
in: header
|
||||||
|
name: x-twitter-client-language
|
||||||
|
type: apiKey
|
||||||
|
|
@ -1,155 +0,0 @@
|
||||||
openapi: 3.0.3
|
|
||||||
info:
|
|
||||||
title: Twitter OpenAPI
|
|
||||||
version: 0.0.1
|
|
||||||
paths:
|
|
||||||
/parameters:
|
|
||||||
get:
|
|
||||||
parameters:
|
|
||||||
- name: queryId
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
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
|
|
||||||
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: ""
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
{
|
{
|
||||||
"HomeTimeline": {
|
"HomeTimeline": {
|
||||||
"Query": "HCosKfLNW1AcOo3la3mMgg",
|
"queryId": "HCosKfLNW1AcOo3la3mMgg",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"count": 20,
|
"count": 20,
|
||||||
"includePromotedContent": true,
|
"includePromotedContent": true,
|
||||||
"latestControlAvailable": true,
|
"latestControlAvailable": true,
|
||||||
"requestContext": "launch",
|
"requestContext": "launch",
|
||||||
"withCommunity": true
|
"withCommunity": true
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -31,14 +31,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"HomeLatestTimeline": {
|
"HomeLatestTimeline": {
|
||||||
"Query": "zhX91JE87mWvfprhYE97xA",
|
"queryId": "zhX91JE87mWvfprhYE97xA",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"count": 20,
|
"count": 20,
|
||||||
"includePromotedContent": true,
|
"includePromotedContent": true,
|
||||||
"latestControlAvailable": true,
|
"latestControlAvailable": true,
|
||||||
"requestContext": "launch"
|
"requestContext": "launch"
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -61,12 +61,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ListLatestTweetsTimeline": {
|
"ListLatestTweetsTimeline": {
|
||||||
"Query": "2TemLyqrMpTeAmysdbnVqw",
|
"queryId": "2TemLyqrMpTeAmysdbnVqw",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"listId": "53044119",
|
"listId": "53044119",
|
||||||
"count": 20
|
"count": 20
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -89,12 +89,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"UserByScreenName": {
|
"UserByScreenName": {
|
||||||
"Query": "sLVLhk0bGj3MVFEKTdax1w",
|
"queryId": "sLVLhk0bGj3MVFEKTdax1w",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"screen_name": "elonmusk",
|
"screen_name": "elonmusk",
|
||||||
"withSafetyModeUserFields": true
|
"withSafetyModeUserFields": true
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -103,15 +103,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ProfileSpotlightsQuery": {
|
"ProfileSpotlightsQuery": {
|
||||||
"Query": "9zwVLJ48lmVUk8u_Gh9DmA",
|
"queryId": "9zwVLJ48lmVUk8u_Gh9DmA",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"screen_name": "elonmusk"
|
"screen_name": "elonmusk"
|
||||||
},
|
},
|
||||||
"Features": {}
|
"features": {}
|
||||||
},
|
},
|
||||||
"UserTweets": {
|
"UserTweets": {
|
||||||
"Query": "HuTx74BxAnezK1gWvYY7zg",
|
"queryId": "HuTx74BxAnezK1gWvYY7zg",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"userId": "44196397",
|
"userId": "44196397",
|
||||||
"count": 40,
|
"count": 40,
|
||||||
"includePromotedContent": true,
|
"includePromotedContent": true,
|
||||||
|
|
@ -119,7 +119,7 @@
|
||||||
"withVoice": true,
|
"withVoice": true,
|
||||||
"withV2Timeline": true
|
"withV2Timeline": true
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -142,8 +142,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"UserTweetsAndReplies": {
|
"UserTweetsAndReplies": {
|
||||||
"Query": "RIWc55YCNyUJ-U3HHGYkdg",
|
"queryId": "RIWc55YCNyUJ-U3HHGYkdg",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"userId": "44196397",
|
"userId": "44196397",
|
||||||
"count": 40,
|
"count": 40,
|
||||||
"includePromotedContent": true,
|
"includePromotedContent": true,
|
||||||
|
|
@ -151,7 +151,7 @@
|
||||||
"withVoice": true,
|
"withVoice": true,
|
||||||
"withV2Timeline": true
|
"withV2Timeline": true
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -174,8 +174,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"UserMedia": {
|
"UserMedia": {
|
||||||
"Query": "YqiE3JL1KNgf9nSljYdxaA",
|
"queryId": "YqiE3JL1KNgf9nSljYdxaA",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"userId": "44196397",
|
"userId": "44196397",
|
||||||
"count": 40,
|
"count": 40,
|
||||||
"includePromotedContent": false,
|
"includePromotedContent": false,
|
||||||
|
|
@ -184,7 +184,7 @@
|
||||||
"withVoice": true,
|
"withVoice": true,
|
||||||
"withV2Timeline": true
|
"withV2Timeline": true
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -207,8 +207,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Likes": {
|
"Likes": {
|
||||||
"Query": "5fmEkRT-1AdHqEsbVgehMg",
|
"queryId": "5fmEkRT-1AdHqEsbVgehMg",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"userId": "44196397",
|
"userId": "44196397",
|
||||||
"count": 20,
|
"count": 20,
|
||||||
"includePromotedContent": false,
|
"includePromotedContent": false,
|
||||||
|
|
@ -217,7 +217,7 @@
|
||||||
"withVoice": true,
|
"withVoice": true,
|
||||||
"withV2Timeline": true
|
"withV2Timeline": true
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -240,12 +240,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Bookmarks": {
|
"Bookmarks": {
|
||||||
"Query": "tmd4ifV8RHltzn8ymGg1aw",
|
"queryId": "tmd4ifV8RHltzn8ymGg1aw",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"count": 20,
|
"count": 20,
|
||||||
"includePromotedContent": true
|
"includePromotedContent": true
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"graphql_timeline_v2_bookmark_timeline": true,
|
"graphql_timeline_v2_bookmark_timeline": true,
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
|
|
@ -269,8 +269,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"TweetDetail": {
|
"TweetDetail": {
|
||||||
"Query": "wNNG8DBB8EaXw1lq4vFWGA",
|
"queryId": "wNNG8DBB8EaXw1lq4vFWGA",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"focalTweetId": "1349129669258448897",
|
"focalTweetId": "1349129669258448897",
|
||||||
"with_rux_injections": false,
|
"with_rux_injections": false,
|
||||||
"includePromotedContent": true,
|
"includePromotedContent": true,
|
||||||
|
|
@ -280,7 +280,7 @@
|
||||||
"withVoice": true,
|
"withVoice": true,
|
||||||
"withV2Timeline": true
|
"withV2Timeline": true
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -303,13 +303,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Followers": {
|
"Followers": {
|
||||||
"Query": "djdTXDIk2qhd4OStqlUFeQ",
|
"queryId": "djdTXDIk2qhd4OStqlUFeQ",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"userId": "44196397",
|
"userId": "44196397",
|
||||||
"count": 20,
|
"count": 20,
|
||||||
"includePromotedContent": false
|
"includePromotedContent": false
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -332,13 +332,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Following": {
|
"Following": {
|
||||||
"Query": "IWP6Zt14sARO29lJT35bBw",
|
"queryId": "IWP6Zt14sARO29lJT35bBw",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"userId": "44196397",
|
"userId": "44196397",
|
||||||
"count": 20,
|
"count": 20,
|
||||||
"includePromotedContent": false
|
"includePromotedContent": false
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"blue_business_profile_image_shape_enabled": true,
|
"blue_business_profile_image_shape_enabled": true,
|
||||||
"responsive_web_graphql_exclude_directive_enabled": true,
|
"responsive_web_graphql_exclude_directive_enabled": true,
|
||||||
"verified_phone_label_enabled": false,
|
"verified_phone_label_enabled": false,
|
||||||
|
|
@ -361,32 +361,44 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"FavoriteTweet": {
|
"FavoriteTweet": {
|
||||||
"Query": "lI07N6Otwv1PhnEgXILM7A",
|
"queryId": "lI07N6Otwv1PhnEgXILM7A",
|
||||||
"Variables": {
|
"Parameters": {
|
||||||
"tweet_id": "1349129669258448897"
|
"variables": {
|
||||||
|
"tweet_id": "1349129669258448897"
|
||||||
|
},
|
||||||
|
"features": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"UnfavoriteTweet": {
|
"UnfavoriteTweet": {
|
||||||
"Query": "ZYKSe-w7KEslx3JhSIk5LA",
|
"queryId": "ZYKSe-w7KEslx3JhSIk5LA",
|
||||||
"Variables": {
|
"Parameters": {
|
||||||
"tweet_id": "1349129669258448897"
|
"variables": {
|
||||||
|
"tweet_id": "1349129669258448897"
|
||||||
|
},
|
||||||
|
"features": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CreateRetweet": {
|
"CreateRetweet": {
|
||||||
"Query": "ojPdsZsimiJrUGLR1sjUtA",
|
"queryId": "ojPdsZsimiJrUGLR1sjUtA",
|
||||||
"Variables": {
|
"Parameters": {
|
||||||
"tweet_id": "1349129669258448897"
|
"variables": {
|
||||||
|
"tweet_id": "1349129669258448897"
|
||||||
|
},
|
||||||
|
"features": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DeleteRetweet": {
|
"DeleteRetweet": {
|
||||||
"Query": "iQtK4dl5hBmXewYZuEOKVw",
|
"queryId": "iQtK4dl5hBmXewYZuEOKVw",
|
||||||
"Variables": {
|
"Parameters": {
|
||||||
"tweet_id": "1349129669258448897"
|
"variables": {
|
||||||
|
"tweet_id": "1349129669258448897"
|
||||||
|
},
|
||||||
|
"features": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CreateTweet": {
|
"CreateTweet": {
|
||||||
"Query": "1RyAhNwby-gzGCRVsMxKbQ",
|
"queryId": "1RyAhNwby-gzGCRVsMxKbQ",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"tweet_text": "test",
|
"tweet_text": "test",
|
||||||
"media": {
|
"media": {
|
||||||
"media_entities": [],
|
"media_entities": [],
|
||||||
|
|
@ -395,7 +407,7 @@
|
||||||
"semantic_annotation_ids": [],
|
"semantic_annotation_ids": [],
|
||||||
"dark_request": false
|
"dark_request": false
|
||||||
},
|
},
|
||||||
"Features": {
|
"features": {
|
||||||
"tweetypie_unmention_optimization_enabled": true,
|
"tweetypie_unmention_optimization_enabled": true,
|
||||||
"vibe_api_enabled": true,
|
"vibe_api_enabled": true,
|
||||||
"responsive_web_edit_tweet_api_enabled": true,
|
"responsive_web_edit_tweet_api_enabled": true,
|
||||||
|
|
@ -418,14 +430,31 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DeleteTweet": {
|
"DeleteTweet": {
|
||||||
"Query": "VaenaVgh5q5ih7kvyVjgtg",
|
"queryId": "VaenaVgh5q5ih7kvyVjgtg",
|
||||||
"Variables": {
|
"variables": {
|
||||||
"tweet_id": "1349129669258448897"
|
"tweet_id": "1349129669258448897"
|
||||||
}
|
},
|
||||||
|
"features": {}
|
||||||
|
},
|
||||||
|
"create.json": {
|
||||||
|
"include_profile_interstitial_type": 1,
|
||||||
|
"include_blocking": 1,
|
||||||
|
"include_blocked_by": 1,
|
||||||
|
"include_followed_by": 1,
|
||||||
|
"include_want_retweets": 1,
|
||||||
|
"include_mute_edge": 1,
|
||||||
|
"include_can_dm": 1,
|
||||||
|
"include_can_media_tag": 1,
|
||||||
|
"include_ext_has_nft_avatar": 1,
|
||||||
|
"include_ext_is_blue_verified": 1,
|
||||||
|
"include_ext_verified_type": 1,
|
||||||
|
"include_ext_profile_image_shape": 1,
|
||||||
|
"skip_status": 1,
|
||||||
|
"user_id": 1180389371481976833
|
||||||
},
|
},
|
||||||
"Template": {
|
"Template": {
|
||||||
"Query": "",
|
"queryId": "",
|
||||||
"Variables": {},
|
"variables": {},
|
||||||
"Features": {}
|
"features": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"docs": {
|
|
||||||
"header": "securitySchemes",
|
|
||||||
"get_parameters": "schema_content",
|
|
||||||
"post_parameters": "schema_parameters"
|
|
||||||
},
|
|
||||||
"dart": {
|
|
||||||
"header": "parameters",
|
|
||||||
"get_parameters": "string",
|
|
||||||
"post_parameters": "object"
|
|
||||||
},
|
|
||||||
"typescript": {
|
|
||||||
"header": "securitySchemes",
|
|
||||||
"get_parameters": "string",
|
|
||||||
"post_parameters": "object"
|
|
||||||
},
|
|
||||||
"test": {
|
|
||||||
"header": "securitySchemes",
|
|
||||||
"get_parameters": "string",
|
|
||||||
"post_parameters": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -42,30 +42,6 @@ components:
|
||||||
name: x-twitter-auth-type
|
name: x-twitter-auth-type
|
||||||
description: "OAuth2Session if you are logged in"
|
description: "OAuth2Session if you are logged in"
|
||||||
|
|
||||||
# {% if header == securitySchemes %}
|
|
||||||
|
|
||||||
UserAgent:
|
|
||||||
description: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
|
|
||||||
in: header
|
|
||||||
name: user-agent
|
|
||||||
type: apiKey
|
|
||||||
ActiveUser:
|
|
||||||
description: "yes"
|
|
||||||
in: header
|
|
||||||
name: x-twitter-active-user
|
|
||||||
type: apiKey
|
|
||||||
BearerAuth:
|
|
||||||
description: AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA
|
|
||||||
scheme: bearer
|
|
||||||
type: http
|
|
||||||
ClientLanguage:
|
|
||||||
description: en
|
|
||||||
in: header
|
|
||||||
name: x-twitter-client-language
|
|
||||||
type: apiKey
|
|
||||||
|
|
||||||
# {% endif %}
|
|
||||||
|
|
||||||
security:
|
security:
|
||||||
- bearerAuth: []
|
- bearerAuth: []
|
||||||
- CsrfToken: []
|
- CsrfToken: []
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/{{BookmarksQuery}}/Bookmarks:
|
/graphql/{{queryId}}/Bookmarks:
|
||||||
get:
|
get:
|
||||||
operationId: getBookmarks
|
operationId: getBookmarks
|
||||||
description: get bookmarks
|
description: get bookmarks
|
||||||
|
|
@ -16,7 +16,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/BookmarksResponse"
|
$ref: "#/components/schemas/BookmarksResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Tweet"
|
- "tweet"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/{{FollowingQuery}}/Following:
|
/graphql/{{queryId}}/Following:
|
||||||
get:
|
get:
|
||||||
operationId: getFollowing
|
operationId: getFollowing
|
||||||
description: get user list of following
|
description: get user list of following
|
||||||
|
|
@ -16,9 +16,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FollowResponse"
|
$ref: "#/components/schemas/FollowResponse"
|
||||||
tags:
|
tags:
|
||||||
- "UserList"
|
- "userList"
|
||||||
|
|
||||||
/{{FollowersQuery}}/Followers:
|
/graphql/{{queryId}}/Followers:
|
||||||
get:
|
get:
|
||||||
operationId: getFollowers
|
operationId: getFollowers
|
||||||
description: get user list of followers
|
description: get user list of followers
|
||||||
|
|
@ -30,7 +30,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FollowResponse"
|
$ref: "#/components/schemas/FollowResponse"
|
||||||
tags:
|
tags:
|
||||||
- "UserList"
|
- "userList"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/{{FavoriteTweetQuery}}/FavoriteTweet:
|
/graphql/{{queryId}}/FavoriteTweet:
|
||||||
post:
|
post:
|
||||||
operationId: postFavoriteTweet
|
operationId: postFavoriteTweet
|
||||||
description: favorite Tweet
|
description: favorite Tweet
|
||||||
|
|
@ -16,9 +16,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FavoriteTweetResponseData"
|
$ref: "#/components/schemas/FavoriteTweetResponseData"
|
||||||
tags:
|
tags:
|
||||||
- "Post"
|
- "post"
|
||||||
|
|
||||||
/{{UnfavoriteTweetQuery}}/UnfavoriteTweet:
|
/graphql/{{queryId}}/UnfavoriteTweet:
|
||||||
post:
|
post:
|
||||||
operationId: postUnfavoriteTweet
|
operationId: postUnfavoriteTweet
|
||||||
description: unfavorite Tweet
|
description: unfavorite Tweet
|
||||||
|
|
@ -30,9 +30,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/UnfavoriteTweetResponseData"
|
$ref: "#/components/schemas/UnfavoriteTweetResponseData"
|
||||||
tags:
|
tags:
|
||||||
- "Post"
|
- "post"
|
||||||
|
|
||||||
/{{CreateRetweetQuery}}/CreateRetweet:
|
/graphql/{{queryId}}/CreateRetweet:
|
||||||
post:
|
post:
|
||||||
operationId: postCreateRetweet
|
operationId: postCreateRetweet
|
||||||
description: create Retweet
|
description: create Retweet
|
||||||
|
|
@ -44,9 +44,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/CreateRetweetResponse"
|
$ref: "#/components/schemas/CreateRetweetResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Post"
|
- "post"
|
||||||
|
|
||||||
/{{DeleteRetweetQuery}}/DeleteRetweet:
|
/graphql/{{queryId}}/DeleteRetweet:
|
||||||
post:
|
post:
|
||||||
operationId: postDeleteRetweet
|
operationId: postDeleteRetweet
|
||||||
description: delete Retweet
|
description: delete Retweet
|
||||||
|
|
@ -58,9 +58,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/DeleteRetweetResponse"
|
$ref: "#/components/schemas/DeleteRetweetResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Post"
|
- "post"
|
||||||
|
|
||||||
/{{CreateTweetQuery}}/CreateTweet:
|
/graphql/{{queryId}}/CreateTweet:
|
||||||
post:
|
post:
|
||||||
operationId: postCreateTweet
|
operationId: postCreateTweet
|
||||||
description: create Tweet
|
description: create Tweet
|
||||||
|
|
@ -72,9 +72,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/CreateTweetResponse"
|
$ref: "#/components/schemas/CreateTweetResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Post"
|
- "post"
|
||||||
|
|
||||||
/{{DeleteTweetQuery}}/DeleteTweet:
|
/graphql/{{queryId}}/DeleteTweet:
|
||||||
post:
|
post:
|
||||||
operationId: postDeleteTweet
|
operationId: postDeleteTweet
|
||||||
description: delete Retweet
|
description: delete Retweet
|
||||||
|
|
@ -86,7 +86,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/DeleteTweetResponse"
|
$ref: "#/components/schemas/DeleteTweetResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Post"
|
- "post"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/{{ProfileSpotlightsQueryQuery}}/ProfileSpotlightsQuery:
|
/graphql/{{queryId}}/ProfileSpotlightsQuery:
|
||||||
get:
|
get:
|
||||||
operationId: getProfileSpotlightsQuery
|
operationId: getProfileSpotlightsQuery
|
||||||
description: "get user by screen name"
|
description: "get user by screen name"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/{{HomeTimelineQuery}}/HomeTimeline:
|
/graphql/{{queryId}}/HomeTimeline:
|
||||||
get:
|
get:
|
||||||
operationId: getHomeTimeline
|
operationId: getHomeTimeline
|
||||||
description: get tweet list of timeline
|
description: get tweet list of timeline
|
||||||
|
|
@ -16,9 +16,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/TimelineResponse"
|
$ref: "#/components/schemas/TimelineResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Tweet"
|
- "tweet"
|
||||||
|
|
||||||
/{{HomeLatestTimelineQuery}}/HomeLatestTimeline:
|
/graphql/{{queryId}}/HomeLatestTimeline:
|
||||||
get:
|
get:
|
||||||
operationId: getHomeLatestTimeline
|
operationId: getHomeLatestTimeline
|
||||||
description: get tweet list of timeline
|
description: get tweet list of timeline
|
||||||
|
|
@ -30,9 +30,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/TimelineResponse"
|
$ref: "#/components/schemas/TimelineResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Tweet"
|
- "tweet"
|
||||||
|
|
||||||
/{{ListLatestTweetsTimelineQuery}}/ListLatestTweetsTimeline:
|
/graphql/{{queryId}}/ListLatestTweetsTimeline:
|
||||||
get:
|
get:
|
||||||
operationId: getListLatestTweetsTimeline
|
operationId: getListLatestTweetsTimeline
|
||||||
description: get tweet list of timeline
|
description: get tweet list of timeline
|
||||||
|
|
@ -44,7 +44,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/ListTweetsTimelineResponse"
|
$ref: "#/components/schemas/ListTweetsTimelineResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Tweet"
|
- "tweet"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/{{TweetDetailQuery}}/TweetDetail:
|
/graphql/{{queryId}}/TweetDetail:
|
||||||
get:
|
get:
|
||||||
operationId: getTweetDetail
|
operationId: getTweetDetail
|
||||||
description: get TweetDetail
|
description: get TweetDetail
|
||||||
|
|
@ -16,7 +16,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/TweetDetailResponse"
|
$ref: "#/components/schemas/TweetDetailResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Tweet"
|
- "tweet"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/{{UserByScreenNameQuery}}/UserByScreenName:
|
/graphql/{{queryId}}/UserByScreenName:
|
||||||
get:
|
get:
|
||||||
operationId: getUserByScreenName
|
operationId: getUserByScreenName
|
||||||
description: "get user by screen name"
|
description: "get user by screen name"
|
||||||
|
|
@ -16,7 +16,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/UserResponse"
|
$ref: "#/components/schemas/UserResponse"
|
||||||
tags:
|
tags:
|
||||||
- "User"
|
- "user"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/{{UserTweetsQuery}}/UserTweets:
|
/graphql/{{queryId}}/UserTweets:
|
||||||
get:
|
get:
|
||||||
operationId: getUserTweets
|
operationId: getUserTweets
|
||||||
description: "get user tweets"
|
description: "get user tweets"
|
||||||
|
|
@ -16,9 +16,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/UserTweetsResponse"
|
$ref: "#/components/schemas/UserTweetsResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Tweet"
|
- "tweet"
|
||||||
|
|
||||||
/{{UserTweetsAndRepliesQuery}}/UserTweetsAndReplies:
|
/graphql/{{queryId}}/UserTweetsAndReplies:
|
||||||
get:
|
get:
|
||||||
operationId: getUserTweetsAndReplies
|
operationId: getUserTweetsAndReplies
|
||||||
description: "get user replies tweets"
|
description: "get user replies tweets"
|
||||||
|
|
@ -30,9 +30,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/UserTweetsResponse"
|
$ref: "#/components/schemas/UserTweetsResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Tweet"
|
- "tweet"
|
||||||
|
|
||||||
/{{UserMediaQuery}}/UserMedia:
|
/graphql/{{queryId}}/UserMedia:
|
||||||
get:
|
get:
|
||||||
operationId: getUserMedia
|
operationId: getUserMedia
|
||||||
description: "get user media tweets"
|
description: "get user media tweets"
|
||||||
|
|
@ -44,9 +44,9 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/UserTweetsResponse"
|
$ref: "#/components/schemas/UserTweetsResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Tweet"
|
- "tweet"
|
||||||
|
|
||||||
/{{LikesQuery}}/Likes:
|
/graphql/{{queryId}}/Likes:
|
||||||
get:
|
get:
|
||||||
operationId: getLikes
|
operationId: getLikes
|
||||||
description: "get user likes tweets"
|
description: "get user likes tweets"
|
||||||
|
|
@ -58,7 +58,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/UserTweetsResponse"
|
$ref: "#/components/schemas/UserTweetsResponse"
|
||||||
tags:
|
tags:
|
||||||
- "Tweet"
|
- "tweet"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
|
||||||
15
src/openapi/paths/v1.1.yaml
Normal file
15
src/openapi/paths/v1.1.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
openapi: 3.0.3
|
||||||
|
info:
|
||||||
|
title: Twitter OpenAPI
|
||||||
|
version: 0.0.1
|
||||||
|
|
||||||
|
paths:
|
||||||
|
/1.1/friendships/create.json:
|
||||||
|
post:
|
||||||
|
operationId: postCreateFriendships
|
||||||
|
description: post create friendships
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Successful operation
|
||||||
|
tags:
|
||||||
|
- "v1.1"
|
||||||
212
tools/build.py
212
tools/build.py
|
|
@ -5,205 +5,55 @@ import yaml
|
||||||
import shutil
|
import shutil
|
||||||
import copy
|
import copy
|
||||||
import re
|
import re
|
||||||
|
from build_config import Config
|
||||||
|
|
||||||
class placeholder_manager:
|
|
||||||
data: dict
|
|
||||||
config: str = "src/config/placeholder.json"
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
with open(self.config, mode="r", encoding="utf-8") as f:
|
|
||||||
self.data = json.load(f)
|
|
||||||
|
|
||||||
def __replace(self, file, old: str, new) -> str:
|
|
||||||
if type(new) is dict:
|
|
||||||
dump = f"'{json.dumps(new)}'"
|
|
||||||
return file.replace(f'"{old}"', dump)
|
|
||||||
else:
|
|
||||||
return file.replace(f"{old}", new)
|
|
||||||
|
|
||||||
def replace(self, file: str) -> str:
|
|
||||||
for prefix in self.data.keys():
|
|
||||||
for key in self.data[prefix]:
|
|
||||||
value = self.data[prefix][key]
|
|
||||||
file = self.__replace(file, f"{{{{{prefix}{key}}}}}", value)
|
|
||||||
return file
|
|
||||||
|
|
||||||
def replace_file(self, file: str, prefix: str) -> str:
|
|
||||||
if self.data.get(prefix, None) is None:
|
|
||||||
return file
|
|
||||||
for key in self.data[prefix].keys():
|
|
||||||
value = self.data[prefix][key]
|
|
||||||
file = self.__replace(file, f"{{{{{key}}}}}", value)
|
|
||||||
return file
|
|
||||||
|
|
||||||
|
|
||||||
def placeholder_to_yaml(obj):
|
|
||||||
if type(obj) is dict:
|
|
||||||
return {
|
|
||||||
"type": "object",
|
|
||||||
"required": [i for i in obj],
|
|
||||||
"properties": {i: placeholder_to_yaml(obj[i]) for i in obj},
|
|
||||||
# "default": {i: placeholder_to_yaml(obj[i]) for i in obj},
|
|
||||||
# "example": {i: placeholder_to_yaml(obj[i]) for i in obj},
|
|
||||||
}
|
|
||||||
elif type(obj) is list:
|
|
||||||
if len(obj) == 0:
|
|
||||||
return {
|
|
||||||
"type": "array",
|
|
||||||
"items": {"type": "object"},
|
|
||||||
# "default": [],
|
|
||||||
# "example": [],
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
"type": "array",
|
|
||||||
"items": placeholder_to_yaml(obj[0]),
|
|
||||||
# "default": placeholder_to_yaml(obj[0]),
|
|
||||||
# "example": placeholder_to_yaml(obj[0]),
|
|
||||||
}
|
|
||||||
elif type(obj) is str:
|
|
||||||
return {"type": "string", "example": obj, "default": obj}
|
|
||||||
elif type(obj) is bool:
|
|
||||||
return {"type": "boolean", "example": obj, "default": obj}
|
|
||||||
elif type(obj) is int:
|
|
||||||
return {"type": "integer", "example": obj, "default": obj}
|
|
||||||
|
|
||||||
|
|
||||||
print("=== Build Start ===")
|
print("=== Build Start ===")
|
||||||
OUTPUT_DIR = "dist/{0}"
|
|
||||||
INPUT_DIR = "src/openapi"
|
|
||||||
METHODS = ["get", "put", "post", "delete", "options", "head", "patch", "trace"]
|
config = Config()
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shutil.rmtree("dist")
|
shutil.rmtree("dist")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
with open("src/config/variable.json", mode="r", encoding="utf-8") as f:
|
for lang in config.main().keys():
|
||||||
variable = json.load(f)
|
dist_replace = lambda x: x.replace(
|
||||||
|
config.INPUT_DIR, config.OUTPUT_DIR.format(lang), 1
|
||||||
|
)
|
||||||
|
|
||||||
|
for dir in glob.glob(os.path.join(config.INPUT_DIR, "**/")):
|
||||||
placeholder = placeholder_manager()
|
os.makedirs(dist_replace(dir), exist_ok=True)
|
||||||
|
|
||||||
for lang in variable.keys():
|
|
||||||
|
|
||||||
def read(file: str):
|
|
||||||
with open(file, mode="r", encoding="utf-8") as f:
|
|
||||||
return remove(f.read())
|
|
||||||
|
|
||||||
def write(file: str, data: str) -> None:
|
|
||||||
with open(
|
|
||||||
file.replace(INPUT_DIR, OUTPUT_DIR.format(lang), 1),
|
|
||||||
mode="w+",
|
|
||||||
encoding="utf-8",
|
|
||||||
) as f:
|
|
||||||
f.write(data)
|
|
||||||
|
|
||||||
def get_yaml(data, key):
|
|
||||||
return yaml.safe_load(placeholder.replace_file(str(data), key))
|
|
||||||
|
|
||||||
def remove(data):
|
|
||||||
for match in re.findall(r"(\{% (.*?) %\})", data):
|
|
||||||
equation = match[1].split(" ")
|
|
||||||
if equation[0] == "if" and equation[2] == "==":
|
|
||||||
if equation[3] != variable[lang][equation[1]]:
|
|
||||||
data = re.sub(
|
|
||||||
re.escape(match[0]) + "[\s\S]*?" + re.escape("{% endif %}"),
|
|
||||||
"",
|
|
||||||
data,
|
|
||||||
)
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
for dir in glob.glob(os.path.join(INPUT_DIR, "**/")):
|
|
||||||
os.makedirs(dir.replace(INPUT_DIR, OUTPUT_DIR.format(lang), 1), exist_ok=True)
|
|
||||||
|
|
||||||
parameters = read("src/config/parameters.yaml")
|
|
||||||
header = read("src/config/header.yaml")
|
|
||||||
|
|
||||||
paths = {}
|
paths = {}
|
||||||
for file in glob.glob(os.path.join(INPUT_DIR, "**/*.yaml")):
|
for file in glob.glob(os.path.join(config.INPUT_DIR, "**/*.yaml")):
|
||||||
file = file.replace(os.path.sep, "/")
|
file = file.replace(os.path.sep, "/")
|
||||||
relative = file.replace(INPUT_DIR, "", 1)
|
with open(file, mode="r", encoding="utf-8") as f:
|
||||||
|
load = yaml.safe_load(f)
|
||||||
|
for path in list(load["paths"]):
|
||||||
|
for method in list(load["paths"][path]):
|
||||||
|
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]:
|
||||||
|
key, value = hook.hook(key, value)
|
||||||
|
load["paths"][path][method] = value
|
||||||
|
load["paths"][key] = load["paths"].pop(path)
|
||||||
|
|
||||||
load = yaml.safe_load(placeholder.replace(read(file)))
|
escape = path.replace("/", "~1")
|
||||||
|
relative = file.replace(config.INPUT_DIR, "", 1)
|
||||||
|
paths.update({key: {"$ref": f".{relative}#/paths/{escape}"}})
|
||||||
|
|
||||||
for key in load["paths"].keys():
|
with open(dist_replace(file), mode="w+", encoding="utf-8") as f:
|
||||||
append = get_yaml(parameters, key.split("/")[-1])
|
f.write(yaml.dump(load))
|
||||||
param = append["paths"]["/parameters"]
|
|
||||||
for method in load["paths"][key].keys():
|
|
||||||
req = load["paths"][key][method]
|
|
||||||
|
|
||||||
req["parameters"] = req.get("parameters", [])
|
|
||||||
req["parameters"] += param[method].get("parameters", [])
|
|
||||||
|
|
||||||
if param[method].get("requestBody") is not None:
|
|
||||||
req["requestBody"] = param[method].get("requestBody")
|
|
||||||
|
|
||||||
if variable[lang].get(method + "_parameters") == "schema_content":
|
|
||||||
for p_key in placeholder.data[key.split("/")[-1]].keys():
|
|
||||||
if p_key.lower() == "query":
|
|
||||||
continue
|
|
||||||
req["parameters"].append(
|
|
||||||
{
|
|
||||||
"name": p_key.lower(),
|
|
||||||
"in": "query",
|
|
||||||
"required": True,
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": placeholder_to_yaml(
|
|
||||||
placeholder.data[key.split("/")[-1]][p_key]
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if variable[lang].get(method + "_parameters") == "schema_parameters":
|
|
||||||
for p_key in placeholder.data[key.split("/")[-1]].keys():
|
|
||||||
if p_key.lower() == "query":
|
|
||||||
continue
|
|
||||||
req["parameters"].append(
|
|
||||||
{
|
|
||||||
"name": p_key.lower(),
|
|
||||||
"in": "query",
|
|
||||||
"required": True,
|
|
||||||
"schema": placeholder_to_yaml(
|
|
||||||
placeholder.data[key.split("/")[-1]][p_key]
|
|
||||||
),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if variable[lang].get(method + "_parameters") == "schema_request_body":
|
|
||||||
data = placeholder.data[key.split("/")[-1]]
|
|
||||||
schema = {i: placeholder_to_yaml(data[i]) for i in data.keys()}
|
|
||||||
|
|
||||||
req["requestBody"] = {
|
|
||||||
"description": key.split("/")[-1] + "body",
|
|
||||||
"required": True,
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"properties": schema,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
append = get_yaml(header, key.split("/")[-1])
|
|
||||||
req = load["paths"][key][method]
|
|
||||||
req["responses"]["200"]["headers"] = append["components"]["headers"]
|
|
||||||
|
|
||||||
escape = key.replace("/", "~1")
|
|
||||||
paths.update({key: {"$ref": f".{relative}#/paths/{escape}"}})
|
|
||||||
write(file, yaml.dump(load))
|
|
||||||
|
|
||||||
file = "src/openapi/openapi-3.0.yaml"
|
file = "src/openapi/openapi-3.0.yaml"
|
||||||
data = read(file)
|
with open(file, mode="r", encoding="utf-8") as f:
|
||||||
|
openapi = yaml.safe_load(f)
|
||||||
for path in paths:
|
for path in paths:
|
||||||
load = yaml.safe_load(placeholder.replace(data))
|
|
||||||
load["paths"] = paths
|
load["paths"] = paths
|
||||||
|
with open(dist_replace(file), mode="w+", encoding="utf-8") as f:
|
||||||
write(file, yaml.dump(load))
|
f.write(yaml.dump(load))
|
||||||
|
|
||||||
print("=== Build End ===")
|
print("=== Build End ===")
|
||||||
|
|
|
||||||
111
tools/build_config.py
Normal file
111
tools/build_config.py
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
from hooks import *
|
||||||
|
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
OUTPUT_DIR = "dist/{0}"
|
||||||
|
INPUT_DIR = "src/openapi"
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
return {
|
||||||
|
"docs": {
|
||||||
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
||||||
|
"request": {
|
||||||
|
key: [
|
||||||
|
ReplaceQueryIdPlaceholder(),
|
||||||
|
SetResponsesHeader(),
|
||||||
|
AddParametersOnContent(),
|
||||||
|
]
|
||||||
|
for key in ["default", "user", "userList", "tweet"]
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
"post": [
|
||||||
|
ReplaceQueryIdPlaceholder(),
|
||||||
|
SetResponsesHeader(),
|
||||||
|
AddParametersOnParameters(),
|
||||||
|
],
|
||||||
|
"v1.1": [SetResponsesHeader()],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"dart": {
|
||||||
|
"openapi": [],
|
||||||
|
"request": {
|
||||||
|
key: [
|
||||||
|
ReplaceQueryIdPlaceholder(),
|
||||||
|
AddSecuritySchemesOnHeader(),
|
||||||
|
SetResponsesHeader(),
|
||||||
|
AddParametersOnParametersAsString(),
|
||||||
|
]
|
||||||
|
for key in ["default", "user", "userList", "tweet"]
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
"post": [
|
||||||
|
ReplaceQueryIdPlaceholder(),
|
||||||
|
AddSecuritySchemesOnHeader(),
|
||||||
|
SetResponsesHeader(),
|
||||||
|
AddParametersOnParametersAsObject(),
|
||||||
|
],
|
||||||
|
"v1.1": [SetResponsesHeader()],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"typescript": {
|
||||||
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
||||||
|
"request": {
|
||||||
|
key: [
|
||||||
|
ReplaceQueryIdPlaceholder(),
|
||||||
|
SetResponsesHeader(),
|
||||||
|
AddParametersOnParametersAsString(),
|
||||||
|
]
|
||||||
|
for key in ["default", "user", "userList", "tweet"]
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
"post": [
|
||||||
|
ReplaceQueryIdPlaceholder(),
|
||||||
|
SetResponsesHeader(),
|
||||||
|
AddParametersOnParametersAsObject(),
|
||||||
|
],
|
||||||
|
"v1.1": [SetResponsesHeader()],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
||||||
|
"request": {
|
||||||
|
key: [
|
||||||
|
ReplaceQueryIdPlaceholder(),
|
||||||
|
SetResponsesHeader(),
|
||||||
|
AddParametersOnParametersAsString(),
|
||||||
|
]
|
||||||
|
for key in ["default", "user", "userList", "tweet"]
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
"post": [
|
||||||
|
ReplaceQueryIdPlaceholder(),
|
||||||
|
SetResponsesHeader(),
|
||||||
|
AddParametersOnParametersAsString(),
|
||||||
|
],
|
||||||
|
"v1.1": [SetResponsesHeader()],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
"docs": {
|
||||||
|
"header": "securitySchemes",
|
||||||
|
"get_parameters": "schema_content",
|
||||||
|
"post_parameters": "schema_parameters"
|
||||||
|
},
|
||||||
|
"dart": {
|
||||||
|
"header": "parameters",
|
||||||
|
"get_parameters": "string",
|
||||||
|
"post_parameters": "object"
|
||||||
|
},
|
||||||
|
"typescript": {
|
||||||
|
"header": "securitySchemes",
|
||||||
|
"get_parameters": "string",
|
||||||
|
"post_parameters": "object"
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"header": "securitySchemes",
|
||||||
|
"get_parameters": "string",
|
||||||
|
"post_parameters": "string"
|
||||||
|
}
|
||||||
|
"""
|
||||||
193
tools/hooks.py
Normal file
193
tools/hooks.py
Normal file
|
|
@ -0,0 +1,193 @@
|
||||||
|
import yaml
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
class HookBase:
|
||||||
|
PLACEHOLDER: dict
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
with open("src/config/placeholder.json", mode="r", encoding="utf-8") as f:
|
||||||
|
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}
|
||||||
|
value = {
|
||||||
|
"type": "object",
|
||||||
|
"required": [i for i in obj],
|
||||||
|
"properties": properties,
|
||||||
|
}
|
||||||
|
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])
|
||||||
|
value = {
|
||||||
|
"type": "array",
|
||||||
|
"items": properties,
|
||||||
|
}
|
||||||
|
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:
|
||||||
|
value = {
|
||||||
|
"type": "array",
|
||||||
|
"items": {"type": "object"},
|
||||||
|
}
|
||||||
|
value.update({"default": []} if default else {})
|
||||||
|
value.update({"example": []} if example else {})
|
||||||
|
return value
|
||||||
|
elif type(obj) is str:
|
||||||
|
return {"type": "string", "example": obj, "default": obj}
|
||||||
|
elif type(obj) is bool:
|
||||||
|
return {"type": "boolean", "example": obj, "default": obj}
|
||||||
|
elif type(obj) is int:
|
||||||
|
return {"type": "integer", "example": obj, "default": obj}
|
||||||
|
|
||||||
|
def load_component(self, name: str) -> dict:
|
||||||
|
with open(f"src/config/component/{name}.yaml", mode="r", encoding="utf-8") as f:
|
||||||
|
return yaml.safe_load(f)
|
||||||
|
|
||||||
|
|
||||||
|
class OpenapiHookBase(HookBase):
|
||||||
|
def hook(self, value: dict):
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class RequestHookBase(HookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
|
class AddSecuritySchemesOnSecuritySchemes(HookBase):
|
||||||
|
def hook(self, value: dict):
|
||||||
|
component = self.load_component("security_schemes")
|
||||||
|
param = component["components"]["securitySchemes"]
|
||||||
|
value["components"]["securitySchemes"].extend(param)
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class AddSecuritySchemesOnHeader(RequestHookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
value["parameters"] = value.get("parameters", [])
|
||||||
|
component = self.load_component("security_schemes")
|
||||||
|
param = component["paths"]["/parameters"]["get"]["parameters"]
|
||||||
|
value["parameters"].extend(param)
|
||||||
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
|
class ReplaceQueryIdPlaceholder(RequestHookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
path_name = path.split("/")[-1]
|
||||||
|
new = self.PLACEHOLDER[path_name]["queryId"]
|
||||||
|
return path.replace(r"{{queryId}}", new), value
|
||||||
|
|
||||||
|
|
||||||
|
class SetResponsesHeader(RequestHookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
component = self.load_component("response_header")
|
||||||
|
value["responses"]["200"]["headers"] = component["components"]["headers"]
|
||||||
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
|
class AddParametersOnParametersAsString(RequestHookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
value["parameters"] = value.get("parameters", [])
|
||||||
|
path_name = path.split("/")[-1]
|
||||||
|
for key in self.PLACEHOLDER[path_name].keys():
|
||||||
|
example = json.dumps(self.PLACEHOLDER[path_name][key])
|
||||||
|
value["parameters"].append(
|
||||||
|
{
|
||||||
|
"name": key,
|
||||||
|
"in": "query",
|
||||||
|
"required": True,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"default": example,
|
||||||
|
"example": example,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
|
class AddParametersOnParametersAsObject(RequestHookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
value["parameters"] = value.get("parameters", [])
|
||||||
|
path_name = path.split("/")[-1]
|
||||||
|
for key in self.PLACEHOLDER[path_name].keys():
|
||||||
|
example = json.dumps(self.PLACEHOLDER[path_name][key])
|
||||||
|
value["parameters"].append(
|
||||||
|
{
|
||||||
|
"name": key,
|
||||||
|
"in": "query",
|
||||||
|
"required": True,
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"default": example,
|
||||||
|
"example": example,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
|
class AddParametersOnContent(RequestHookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
value["parameters"] = value.get("parameters", [])
|
||||||
|
path_name = path.split("/")[-1]
|
||||||
|
for key in self.PLACEHOLDER[path_name].keys():
|
||||||
|
value["parameters"].append(
|
||||||
|
{
|
||||||
|
"name": key,
|
||||||
|
"in": "query",
|
||||||
|
"required": True,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": self.placeholder_to_yaml(
|
||||||
|
self.PLACEHOLDER[path_name][key]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
|
class AddParametersOnParameters(RequestHookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
value["parameters"] = value.get("parameters", [])
|
||||||
|
path_name = path.split("/")[-1]
|
||||||
|
for key in self.PLACEHOLDER[path_name].keys():
|
||||||
|
value["parameters"].append(
|
||||||
|
{
|
||||||
|
"name": key,
|
||||||
|
"in": "query",
|
||||||
|
"required": True,
|
||||||
|
"schema": self.placeholder_to_yaml(
|
||||||
|
self.PLACEHOLDER[path_name][key]
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
|
class AddParametersOnBody(RequestHookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
value["parameters"] = value.get("parameters", [])
|
||||||
|
path_name = path.split("/")[-1]
|
||||||
|
data = self.PLACEHOLDER[path_name]
|
||||||
|
schema = {i: self.placeholder_to_yaml(data[i]) for i in data.keys()}
|
||||||
|
value["requestBody"] = {
|
||||||
|
"description": "body",
|
||||||
|
"required": True,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"properties": schema,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return path, value
|
||||||
Loading…
Add table
Add a link
Reference in a new issue