in src/models/api.ts [110:170]
constructor(contract?: ApiContract) {
if (!contract) {
return;
}
this.id = contract.id;
this.name = contract.id;
this.displayName = contract.name;
this.versionedDisplayName = contract.name;
this.protocols = contract.protocols;
this.description = contract.description;
this.path = contract.path;
this.versionedPath = this.path;
this.apiVersion = contract.apiVersion;
this.apiRevision = contract.apiRevision;
this.subscriptionKeyParameterNames = contract.subscriptionKeyParameterNames;
this.type = contract.type;
this.authenticationSettings = contract.authenticationSettings;
this.subscriptionRequired = contract.subscriptionRequired;
this.contact = contract.contact;
this.license = contract.license;
this.termsOfServiceUrl = contract.termsOfServiceUrl;
if (contract.type) {
switch (contract.type) {
case TypeOfApi.soap:
this.typeName = "SOAP";
break;
case TypeOfApi.webSocket:
this.typeName = "WebSocket";
break;
case TypeOfApi.graphQL:
this.typeName = "GraphQL";
break;
default:
this.typeName = "REST";
break;
}
} else {
this.typeName = "REST";
}
if (contract.apiVersionSet) {
const nestedVersionSet = contract.apiVersionSet;
const versionSet = new VersionSet(contract.apiVersionSetId);
versionSet.name = nestedVersionSet.name;
versionSet.description = nestedVersionSet.description;
versionSet.versionHeaderName = nestedVersionSet.versionHeaderName;
versionSet.versionQueryName = nestedVersionSet.versionQueryName;
versionSet.versioningScheme = nestedVersionSet.versioningScheme;
this.apiVersionSet = versionSet;
if (nestedVersionSet && this.apiVersion && versionSet.versioningScheme === "Segment") {
this.versionedPath = `${this.path}/${this.apiVersion}`;
}
if (this.apiVersion) {
this.versionedDisplayName = `${this.displayName} - ${this.apiVersion}`;
}
}
}