ng-openapi-gen
Version:
An OpenAPI 3.0 and 3.1 codegen for Angular 16+
35 lines • 1.25 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parameter = void 0;
const gen_utils_1 = require("./gen-utils");
/**
* An operation parameter
*/
class Parameter {
constructor(spec, options, openApi) {
this.spec = spec;
this.specific = false;
this.name = spec.name;
this.var = (0, gen_utils_1.escapeId)(this.name);
this.varAccess = this.var.includes('\'') ? `[${this.var}]` : `.${this.var}`;
this.tsComments = (0, gen_utils_1.tsComments)(spec.description || '', 0, spec.deprecated);
this.in = (spec.in || 'query');
this.required = this.in === 'path' || spec.required || false;
this.type = (0, gen_utils_1.tsType)(spec.schema, options, openApi);
this.style = spec.style;
this.explode = spec.explode;
this.parameterOptions = this.createParameterOptions();
}
createParameterOptions() {
const options = {};
if (this.style) {
options.style = this.style;
}
if (!!this.explode === this.explode) {
options.explode = this.explode;
}
return JSON.stringify(options);
}
}
exports.Parameter = Parameter;
//# sourceMappingURL=parameter.js.map