"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSecuritySchemes=exports.getSecurityScheme=exports.getSecurityRequirement=void 0;const utils_1=require("../utils");function getSecurityRequirement({requirement:e,parser:t}){const r=t.definition.components&&t.definition.components.securitySchemes||{};return{schemes:Object.keys(e||{}).map((i=>{const c=t.deref(r[i]).resolved,n=e[i]||[];if(c)return Object.assign(Object.assign({},c),{id:i,sectionId:i,scopes:n})})).filter(Boolean)}}function getSecurityScheme(e,t,r){if(!(null==e?void 0:e.deref))return{};const{resolved:i}=e.deref(r),c=t,n=i.type,s=(0,utils_1.getValueFromMdParsedExtension)(i,"description")||"";let o,u,m,p={};switch(i.type){case"apiKey":o={name:i.name,in:i.in};break;case"http":u={scheme:i.scheme,bearerFormat:i.bearerFormat};break;case"openIdConnect":m={connectUrl:i.openIdConnectUrl};break;case"oauth2":p=i.flows}return{id:t,sectionId:c,type:n,description:s,apiKey:o,http:u,flows:p,openId:m}}function getSecuritySchemes({parser:e}){var t,r;if(!e)return[];const i=(null===(r=null===(t=e.definition)||void 0===t?void 0:t.components)||void 0===r?void 0:r.securitySchemes)||{};return Object.keys(i).map((t=>getSecurityScheme(e,t,i[t])))}exports.getSecurityRequirement=getSecurityRequirement,exports.getSecurityScheme=getSecurityScheme,exports.getSecuritySchemes=getSecuritySchemes;
//# sourceMappingURL=security.js.map