export class AmfSecurity {
    static readSecurityList(security) {
        const result = [];
        if (!Array.isArray(security) || !security.length) {
            return result;
        }
        security.forEach((item) => {
            const { schemes } = item;
            if (!Array.isArray(schemes)) {
                return;
            }
            result.push(AmfSecurity.readSecurityListItem(item));
        });
        return result;
    }
    static readSecurityListItem(item) {
        const { schemes } = item;
        const result = {
            types: [],
            labels: [],
            security: item,
        };
        schemes.forEach((scheme) => {
            const { name, scheme: settings } = scheme;
            if (name === 'null') {
                // RAML allows to define a "null" scheme. This means that the authorization
                // for this endpoint is optional.
                result.types.push(undefined);
                result.labels.push('No authorization');
                return;
            }
            const label = name || settings && settings.name;
            const type = settings && settings.type;
            result.types.push(type);
            result.labels.push(label);
        });
        return result;
    }
}
//# sourceMappingURL=AmfSecurity.js.map