Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (const c in content) {
debug(' processing response code %s with content-type %', code, c);
processSchemaExtensions(spec, content[c].schema);
}
}
debug(' processing parameters for method %s', op);
let params = MetadataInspector.getAllParameterMetadata(
OAI3Keys.PARAMETERS_KEY,
constructor.prototype,
op,
);
debug(' parameters for method %s: %j', op, params);
if (params != null) {
params = DecoratorFactory.cloneDeep(params);
/**
* If a controller method uses dependency injection, the parameters
* might be sparse. For example,
* ```ts
* class MyController {
* greet(
* @inject('prefix') prefix: string,
* @param.query.string('name) name: string) {
* return `${prefix}`, ${name}`;
* }
* ```
*/
operationSpec.parameters = params
.filter(p => p != null)
.map(p => {
// Per OpenAPI spec, `required` must be `true` for path parameters
constructor,
);
if (spec) {
debug(' using class-level spec defined via @api()', spec);
spec = DecoratorFactory.cloneDeep(spec);
} else {
spec = {paths: {}};
}
let endpoints =
MetadataInspector.getAllMethodMetadata(
OAI3Keys.METHODS_KEY,
constructor.prototype,
) ?? {};
endpoints = DecoratorFactory.cloneDeep(endpoints);
for (const op in endpoints) {
debug(' processing method %s', op);
const endpoint = endpoints[op];
const verb = endpoint.verb!;
const path = endpoint.path!;
let endpointName = '';
/* istanbul ignore if */
if (debug.enabled) {
const className = constructor.name || '';
const fullMethodName = `${className}.${op}`;
endpointName = `${fullMethodName} (${verb} ${path})`;
}
const defaultResponse = {
function resolveControllerSpec(constructor: Function): ControllerSpec {
debug(`Retrieving OpenAPI specification for controller ${constructor.name}`);
let spec = MetadataInspector.getClassMetadata(
OAI3Keys.CLASS_KEY,
constructor,
);
if (spec) {
debug(' using class-level spec defined via @api()', spec);
spec = DecoratorFactory.cloneDeep(spec);
} else {
spec = {paths: {}};
}
let endpoints =
MetadataInspector.getAllMethodMetadata(
OAI3Keys.METHODS_KEY,
constructor.prototype,
) ?? {};
endpoints = DecoratorFactory.cloneDeep(endpoints);
for (const op in endpoints) {
debug(' processing method %s', op);
const endpoint = endpoints[op];
const verb = endpoint.verb!;