How to use the @tsed/core.deepExtends function in @tsed/core

To help you get started, we’ve selected a few @tsed/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TypedProject / ts-express-decorators / packages / swagger / src / services / SwaggerService.ts View on Github external
endpoint.pathsMethods.forEach(pathMethod => {
        /* istanbul ignore else */
        if (!!pathMethod.method) {
          const builder = new OpenApiEndpointBuilder(endpoint, endpointUrl, pathMethod, getOperationId).build();

          deepExtends(paths, builder.paths);
          deepExtends(definitions, builder.definitions);
        }
      });
    });
github TypedProject / ts-express-decorators / packages / swagger / services / SwaggerService.ts View on Github external
const doc = conf.doc;
    const tags: Tag[] = [];

    const getOperationId = this.createOperationIdFormatter(conf);

    this.controllerService.routes.forEach(({provider, route}) => {
      const hidden = provider.store.get("hidden");
      const docs = provider.store.get("docs") || [];

      if ((!doc && !hidden) || (doc && docs.indexOf(doc) > -1)) {
        this.buildRoutes(paths, definitions, provider, route, getOperationId);
        tags.push(this.buildTags(provider));
      }
    });

    return deepExtends(
      defaultSpec,
      {
        tags,
        paths,
        definitions
      },
      getReducers()
    );
  }
github TypedProject / ts-express-decorators / src / swagger / class / OpenApiEndpointBuilder.ts View on Github external
private createResponses(builderResponses: OpenApiResponses): OpenApiResponses {
    const responses = this.endpoint.get("responses") || {};

    deepExtends(responses, builderResponses);

    responses[this.endpoint.get("statusCode") || "200"] = {description: "Success"};

    Object.keys(responses).forEach(code => {
      responses[code] = this.createResponse(code, responses[code]);
    });

    return responses;
  }
github TypedProject / ts-express-decorators / packages / swagger / src / class / OpenApiParamsBuilder.ts View on Github external
protected createSchemaFromBodyParam(param: ParamMetadata): Schema {
    let builder;

    const {currentProperty, schema} = this.createSchemaFromExpression(param);

    if (param.isClass) {
      builder = new OpenApiModelSchemaBuilder(param.type);
      builder.build();

      deepExtends(this._definitions, builder.definitions);
      deepExtends(this._responses, builder.responses);
    }

    Object.assign(currentProperty, super.createSchema(param));

    return schema;
  }
github TypedProject / ts-express-decorators / src / mongoose / utils / schemaOptions.ts View on Github external
export function schemaOptions(target: any, options?: MongooseModelOptions) {
  const store = Store.from(target);
  if (options) {
    options = deepExtends(store.get(MONGOOSE_SCHEMA_OPTIONS) || {}, options);
    store.set(MONGOOSE_SCHEMA_OPTIONS, options);
  }

  return store.get(MONGOOSE_SCHEMA_OPTIONS);
}
github TypedProject / ts-express-decorators / packages / swagger / class / OpenApiEndpointBuilder.ts View on Github external
private createResponses(builderResponses: OpenApiResponses): OpenApiResponses {
    const responses = this.endpoint.get("responses") || {};

    deepExtends(responses, builderResponses);

    responses[this.endpoint.get("statusCode") || "200"] = {description: "Success"};

    Object.keys(responses).forEach(code => {
      responses[code] = this.createResponse(code, responses[code]);
    });

    return responses;
  }
github TypedProject / ts-express-decorators / packages / swagger / class / OpenApiEndpointBuilder.ts View on Github external
private createOperation(builder: OpenApiParamsBuilder): Operation {
    const operationId = this.getOperationId(this.endpoint.targetName, this.endpoint.methodClassName);
    const security = this.endpoint.get("security");
    const produces = this.endpoint.get("produces");
    const consumes = this.endpoint.get("consumes");

    return deepExtends(
      {
        operationId,
        tags: [this.getTagName()],
        parameters: builder.parameters.length ? builder.parameters : undefined,
        consumes,
        responses: this.createResponses(builder.responses),
        security,
        produces
      },
      this.endpoint.get("operation") || {}
    );
  }
github TypedProject / ts-express-decorators / packages / swagger / src / class / OpenApiParamsBuilder.ts View on Github external
this._definitions[model] = params.reduce((acc: any, param) => {
      deepExtends(acc, this.createSchemaFromBodyParam(param));

      if (param.required) {
        this.addResponse400();
        required = true;
      }

      return acc;
    }, {});
github TypedProject / ts-express-decorators / packages / common / src / mvc / models / EndpointMetadata.ts View on Github external
if (+code === +expectedStatus) {
      const response = this.store.get("response");

      if (response) {
        headers = response.headers || headers;
        examples = response.examples || examples;
        description = response.description || description;

        this.type = response.type || this.type;
        this.collectionType = response.collectionType || this.collectionType;
      }
    }

    if (headers) {
      headers = deepExtends({}, headers);
      Object.keys(headers).forEach(key => {
        delete headers[key].value;
      });
    }

    return {
      headers,
      examples,
      description
    };
  }