| @@ -12,6 +12,10 @@ import { HttpMethod, ServerInfo, type ExtractionResult } from "./types"; · 11 unmodified lines |
| 12 | 12 | |
| 13 | 13 | /** Scopes declared by a flow: `{ scopeName: description }` */ |
| 14 | 14 | const OAuth2Scopes = Schema.Record(Schema.String, Schema.String); |
| 15 | +const SecuritySchemeType = Schema.Literals(["http", "apiKey", "oauth2", "openIdConnect"]); |
| 16 | +type SecuritySchemeType = typeof SecuritySchemeType.Type; |
| 17 | + |
| 18 | +const decodeSecuritySchemeType = Schema.decodeUnknownOption(SecuritySchemeType); |
| 15 | 19 | |
| 16 | 20 | export class OAuth2AuthorizationCodeFlow extends Schema.Class<OAuth2AuthorizationCodeFlow>( |
| 17 | 21 | "OAuth2AuthorizationCodeFlow", |
| @@ -43,7 +47,7 @@ export class SecurityScheme extends Schema.Class<SecurityScheme>("SecurityScheme · 25 unmodified lines |
| 43 | 47 | /** Key name in components.securitySchemes (e.g. "api_token") */ |
| 44 | 48 | name: Schema.String, |
| 45 | 49 | /** OpenAPI security scheme type */ |
| 46 | | − type: Schema.Literals(["http", "apiKey", "oauth2", "openIdConnect"]), |
| 50 | + type: SecuritySchemeType, |
| 47 | 51 | /** For type: "http" — e.g. "bearer", "basic" */ |
| 48 | 52 | scheme: Schema.OptionFromOptional(Schema.String), |
| 49 | 53 | /** For type: "http" with scheme "bearer" — e.g. "JWT" */ |
| @@ -215,19 +219,20 @@ const extractSecuritySchemes = ( · 165 unmodified lines |
| 215 | 219 | if (!resolved || typeof resolved !== "object") return []; |
| 216 | 220 | const scheme = resolved; |
| 217 | 221 | |
| 218 | | − const type = scheme.type as string; |
| 219 | | − if (!["http", "apiKey", "oauth2", "openIdConnect"].includes(type)) return []; |
| 222 | + const type = decodeSecuritySchemeType(scheme.type); |
| 223 | + if (Option.isNone(type)) return []; |
| 224 | + const schemeType = type.value; |
| 220 | 225 | |
| 221 | 226 | return [ |
| 222 | 227 | new SecurityScheme({ |
| 223 | 228 | name, |
| 224 | | − type: type as "http" | "apiKey" | "oauth2" | "openIdConnect", |
| 229 | + type: schemeType, |
| 225 | 230 | scheme: Option.fromNullishOr(scheme.scheme as string | undefined), |
| 226 | 231 | bearerFormat: Option.fromNullishOr(scheme.bearerFormat as string | undefined), |
| 227 | 232 | in: Option.fromNullishOr(scheme.in as "header" | "query" | "cookie" | undefined), |
| 228 | 233 | headerName: Option.fromNullishOr(scheme.name as string | undefined), |
| 229 | 234 | description: Option.fromNullishOr(scheme.description as string | undefined), |
| 230 | | − flows: type === "oauth2" ? extractFlows(scheme.flows) : Option.none(), |
| 235 | + flows: schemeType === "oauth2" ? extractFlows(scheme.flows) : Option.none(), |
| 231 | 236 | openIdConnectUrl: Option.fromNullishOr( |
| 232 | 237 | scheme.openIdConnectUrl as string | undefined, |
| 233 | 238 | ), |