Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public cloneApi(): string {
let sourceDoc: Document = this.document;
CommandFactory.createChangeTitleCommand(this.title).execute(sourceDoc);
if (sourceDoc.getDocumentType() == DocumentType.openapi2 && this.convertApi) {
console.info("[CopyPageComponent] Converting API from 2.0 to 3.0.x!");
sourceDoc = this.transformDocument(sourceDoc as Oas20Document);
}
let sourceJs: any = Library.writeNode(sourceDoc);
let sourceStr: string = JSON.stringify(sourceJs);
let sourceB64: string = Base64.encode(sourceStr);
return sourceB64;
}
refreshUrl: null,
scopes: []
},
authorizationCode: {
enabled: false,
authorizationUrl: null,
tokenUrl: null,
refreshUrl: null,
scopes: []
}
}
} as SecurityScheme30Data;
}
if (scheme) {
if (this.context.ownerDocument().getDocumentType() == DocumentType.openapi2) {
let scheme20: Oas20SecurityScheme = scheme as Oas20SecurityScheme;
this.model.schemeName = scheme20.getSchemeName();
this.model.description = scheme20.description;
this.model.type = scheme20.type;
this.model.in = scheme20.in;
this.model.name = scheme20.name;
this.model.flow = scheme20.flow;
this.model.authorizationUrl = scheme20.authorizationUrl;
this.model.tokenUrl = scheme20.tokenUrl;
this.model.scopes = this.toScopesArray(scheme20.scopes);
} else {
let scheme30: Oas30SecurityScheme = scheme as Oas30SecurityScheme;
let model: SecurityScheme30Data = this.model as SecurityScheme30Data;
model.schemeName = scheme30.getSchemeName();
model.description = scheme30.description;
model.type = scheme30.type;
public is2x(): boolean {
return this.context.ownerDocument().getDocumentType() == DocumentType.openapi2;
}
public is2xDocument(): boolean {
return this.operation.ownerDocument().getDocumentType() == DocumentType.openapi2;
}
public isSwagger2(): boolean {
return this.document.getDocumentType() === DocumentType.openapi2;
}
getFilterValue(filter: ValidationRuleFilter): string {
if (filter.type === "severity") {
if (filter.value === ValidationProblemSeverity.ignore) {
return "None";
} else if (filter.value === ValidationProblemSeverity.low) {
return "Low";
} else if (filter.value === ValidationProblemSeverity.medium) {
return "Medium";
} else if (filter.value === ValidationProblemSeverity.high) {
return "High";
}
}
if (filter.type === "version") {
if (filter.value == DocumentType.openapi2) {
return "OpenAPI 2.0";
}
if (filter.value == DocumentType.openapi3) {
return "OpenAPI 3.x";
}
if (filter.value == DocumentType.asyncapi2) {
return "AsyncAPI 2.x";
}
}
return filter.value;
}
responseDefRefPrefix(): string {
let prefix: string = "#/components/responses/";
if (this.response.ownerDocument().getDocumentType() === DocumentType.openapi2) {
prefix = "#/responses/";
}
return prefix;
}