mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-10 15:20:26 +01:00
fix error schema
Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
parent
162ad96a13
commit
28e49c7ddb
9 changed files with 90 additions and 199 deletions
37
dist/compatible/openapi-3.0.yaml
vendored
37
dist/compatible/openapi-3.0.yaml
vendored
|
|
@ -755,7 +755,6 @@ components:
|
||||||
- kind
|
- kind
|
||||||
- name
|
- name
|
||||||
- source
|
- source
|
||||||
- retry_after
|
|
||||||
- tracing
|
- tracing
|
||||||
type: object
|
type: object
|
||||||
ErrorExtensions:
|
ErrorExtensions:
|
||||||
|
|
@ -775,19 +774,10 @@ components:
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
- source
|
- source
|
||||||
- retry_after
|
|
||||||
- code
|
- code
|
||||||
- kind
|
- kind
|
||||||
- tracing
|
- tracing
|
||||||
type: object
|
type: object
|
||||||
ErrorResponse:
|
|
||||||
properties:
|
|
||||||
errors:
|
|
||||||
$ref: '#/components/schemas/Errors'
|
|
||||||
required:
|
|
||||||
- errors
|
|
||||||
- data
|
|
||||||
type: object
|
|
||||||
Errors:
|
Errors:
|
||||||
properties:
|
properties:
|
||||||
errors:
|
errors:
|
||||||
|
|
@ -814,25 +804,6 @@ components:
|
||||||
type: array
|
type: array
|
||||||
required:
|
required:
|
||||||
- media
|
- media
|
||||||
Extensions:
|
|
||||||
properties:
|
|
||||||
code:
|
|
||||||
type: integer
|
|
||||||
kind:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
source:
|
|
||||||
type: string
|
|
||||||
tracing:
|
|
||||||
$ref: '#/components/schemas/Tracing'
|
|
||||||
required:
|
|
||||||
- name
|
|
||||||
- source
|
|
||||||
- code
|
|
||||||
- kind
|
|
||||||
- tracing
|
|
||||||
type: object
|
|
||||||
FavoriteTweet:
|
FavoriteTweet:
|
||||||
properties:
|
properties:
|
||||||
favorite_tweet:
|
favorite_tweet:
|
||||||
|
|
@ -2482,17 +2453,25 @@ components:
|
||||||
properties:
|
properties:
|
||||||
__typename:
|
__typename:
|
||||||
$ref: '#/components/schemas/TypeName'
|
$ref: '#/components/schemas/TypeName'
|
||||||
|
TweetUnavailable:
|
||||||
|
properties:
|
||||||
|
__typename:
|
||||||
|
$ref: '#/components/schemas/TypeName'
|
||||||
|
reason:
|
||||||
|
type: string
|
||||||
TweetUnion:
|
TweetUnion:
|
||||||
discriminator:
|
discriminator:
|
||||||
mapping":
|
mapping":
|
||||||
Tweet: '#/components/schemas/Tweet'
|
Tweet: '#/components/schemas/Tweet'
|
||||||
TweetTombstone: '#/components/schemas/TweetTombstone'
|
TweetTombstone: '#/components/schemas/TweetTombstone'
|
||||||
|
TweetUnavailable: '#/components/schemas/TweetUnavailable'
|
||||||
TweetWithVisibilityResults: '#/components/schemas/TweetWithVisibilityResults'
|
TweetWithVisibilityResults: '#/components/schemas/TweetWithVisibilityResults'
|
||||||
propertyName: __typename
|
propertyName: __typename
|
||||||
oneOf:
|
oneOf:
|
||||||
- $ref: '#/components/schemas/Tweet'
|
- $ref: '#/components/schemas/Tweet'
|
||||||
- $ref: '#/components/schemas/TweetWithVisibilityResults'
|
- $ref: '#/components/schemas/TweetWithVisibilityResults'
|
||||||
- $ref: '#/components/schemas/TweetTombstone'
|
- $ref: '#/components/schemas/TweetTombstone'
|
||||||
|
- $ref: '#/components/schemas/TweetUnavailable'
|
||||||
TweetView:
|
TweetView:
|
||||||
properties:
|
properties:
|
||||||
count:
|
count:
|
||||||
|
|
|
||||||
37
dist/compatible_discriminator/openapi-3.0.yaml
vendored
37
dist/compatible_discriminator/openapi-3.0.yaml
vendored
|
|
@ -755,7 +755,6 @@ components:
|
||||||
- kind
|
- kind
|
||||||
- name
|
- name
|
||||||
- source
|
- source
|
||||||
- retry_after
|
|
||||||
- tracing
|
- tracing
|
||||||
type: object
|
type: object
|
||||||
ErrorExtensions:
|
ErrorExtensions:
|
||||||
|
|
@ -775,19 +774,10 @@ components:
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
- source
|
- source
|
||||||
- retry_after
|
|
||||||
- code
|
- code
|
||||||
- kind
|
- kind
|
||||||
- tracing
|
- tracing
|
||||||
type: object
|
type: object
|
||||||
ErrorResponse:
|
|
||||||
properties:
|
|
||||||
errors:
|
|
||||||
$ref: '#/components/schemas/Errors'
|
|
||||||
required:
|
|
||||||
- errors
|
|
||||||
- data
|
|
||||||
type: object
|
|
||||||
Errors:
|
Errors:
|
||||||
properties:
|
properties:
|
||||||
errors:
|
errors:
|
||||||
|
|
@ -814,25 +804,6 @@ components:
|
||||||
type: array
|
type: array
|
||||||
required:
|
required:
|
||||||
- media
|
- media
|
||||||
Extensions:
|
|
||||||
properties:
|
|
||||||
code:
|
|
||||||
type: integer
|
|
||||||
kind:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
source:
|
|
||||||
type: string
|
|
||||||
tracing:
|
|
||||||
$ref: '#/components/schemas/Tracing'
|
|
||||||
required:
|
|
||||||
- name
|
|
||||||
- source
|
|
||||||
- code
|
|
||||||
- kind
|
|
||||||
- tracing
|
|
||||||
type: object
|
|
||||||
FavoriteTweet:
|
FavoriteTweet:
|
||||||
properties:
|
properties:
|
||||||
favorite_tweet:
|
favorite_tweet:
|
||||||
|
|
@ -2482,17 +2453,25 @@ components:
|
||||||
properties:
|
properties:
|
||||||
__typename:
|
__typename:
|
||||||
$ref: '#/components/schemas/TypeName'
|
$ref: '#/components/schemas/TypeName'
|
||||||
|
TweetUnavailable:
|
||||||
|
properties:
|
||||||
|
__typename:
|
||||||
|
$ref: '#/components/schemas/TypeName'
|
||||||
|
reason:
|
||||||
|
type: string
|
||||||
TweetUnion:
|
TweetUnion:
|
||||||
discriminator:
|
discriminator:
|
||||||
mapping":
|
mapping":
|
||||||
Tweet: '#/components/schemas/Tweet'
|
Tweet: '#/components/schemas/Tweet'
|
||||||
TweetTombstone: '#/components/schemas/TweetTombstone'
|
TweetTombstone: '#/components/schemas/TweetTombstone'
|
||||||
|
TweetUnavailable: '#/components/schemas/TweetUnavailable'
|
||||||
TweetWithVisibilityResults: '#/components/schemas/TweetWithVisibilityResults'
|
TweetWithVisibilityResults: '#/components/schemas/TweetWithVisibilityResults'
|
||||||
propertyName: __typename
|
propertyName: __typename
|
||||||
oneOf:
|
oneOf:
|
||||||
- $ref: '#/components/schemas/Tweet'
|
- $ref: '#/components/schemas/Tweet'
|
||||||
- $ref: '#/components/schemas/TweetWithVisibilityResults'
|
- $ref: '#/components/schemas/TweetWithVisibilityResults'
|
||||||
- $ref: '#/components/schemas/TweetTombstone'
|
- $ref: '#/components/schemas/TweetTombstone'
|
||||||
|
- $ref: '#/components/schemas/TweetUnavailable'
|
||||||
TweetView:
|
TweetView:
|
||||||
properties:
|
properties:
|
||||||
count:
|
count:
|
||||||
|
|
|
||||||
37
dist/docs/openapi-3.0.yaml
vendored
37
dist/docs/openapi-3.0.yaml
vendored
|
|
@ -755,7 +755,6 @@ components:
|
||||||
- kind
|
- kind
|
||||||
- name
|
- name
|
||||||
- source
|
- source
|
||||||
- retry_after
|
|
||||||
- tracing
|
- tracing
|
||||||
type: object
|
type: object
|
||||||
ErrorExtensions:
|
ErrorExtensions:
|
||||||
|
|
@ -775,19 +774,10 @@ components:
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
- source
|
- source
|
||||||
- retry_after
|
|
||||||
- code
|
- code
|
||||||
- kind
|
- kind
|
||||||
- tracing
|
- tracing
|
||||||
type: object
|
type: object
|
||||||
ErrorResponse:
|
|
||||||
properties:
|
|
||||||
errors:
|
|
||||||
$ref: '#/components/schemas/Errors'
|
|
||||||
required:
|
|
||||||
- errors
|
|
||||||
- data
|
|
||||||
type: object
|
|
||||||
Errors:
|
Errors:
|
||||||
properties:
|
properties:
|
||||||
errors:
|
errors:
|
||||||
|
|
@ -814,25 +804,6 @@ components:
|
||||||
type: array
|
type: array
|
||||||
required:
|
required:
|
||||||
- media
|
- media
|
||||||
Extensions:
|
|
||||||
properties:
|
|
||||||
code:
|
|
||||||
type: integer
|
|
||||||
kind:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
source:
|
|
||||||
type: string
|
|
||||||
tracing:
|
|
||||||
$ref: '#/components/schemas/Tracing'
|
|
||||||
required:
|
|
||||||
- name
|
|
||||||
- source
|
|
||||||
- code
|
|
||||||
- kind
|
|
||||||
- tracing
|
|
||||||
type: object
|
|
||||||
FavoriteTweet:
|
FavoriteTweet:
|
||||||
properties:
|
properties:
|
||||||
favorite_tweet:
|
favorite_tweet:
|
||||||
|
|
@ -2482,17 +2453,25 @@ components:
|
||||||
properties:
|
properties:
|
||||||
__typename:
|
__typename:
|
||||||
$ref: '#/components/schemas/TypeName'
|
$ref: '#/components/schemas/TypeName'
|
||||||
|
TweetUnavailable:
|
||||||
|
properties:
|
||||||
|
__typename:
|
||||||
|
$ref: '#/components/schemas/TypeName'
|
||||||
|
reason:
|
||||||
|
type: string
|
||||||
TweetUnion:
|
TweetUnion:
|
||||||
discriminator:
|
discriminator:
|
||||||
mapping":
|
mapping":
|
||||||
Tweet: '#/components/schemas/Tweet'
|
Tweet: '#/components/schemas/Tweet'
|
||||||
TweetTombstone: '#/components/schemas/TweetTombstone'
|
TweetTombstone: '#/components/schemas/TweetTombstone'
|
||||||
|
TweetUnavailable: '#/components/schemas/TweetUnavailable'
|
||||||
TweetWithVisibilityResults: '#/components/schemas/TweetWithVisibilityResults'
|
TweetWithVisibilityResults: '#/components/schemas/TweetWithVisibilityResults'
|
||||||
propertyName: __typename
|
propertyName: __typename
|
||||||
oneOf:
|
oneOf:
|
||||||
- $ref: '#/components/schemas/Tweet'
|
- $ref: '#/components/schemas/Tweet'
|
||||||
- $ref: '#/components/schemas/TweetWithVisibilityResults'
|
- $ref: '#/components/schemas/TweetWithVisibilityResults'
|
||||||
- $ref: '#/components/schemas/TweetTombstone'
|
- $ref: '#/components/schemas/TweetTombstone'
|
||||||
|
- $ref: '#/components/schemas/TweetUnavailable'
|
||||||
TweetView:
|
TweetView:
|
||||||
properties:
|
properties:
|
||||||
count:
|
count:
|
||||||
|
|
|
||||||
31
other/error/GenericError.json
Normal file
31
other/error/GenericError.json
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"errors": [
|
||||||
|
{
|
||||||
|
"message": "_Missing: No status found with that ID.",
|
||||||
|
"locations": [
|
||||||
|
{
|
||||||
|
"line": 2,
|
||||||
|
"column": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"path": ["threaded_conversation_with_injections_v2"],
|
||||||
|
"extensions": {
|
||||||
|
"name": "GenericError",
|
||||||
|
"source": "Server",
|
||||||
|
"code": 144,
|
||||||
|
"kind": "NonFatal",
|
||||||
|
"tracing": {
|
||||||
|
"trace_id": "e6de8b2b694ae128"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"code": 144,
|
||||||
|
"kind": "NonFatal",
|
||||||
|
"name": "GenericError",
|
||||||
|
"source": "Server",
|
||||||
|
"tracing": {
|
||||||
|
"trace_id": "e6de8b2b694ae128"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
|
@ -4,19 +4,14 @@ info:
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
paths: {}
|
paths: {}
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
ErrorResponse:
|
Errors:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
- errors
|
- errors
|
||||||
- data
|
|
||||||
properties:
|
properties:
|
||||||
errors:
|
errors:
|
||||||
$ref: "#/components/schemas/Errors"
|
|
||||||
|
|
||||||
Errors:
|
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/Error"
|
$ref: "#/components/schemas/Error"
|
||||||
|
|
@ -32,7 +27,6 @@ components:
|
||||||
- kind
|
- kind
|
||||||
- name
|
- name
|
||||||
- source
|
- source
|
||||||
- retry_after
|
|
||||||
- tracing
|
- tracing
|
||||||
properties:
|
properties:
|
||||||
message:
|
message:
|
||||||
|
|
@ -46,7 +40,7 @@ components:
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
extensions:
|
extensions:
|
||||||
$ref: "#/components/schemas/Extensions"
|
$ref: "#/components/schemas/ErrorExtensions"
|
||||||
code:
|
code:
|
||||||
type: integer
|
type: integer
|
||||||
kind:
|
kind:
|
||||||
|
|
@ -71,7 +65,7 @@ components:
|
||||||
column:
|
column:
|
||||||
type: integer
|
type: integer
|
||||||
|
|
||||||
Extensions:
|
ErrorExtensions:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
|
|
@ -84,6 +78,8 @@ components:
|
||||||
type: string
|
type: string
|
||||||
source:
|
source:
|
||||||
type: string
|
type: string
|
||||||
|
retry_after:
|
||||||
|
type: integer
|
||||||
code:
|
code:
|
||||||
type: integer
|
type: integer
|
||||||
kind:
|
kind:
|
||||||
|
|
@ -98,3 +94,4 @@ components:
|
||||||
properties:
|
properties:
|
||||||
trace_id:
|
trace_id:
|
||||||
type: string
|
type: string
|
||||||
|
pattern: "^[0-9a-f]{16}$"
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ components:
|
||||||
ItemResult:
|
ItemResult:
|
||||||
properties:
|
properties:
|
||||||
__typename:
|
__typename:
|
||||||
$ref: "./typename.yaml#/components/schemas/TypeName" # null | TimelineTweet
|
$ref: "./typename.yaml#/components/schemas/TypeName" # null | TimelineTweet | TweetUnavailable
|
||||||
result:
|
result:
|
||||||
$ref: "./tweet.yaml#/components/schemas/TweetUnion"
|
$ref: "./tweet.yaml#/components/schemas/TweetUnion"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
||||||
openapi: 3.0.3
|
|
||||||
info:
|
|
||||||
title: Twitter OpenAPI
|
|
||||||
version: 0.0.1
|
|
||||||
|
|
||||||
paths: {}
|
|
||||||
components:
|
|
||||||
schemas:
|
|
||||||
Errors:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- errors
|
|
||||||
properties:
|
|
||||||
errors:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
|
|
||||||
Error:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- message
|
|
||||||
- locations
|
|
||||||
- path
|
|
||||||
- extensions
|
|
||||||
- code
|
|
||||||
- kind
|
|
||||||
- name
|
|
||||||
- source
|
|
||||||
- retry_after
|
|
||||||
- tracing
|
|
||||||
properties:
|
|
||||||
message:
|
|
||||||
type: string
|
|
||||||
locations:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/Location"
|
|
||||||
path:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
extensions:
|
|
||||||
$ref: "#/components/schemas/ErrorExtensions"
|
|
||||||
code:
|
|
||||||
type: integer
|
|
||||||
kind:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
source:
|
|
||||||
type: string
|
|
||||||
retry_after:
|
|
||||||
type: integer
|
|
||||||
tracing:
|
|
||||||
$ref: "#/components/schemas/Tracing"
|
|
||||||
|
|
||||||
Location:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- line
|
|
||||||
- column
|
|
||||||
properties:
|
|
||||||
line:
|
|
||||||
type: integer
|
|
||||||
column:
|
|
||||||
type: integer
|
|
||||||
|
|
||||||
ErrorExtensions:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- name
|
|
||||||
- source
|
|
||||||
- retry_after
|
|
||||||
- code
|
|
||||||
- kind
|
|
||||||
- tracing
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
source:
|
|
||||||
type: string
|
|
||||||
retry_after:
|
|
||||||
type: integer
|
|
||||||
code:
|
|
||||||
type: integer
|
|
||||||
kind:
|
|
||||||
type: string
|
|
||||||
tracing:
|
|
||||||
$ref: "#/components/schemas/Tracing"
|
|
||||||
|
|
||||||
Tracing:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- trace_id
|
|
||||||
properties:
|
|
||||||
trace_id:
|
|
||||||
type: string
|
|
||||||
pattern: "^[0-9a-f]{16}$"
|
|
||||||
|
|
@ -12,12 +12,14 @@ components:
|
||||||
- $ref: "#/components/schemas/Tweet"
|
- $ref: "#/components/schemas/Tweet"
|
||||||
- $ref: "#/components/schemas/TweetWithVisibilityResults"
|
- $ref: "#/components/schemas/TweetWithVisibilityResults"
|
||||||
- $ref: "#/components/schemas/TweetTombstone"
|
- $ref: "#/components/schemas/TweetTombstone"
|
||||||
|
- $ref: "#/components/schemas/TweetUnavailable"
|
||||||
discriminator:
|
discriminator:
|
||||||
propertyName: __typename
|
propertyName: __typename
|
||||||
mapping": # deprecated
|
mapping": # deprecated
|
||||||
Tweet: "#/components/schemas/Tweet"
|
Tweet: "#/components/schemas/Tweet"
|
||||||
TweetWithVisibilityResults: "#/components/schemas/TweetWithVisibilityResults"
|
TweetWithVisibilityResults: "#/components/schemas/TweetWithVisibilityResults"
|
||||||
TweetTombstone: "#/components/schemas/TweetTombstone"
|
TweetTombstone: "#/components/schemas/TweetTombstone"
|
||||||
|
TweetUnavailable: "#/components/schemas/TweetUnavailable"
|
||||||
|
|
||||||
TweetWithVisibilityResults:
|
TweetWithVisibilityResults:
|
||||||
required:
|
required:
|
||||||
|
|
@ -138,6 +140,13 @@ components:
|
||||||
$ref: "./typename.yaml#/components/schemas/TypeName" # TweetWithVisibilityResults
|
$ref: "./typename.yaml#/components/schemas/TypeName" # TweetWithVisibilityResults
|
||||||
additionalProperties: true # todo
|
additionalProperties: true # todo
|
||||||
|
|
||||||
|
TweetUnavailable: # nsfw tweet
|
||||||
|
properties:
|
||||||
|
__typename:
|
||||||
|
$ref: "./typename.yaml#/components/schemas/TypeName" # TweetUnavailable
|
||||||
|
reason:
|
||||||
|
type: string
|
||||||
|
|
||||||
Tweet:
|
Tweet:
|
||||||
required:
|
required:
|
||||||
- "rest_id"
|
- "rest_id"
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,15 @@ if __name__ == "__main__":
|
||||||
task_callback(file, thread=False)
|
task_callback(file, thread=False)
|
||||||
logger.info(f"Match rate: {rate}")
|
logger.info(f"Match rate: {rate}")
|
||||||
|
|
||||||
|
for file in glob.glob("other/**/*.json", recursive=True):
|
||||||
|
with open(file, "r") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
|
try:
|
||||||
|
_ = pt.Errors.from_dict(data)
|
||||||
|
except Exception as e:
|
||||||
|
error_dump(e)
|
||||||
|
|
||||||
api_conf = pt.Configuration(
|
api_conf = pt.Configuration(
|
||||||
api_key={
|
api_key={
|
||||||
"ClientLanguage": "en",
|
"ClientLanguage": "en",
|
||||||
|
|
@ -345,6 +354,13 @@ if __name__ == "__main__":
|
||||||
res = pt.TweetApi(api_client).get_tweet_detail_with_http_info(**kwargs)
|
res = pt.TweetApi(api_client).get_tweet_detail_with_http_info(**kwargs)
|
||||||
data = res.data.to_dict()
|
data = res.data.to_dict()
|
||||||
|
|
||||||
|
save_cache(
|
||||||
|
{
|
||||||
|
"raw": res.raw_data.decode("utf-8"),
|
||||||
|
"type": res.data.__class__.__name__,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
rate = match_rate(
|
rate = match_rate(
|
||||||
data,
|
data,
|
||||||
json.loads(res.raw_data),
|
json.loads(res.raw_data),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue