lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.48k stars 498 forks source link

feat: support using custom multer instance in RegisterRoutes #1638

Closed midoelhawy closed 2 months ago

midoelhawy commented 3 months ago

All Submissions:

Closing issues

closes #1483

If this is a new feature submission:

Potential Problems With The Approach

Test plan

WoH commented 3 months ago

LGTM, but can you add a test in one of the setups maybe?

midoelhawy commented 3 months ago

Hi @WoH,

Makes sense. I've now added the automatic tests to avoid bad configuration errors:

cross-env NODE_ENV=tsoa_test mocha "./integration/express-server-custom-multer.spec.ts"

  Express Server With custom multer
    file upload With custom multer instance
      ✔ can post a file (71ms)
      ✔ can post a file without name
      ✔ cannot post a file with wrong attribute name
      ✔ can post multiple files with other form fields
      ✔ can post single file to multi file field
      ✔ can post multiple files with different field
      ✔ can post multiple files with different array fields
      ✔ can post mixed form data content with file and not providing optional file
      ✔ can post mixed form data content with file and provides optional file

  9 passing (239ms)

Thanks!

midoelhawy commented 3 months ago

Hi @WoH,

There were some ESLint errors outside my edited files, but they were resolved by merging master into my branch. Everything works now.

Can you run the tests again, please?

midoelhawy commented 3 months ago

Hi @WoH,

These errors are related to @typescript-eslint rules. They appeared only after cleaning the yarn.lock, so I think they're related to some new @typescript-eslint patch.

/home/work/tsoa/tsoa/packages/cli/src/metadataGeneration/transformer/referenceTransformer.ts
17:40 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion
21:35 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion

/home/work/tsoa/tsoa/packages/cli/src/metadataGeneration/typeResolver.ts
144:43 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion

/home/work/tsoa/tsoa/packages/cli/src/swagger/specGenerator2.ts
441:54 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion

/home/work/tsoa/tsoa/packages/cli/src/swagger/specGenerator3.ts
105:28 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion

I fixed them by ignoring the errors in some cases and by fixing the types when possible.

Can you run the Build action again, please?

WoH commented 2 months ago

LGTM, thanks for your contribution, and, tbh, your patience