Skip to content

Commit c774902

Browse files
Copilotabraham
andcommitted
Fix OAuth2 security scheme validation by adding required flows property
Co-authored-by: abraham <[email protected]>
1 parent 3bb5633 commit c774902

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

dist/schema.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7813,7 +7813,26 @@
78137813
"securitySchemes": {
78147814
"OAuth2": {
78157815
"type": "oauth2",
7816-
"description": "OAuth 2.0 authentication"
7816+
"description": "OAuth 2.0 authentication",
7817+
"flows": {
7818+
"authorizationCode": {
7819+
"authorizationUrl": "https://mastodon.example/oauth/authorize",
7820+
"tokenUrl": "https://mastodon.example/oauth/token",
7821+
"scopes": {
7822+
"read": "Read access",
7823+
"write": "Write access",
7824+
"follow": "Follow/unfollow accounts",
7825+
"push": "Push notifications"
7826+
}
7827+
},
7828+
"clientCredentials": {
7829+
"tokenUrl": "https://mastodon.example/oauth/token",
7830+
"scopes": {
7831+
"read": "Read access",
7832+
"write": "Write access"
7833+
}
7834+
}
7835+
}
78177836
},
78187837
"BearerAuth": {
78197838
"type": "http",

src/generators/OpenAPIGenerator.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ class OpenAPIGenerator {
3535
OAuth2: {
3636
type: 'oauth2',
3737
description: 'OAuth 2.0 authentication',
38+
flows: {
39+
authorizationCode: {
40+
authorizationUrl: 'https://mastodon.example/oauth/authorize',
41+
tokenUrl: 'https://mastodon.example/oauth/token',
42+
scopes: {
43+
'read': 'Read access',
44+
'write': 'Write access',
45+
'follow': 'Follow/unfollow accounts',
46+
'push': 'Push notifications'
47+
}
48+
},
49+
clientCredentials: {
50+
tokenUrl: 'https://mastodon.example/oauth/token',
51+
scopes: {
52+
'read': 'Read access',
53+
'write': 'Write access'
54+
}
55+
}
56+
}
3857
},
3958
BearerAuth: {
4059
type: 'http',

src/interfaces/OpenAPISchema.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,24 @@ interface OpenAPIServer {
99
description?: string;
1010
}
1111

12+
interface OAuthFlow {
13+
authorizationUrl?: string;
14+
tokenUrl: string;
15+
refreshUrl?: string;
16+
scopes: Record<string, string>;
17+
}
18+
1219
interface OpenAPISecurityScheme {
1320
type: string;
1421
scheme?: string;
1522
bearerFormat?: string;
1623
description?: string;
24+
flows?: {
25+
implicit?: OAuthFlow;
26+
password?: OAuthFlow;
27+
clientCredentials?: OAuthFlow;
28+
authorizationCode?: OAuthFlow;
29+
};
1730
}
1831

1932
interface OpenAPIProperty {
@@ -95,6 +108,7 @@ export {
95108
OpenAPIInfo,
96109
OpenAPIServer,
97110
OpenAPISecurityScheme,
111+
OAuthFlow,
98112
OpenAPIProperty,
99113
OpenAPISchema,
100114
OpenAPIParameter,

0 commit comments

Comments
 (0)