How to use the @tsed/common.ParamTypes.FORM_DATA function in @tsed/common

To help you get started, we’ve selected a few @tsed/common 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 / multipartfiles / src / decorators / multipartFile.ts View on Github external
.set("multipartAdded", true);

        if (!added) {
          // middleware is added
          UseBefore(MultipartFileMiddleware)(target, propertyKey, descriptorOf(target, propertyKey));
        }

        if (name === undefined) {
          store.merge(MultipartFileMiddleware, {
            options,
            any: true
          });

          UseFilter(multiple ? MultipartFilesFilter : MultipartFileFilter, {
            useConverter: false,
            paramType: ParamTypes.FORM_DATA
          })(target, propertyKey, index);
        } else {
          const expression = multiple ? (name as string) : name + ".0";

          store.merge(MultipartFileMiddleware, {
            fields: [
              {
                name,
                maxCount
              }
            ],
            options
          });

          UseFilter(MultipartFilesFilter, {
            expression,
github TypedProject / ts-express-decorators / src / multipartfiles / decorators / multipartFile.ts View on Github external
// middleware is added
          UseBefore(MultipartFileMiddleware)(target, propertyKey, descriptorOf(target, propertyKey));
        }

        if (name === undefined) {
          store.merge(MultipartFileMiddleware, {
            options,
            any: true
          });

          ParamRegistry.useFilter(multiple ? MultipartFilesFilter : MultipartFileFilter, {
            propertyKey,
            parameterIndex,
            target,
            useConverter: false,
            paramType: ParamTypes.FORM_DATA
          });
        } else {
          const expression = multiple ? (name as string) : name + ".0";

          store.merge(MultipartFileMiddleware, {
            fields: [
              {
                name,
                maxCount
              }
            ],
            options
          });

          ParamRegistry.useFilter(MultipartFilesFilter, {
            expression,
github TypedProject / ts-express-decorators / test / units / multipartfiles / decorators / multipartFile.spec.ts View on Github external
it("should set params metadata", () => {
        this.useFilterStub.should.have.been.calledWithExactly(MultipartFilesFilter, {
          expression: "file1.0",
          propertyKey: "test",
          parameterIndex: 0,
          target: Test.prototype,
          useConverter: false,
          paramType: ParamTypes.FORM_DATA
        });
      });
    });
github TypedProject / ts-express-decorators / test / units / multipartfiles / decorators / multipartFile.spec.ts View on Github external
it("should set params metadata", () => {
          this.useFilterStub.should.have.been.calledWithExactly(MultipartFileFilter, {
            propertyKey: "test",
            parameterIndex: 0,
            target: Test.prototype,
            useConverter: false,
            paramType: ParamTypes.FORM_DATA
          });
        });
      });
github TypedProject / ts-express-decorators / test / units / swagger / class / OpenApiParamsBuilder.spec.ts View on Github external
before(() => {
        const storeGet = (key: string) => {
          if (key === "hidden") {
            return false;
          }

          return {test: "test"};
        };

        this.params = [
          {
            paramType: ParamTypes.FORM_DATA,
            expression: "expression1",
            required: true,
            store: {
              get: storeGet
            }
          },
          {
            paramType: ParamTypes.BODY,
            expression: "expression1",
            required: true,
            store: {
              get: storeGet
            }
          }
        ];
github TypedProject / ts-express-decorators / test / units / swagger / class / OpenApiParamsBuilder.spec.ts View on Github external
return {test: "test"};
      };

      this.params = [
        {
          paramType: ParamTypes.BODY,
          expression: "expression1",
          required: true,
          type: String,
          store: {
            get: storeGet
          }
        },
        {
          paramType: ParamTypes.FORM_DATA,
          expression: "expression2.0",
          required: false,
          store: {
            get: storeGet
          }
        }
      ];

      this.getParamsStub = Sinon.stub(ParamRegistry, "getParams").returns(this.params);

      this.builder = new OpenApiParamsBuilder(Ctrl, "test");

      this.result = this.builder.getInFormData();
    });
    after(() => {
github TypedProject / ts-express-decorators / packages / swagger / src / class / OpenApiParamsBuilder.ts View on Github external
.map(param => {
        const name = ((param.expression as string) || "").replace(".0", "");
        const type = param.paramType === ParamTypes.FORM_DATA ? "file" : swaggerType(param.paramType);

        return Object.assign({}, param.store.get("baseParameter"), {
          in: "formData",
          name,
          required: param.required,
          type
        });
      });
  }
github TypedProject / ts-express-decorators / packages / swagger / src / class / OpenApiParamsBuilder.ts View on Github external
this.injectedParams = ParamRegistry.getParams(target, methodClassName).filter(param => {
      if (param.paramType === ParamTypes.BODY) {
        this.hasBody = true;
      }

      if (param.paramType === ParamTypes.FORM_DATA) {
        this.hasFormData = true;
      }

      return !param.store.get("hidden");
    });