ng-openapi-gen
Version:
An OpenAPI 3.0 and 3.1 codegen for Angular 16+
51 lines • 2.79 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Globals = void 0;
const gen_utils_1 = require("./gen-utils");
/**
* Stores the global variables used on generation
*/
class Globals {
constructor(options) {
this.configurationClass = options.configuration ?? 'ApiConfiguration';
this.configurationFile = (0, gen_utils_1.fileName)(this.configurationClass);
this.configurationParams = `${this.configurationClass}Params`;
this.baseServiceClass = options.baseService ?? 'BaseService';
this.baseServiceFile = (0, gen_utils_1.fileName)(this.baseServiceClass);
if (options.apiService === false) {
this.apiServiceClass = undefined;
}
else {
this.apiServiceClass = options.apiService === true ? '' : options.apiService;
if ((this.apiServiceClass ?? '') === '') {
this.apiServiceClass = 'Api';
}
if (typeof this.apiServiceClass === 'string') {
// Angular's best practices demands xxx.service.ts, not xxx-service.ts
this.apiServiceFile = (0, gen_utils_1.fileName)(this.apiServiceClass).replace(/\-service$/, '.service');
}
}
this.promises = options.promises ?? true;
this.requestBuilderClass = options.requestBuilder ?? 'RequestBuilder';
this.requestBuilderFile = (0, gen_utils_1.fileName)(this.requestBuilderClass);
this.responseClass = options.response ?? 'StrictHttpResponse';
this.responseFile = (0, gen_utils_1.fileName)(this.responseClass);
if (options.module !== false && options.module !== '') {
this.moduleClass = options.module === true || options.module === undefined ? 'ApiModule' : options.module;
// Angular's best practices demands xxx.module.ts, not xxx-module.ts
this.moduleFile = (0, gen_utils_1.fileName)(this.moduleClass).replace(/\-module$/, '.module');
}
if (options.serviceIndex !== false && options.serviceIndex !== '') {
this.serviceIndexFile = options.serviceIndex === true || options.serviceIndex === undefined ? 'services' : options.serviceIndex;
}
if (options.modelIndex !== false && options.modelIndex !== '') {
this.modelIndexFile = options.modelIndex === true || options.modelIndex === undefined ? 'models' : options.modelIndex;
}
if (options.functionIndex !== false && options.functionIndex !== '') {
this.functionIndexFile = options.functionIndex === true || options.functionIndex === undefined ? 'functions' : options.functionIndex;
}
this.generateServices = !!options.services;
}
}
exports.Globals = Globals;
//# sourceMappingURL=globals.js.map