mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-11 23:50:26 +01:00
Merge pull request #9 from fa0311/thecodrr-feature/dynamic-query-id-in-path
Static generation of default values by the AddPathQueryIdOnParameters hook
This commit is contained in:
commit
10aaec8df8
12 changed files with 80 additions and 73 deletions
|
|
@ -4,12 +4,10 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/graphql/{queryId}/Bookmarks:
|
/graphql/{pathQueryId}/Bookmarks:
|
||||||
get:
|
get:
|
||||||
operationId: getBookmarks
|
operationId: getBookmarks
|
||||||
description: get bookmarks
|
description: get bookmarks
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,10 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/graphql/{queryId}/Following:
|
/graphql/{pathQueryId}/Following:
|
||||||
get:
|
get:
|
||||||
operationId: getFollowing
|
operationId: getFollowing
|
||||||
description: get user list of following
|
description: get user list of following
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -20,12 +18,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "user-list"
|
- "user-list"
|
||||||
|
|
||||||
/graphql/{queryId}/Followers:
|
/graphql/{pathQueryId}/Followers:
|
||||||
get:
|
get:
|
||||||
operationId: getFollowers
|
operationId: getFollowers
|
||||||
description: get user list of followers
|
description: get user list of followers
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,10 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/graphql/{queryId}/FavoriteTweet:
|
/graphql/{pathQueryId}/FavoriteTweet:
|
||||||
post:
|
post:
|
||||||
operationId: postFavoriteTweet
|
operationId: postFavoriteTweet
|
||||||
description: favorite Tweet
|
description: favorite Tweet
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -20,12 +18,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "post"
|
- "post"
|
||||||
|
|
||||||
/graphql/{queryId}/UnfavoriteTweet:
|
/graphql/{pathQueryId}/UnfavoriteTweet:
|
||||||
post:
|
post:
|
||||||
operationId: postUnfavoriteTweet
|
operationId: postUnfavoriteTweet
|
||||||
description: unfavorite Tweet
|
description: unfavorite Tweet
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -36,12 +32,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "post"
|
- "post"
|
||||||
|
|
||||||
/graphql/{queryId}/CreateRetweet:
|
/graphql/{pathQueryId}/CreateRetweet:
|
||||||
post:
|
post:
|
||||||
operationId: postCreateRetweet
|
operationId: postCreateRetweet
|
||||||
description: create Retweet
|
description: create Retweet
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -52,12 +46,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "post"
|
- "post"
|
||||||
|
|
||||||
/graphql/{queryId}/DeleteRetweet:
|
/graphql/{pathQueryId}/DeleteRetweet:
|
||||||
post:
|
post:
|
||||||
operationId: postDeleteRetweet
|
operationId: postDeleteRetweet
|
||||||
description: delete Retweet
|
description: delete Retweet
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -68,12 +60,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "post"
|
- "post"
|
||||||
|
|
||||||
/graphql/{queryId}/CreateTweet:
|
/graphql/{pathQueryId}/CreateTweet:
|
||||||
post:
|
post:
|
||||||
operationId: postCreateTweet
|
operationId: postCreateTweet
|
||||||
description: create Tweet
|
description: create Tweet
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -84,12 +74,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "post"
|
- "post"
|
||||||
|
|
||||||
/graphql/{queryId}/DeleteTweet:
|
/graphql/{pathQueryId}/DeleteTweet:
|
||||||
post:
|
post:
|
||||||
operationId: postDeleteTweet
|
operationId: postDeleteTweet
|
||||||
description: delete Retweet
|
description: delete Retweet
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,10 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/graphql/{queryId}/ProfileSpotlightsQuery:
|
/graphql/{pathQueryId}/ProfileSpotlightsQuery:
|
||||||
get:
|
get:
|
||||||
operationId: getProfileSpotlightsQuery
|
operationId: getProfileSpotlightsQuery
|
||||||
description: "get user by screen name"
|
description: "get user by screen name"
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,10 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/graphql/{queryId}/HomeTimeline:
|
/graphql/{pathQueryId}/HomeTimeline:
|
||||||
get:
|
get:
|
||||||
operationId: getHomeTimeline
|
operationId: getHomeTimeline
|
||||||
description: get tweet list of timeline
|
description: get tweet list of timeline
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -20,12 +18,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "tweet"
|
- "tweet"
|
||||||
|
|
||||||
/graphql/{queryId}/HomeLatestTimeline:
|
/graphql/{pathQueryId}/HomeLatestTimeline:
|
||||||
get:
|
get:
|
||||||
operationId: getHomeLatestTimeline
|
operationId: getHomeLatestTimeline
|
||||||
description: get tweet list of timeline
|
description: get tweet list of timeline
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -36,12 +32,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "tweet"
|
- "tweet"
|
||||||
|
|
||||||
/graphql/{queryId}/ListLatestTweetsTimeline:
|
/graphql/{pathQueryId}/ListLatestTweetsTimeline:
|
||||||
get:
|
get:
|
||||||
operationId: getListLatestTweetsTimeline
|
operationId: getListLatestTweetsTimeline
|
||||||
description: get tweet list of timeline
|
description: get tweet list of timeline
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,10 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/graphql/{queryId}/TweetDetail:
|
/graphql/{pathQueryId}/TweetDetail:
|
||||||
get:
|
get:
|
||||||
operationId: getTweetDetail
|
operationId: getTweetDetail
|
||||||
description: get TweetDetail
|
description: get TweetDetail
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,10 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/graphql/{queryId}/UserByScreenName:
|
/graphql/{pathQueryId}/UserByScreenName:
|
||||||
get:
|
get:
|
||||||
operationId: getUserByScreenName
|
operationId: getUserByScreenName
|
||||||
description: "get user by screen name"
|
description: "get user by screen name"
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,10 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/graphql/{queryId}/UserTweets:
|
/graphql/{pathQueryId}/UserTweets:
|
||||||
get:
|
get:
|
||||||
operationId: getUserTweets
|
operationId: getUserTweets
|
||||||
description: "get user tweets"
|
description: "get user tweets"
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -20,12 +18,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "tweet"
|
- "tweet"
|
||||||
|
|
||||||
/graphql/{queryId}/UserTweetsAndReplies:
|
/graphql/{pathQueryId}/UserTweetsAndReplies:
|
||||||
get:
|
get:
|
||||||
operationId: getUserTweetsAndReplies
|
operationId: getUserTweetsAndReplies
|
||||||
description: "get user replies tweets"
|
description: "get user replies tweets"
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -36,12 +32,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "tweet"
|
- "tweet"
|
||||||
|
|
||||||
/graphql/{queryId}/UserMedia:
|
/graphql/{pathQueryId}/UserMedia:
|
||||||
get:
|
get:
|
||||||
operationId: getUserMedia
|
operationId: getUserMedia
|
||||||
description: "get user media tweets"
|
description: "get user media tweets"
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
@ -52,12 +46,10 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- "tweet"
|
- "tweet"
|
||||||
|
|
||||||
/graphql/{queryId}/Likes:
|
/graphql/{pathQueryId}/Likes:
|
||||||
get:
|
get:
|
||||||
operationId: getLikes
|
operationId: getLikes
|
||||||
description: "get user likes tweets"
|
description: "get user likes tweets"
|
||||||
parameters:
|
|
||||||
- $ref: "../resources/parameters.yaml#/components/parameters/queryId"
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
|
info:
|
||||||
|
title: Twitter OpenAPI
|
||||||
|
version: 0.0.1
|
||||||
|
|
||||||
paths: {}
|
paths: {}
|
||||||
|
|
||||||
components:
|
components:
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@ components:
|
||||||
card:
|
card:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
rest_id: string
|
rest_id:
|
||||||
|
type: string
|
||||||
legacy:
|
legacy:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@ class Config:
|
||||||
"docs": {
|
"docs": {
|
||||||
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
||||||
"schemas": [],
|
"schemas": [],
|
||||||
"other":[],
|
"other": [],
|
||||||
"request": {
|
"request": {
|
||||||
key: [
|
key: [
|
||||||
SetResponsesHeader(suffix=None),
|
SetResponsesHeader(suffix=None),
|
||||||
|
AddPathQueryIdOnParameters(split=-1),
|
||||||
AddParametersOnContent(
|
AddParametersOnContent(
|
||||||
split=-1, contentType="application/json"
|
split=-1, contentType="application/json"
|
||||||
),
|
),
|
||||||
|
|
@ -23,6 +24,7 @@ class Config:
|
||||||
| {
|
| {
|
||||||
key: [
|
key: [
|
||||||
SetResponsesHeader(suffix=None),
|
SetResponsesHeader(suffix=None),
|
||||||
|
AddPathQueryIdOnParameters(split=-1),
|
||||||
AddParametersOnParameters(
|
AddParametersOnParameters(
|
||||||
split=-1,
|
split=-1,
|
||||||
schemaType=None,
|
schemaType=None,
|
||||||
|
|
@ -56,11 +58,12 @@ class Config:
|
||||||
"dart": {
|
"dart": {
|
||||||
"openapi": [],
|
"openapi": [],
|
||||||
"schemas": [],
|
"schemas": [],
|
||||||
"other":[],
|
"other": [],
|
||||||
"request": {
|
"request": {
|
||||||
key: [
|
key: [
|
||||||
AddSecuritySchemesOnHeader(split=-1),
|
AddSecuritySchemesOnHeader(split=-1),
|
||||||
SetResponsesHeader(suffix=None),
|
SetResponsesHeader(suffix=None),
|
||||||
|
AddPathQueryIdOnParameters(split=-1),
|
||||||
AddParametersOnParameters(
|
AddParametersOnParameters(
|
||||||
split=-1,
|
split=-1,
|
||||||
schemaType="string",
|
schemaType="string",
|
||||||
|
|
@ -72,6 +75,7 @@ class Config:
|
||||||
key: [
|
key: [
|
||||||
AddSecuritySchemesOnHeader(split=-1),
|
AddSecuritySchemesOnHeader(split=-1),
|
||||||
SetResponsesHeader(suffix=None),
|
SetResponsesHeader(suffix=None),
|
||||||
|
AddPathQueryIdOnParameters(split=-1),
|
||||||
AddParametersOnBody(
|
AddParametersOnBody(
|
||||||
split=-1,
|
split=-1,
|
||||||
schemaType=None,
|
schemaType=None,
|
||||||
|
|
@ -108,10 +112,11 @@ class Config:
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
||||||
"schemas": [],
|
"schemas": [],
|
||||||
"other":[],
|
"other": [],
|
||||||
"request": {
|
"request": {
|
||||||
key: [
|
key: [
|
||||||
SetResponsesHeader(suffix=None),
|
SetResponsesHeader(suffix=None),
|
||||||
|
AddPathQueryIdOnParameters(split=-1),
|
||||||
AddParametersOnParameters(
|
AddParametersOnParameters(
|
||||||
split=-1,
|
split=-1,
|
||||||
schemaType="string",
|
schemaType="string",
|
||||||
|
|
@ -122,6 +127,7 @@ class Config:
|
||||||
| {
|
| {
|
||||||
key: [
|
key: [
|
||||||
SetResponsesHeader(suffix=None),
|
SetResponsesHeader(suffix=None),
|
||||||
|
AddPathQueryIdOnParameters(split=-1),
|
||||||
AddParametersOnBody(
|
AddParametersOnBody(
|
||||||
split=-1,
|
split=-1,
|
||||||
schemaType=None,
|
schemaType=None,
|
||||||
|
|
@ -156,10 +162,11 @@ class Config:
|
||||||
"test": {
|
"test": {
|
||||||
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
"openapi": [AddSecuritySchemesOnSecuritySchemes()],
|
||||||
"schemas": [],
|
"schemas": [],
|
||||||
"other":[],
|
"other": [],
|
||||||
"request": {
|
"request": {
|
||||||
key: [
|
key: [
|
||||||
SetResponsesHeader(suffix=None),
|
SetResponsesHeader(suffix=None),
|
||||||
|
AddPathQueryIdOnParameters(split=-1),
|
||||||
AddParametersOnParameters(
|
AddParametersOnParameters(
|
||||||
split=-1,
|
split=-1,
|
||||||
schemaType="string",
|
schemaType="string",
|
||||||
|
|
@ -170,6 +177,7 @@ class Config:
|
||||||
| {
|
| {
|
||||||
key: [
|
key: [
|
||||||
SetResponsesHeader(suffix=None),
|
SetResponsesHeader(suffix=None),
|
||||||
|
AddPathQueryIdOnParameters(split=-1),
|
||||||
AddParametersOnParameters(
|
AddParametersOnParameters(
|
||||||
split=-1,
|
split=-1,
|
||||||
schemaType="string",
|
schemaType="string",
|
||||||
|
|
|
||||||
|
|
@ -58,15 +58,17 @@ class HookBase:
|
||||||
|
|
||||||
|
|
||||||
class OpenapiHookBase(HookBase):
|
class OpenapiHookBase(HookBase):
|
||||||
def hook(self, value: dict)->dict:
|
def hook(self, value: dict) -> dict:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
class OtherHookBase(HookBase):
|
class OtherHookBase(HookBase):
|
||||||
def hook(self)->tuple[str, dict]:
|
def hook(self) -> tuple[str, dict]:
|
||||||
return "", {}
|
return "", {}
|
||||||
|
|
||||||
|
|
||||||
class SchemasHookBase(HookBase):
|
class SchemasHookBase(HookBase):
|
||||||
def hook(self, value: dict)->dict:
|
def hook(self, value: dict) -> dict:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -78,7 +80,7 @@ class RequestHookBase(HookBase):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.split = split
|
self.split = split
|
||||||
|
|
||||||
def hook(self, path: str, value: dict)->tuple[str, dict]:
|
def hook(self, path: str, value: dict) -> tuple[str, dict]:
|
||||||
value["parameters"] = value.get("parameters", [])
|
value["parameters"] = value.get("parameters", [])
|
||||||
self.path_name = "/".join(path.split("/")[self.split :])
|
self.path_name = "/".join(path.split("/")[self.split :])
|
||||||
return path, value
|
return path, value
|
||||||
|
|
@ -118,6 +120,14 @@ class AddSecuritySchemesOnHeader(RequestHookBase):
|
||||||
value["parameters"].extend(param)
|
value["parameters"].extend(param)
|
||||||
return path, value
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
|
class ReplaceQueryIdPlaceholder(RequestHookBase):
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
path, value = super().hook(path, value)
|
||||||
|
new = self.PLACEHOLDER[self.path_name]["queryId"]
|
||||||
|
return path.replace(r"{pathQueryId}", new), value
|
||||||
|
|
||||||
|
|
||||||
class SetResponsesHeader(RequestHookBase):
|
class SetResponsesHeader(RequestHookBase):
|
||||||
suffix: str
|
suffix: str
|
||||||
|
|
||||||
|
|
@ -132,6 +142,28 @@ class SetResponsesHeader(RequestHookBase):
|
||||||
return path, value
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
|
class AddPathQueryIdOnParameters(RequestHookBase):
|
||||||
|
def __init__(self, split: str = 1):
|
||||||
|
super().__init__(split=split)
|
||||||
|
|
||||||
|
def hook(self, path: str, value: dict):
|
||||||
|
path, value = super().hook(path, value)
|
||||||
|
data = self.PLACEHOLDER[self.path_name]
|
||||||
|
value["parameters"].append(
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "pathQueryId",
|
||||||
|
"required": True,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"default": data["queryId"],
|
||||||
|
"example": data["queryId"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return path, value
|
||||||
|
|
||||||
|
|
||||||
# OnParameters
|
# OnParameters
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue