redoc/lib/components/SecurityDefinitions/security-definitions.ts

51 lines
1.3 KiB
TypeScript
Raw Normal View History

2016-10-23 20:18:42 +03:00
'use strict';
2016-12-02 12:59:29 +03:00
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
2016-10-23 20:18:42 +03:00
import { SpecManager, BaseComponent } from '../base';
2016-10-31 11:15:04 +03:00
import { ComponentParser } from '../../services/component-parser.service';
2016-10-30 18:58:06 +03:00
const AUTH_TYPES = {
'oauth2': 'OAuth2',
'apiKey': 'API Key',
'basic': 'Basic Authorization'
}
2016-10-23 20:18:42 +03:00
@Component({
selector: 'security-definitions',
styleUrls: ['./security-definitions.css'],
templateUrl: './security-definitions.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class SecurityDefinitions extends BaseComponent implements OnInit {
info: any = {};
specUrl: String;
2016-10-30 18:58:06 +03:00
defs: any[];
static insertTagIntoDescription(md:string) {
if (ComponentParser.contains(md, 'security-definitions')) return md;
if (/^#\s?Authentication\s*$/mi.test(md)) return md;
return md + '\n# Authentication \n' + ComponentParser.build('security-definitions');
}
2016-10-23 20:18:42 +03:00
constructor(specMgr:SpecManager) {
super(specMgr);
}
init() {
2016-10-30 18:58:06 +03:00
this.componentSchema = this.componentSchema.securityDefinitions;
this.defs = Object.keys(this.componentSchema).map(name => {
let details = this.componentSchema[name];
details._displayType = AUTH_TYPES[details.type];
return {
name,
details
}
});
2016-10-23 20:18:42 +03:00
}
ngOnInit() {
this.preinit();
}
}