Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR 1498 break generating spec or routes #1516

Closed
2 of 4 tasks
eungkyu opened this issue Nov 26, 2023 · 4 comments
Closed
2 of 4 tasks

PR 1498 break generating spec or routes #1516

eungkyu opened this issue Nov 26, 2023 · 4 comments
Labels

Comments

@eungkyu
Copy link

eungkyu commented Nov 26, 2023

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

// src/TestController.ts
import { Body, Controller, Post, Route } from "tsoa";

type PostBody = {
  arg1: string;
};

@Route("test")
export class TestController extends Controller {
  @Post("/post")
  public post(@Body() body: PostBody) {
    return "ok";
  }
}
// src/Test2Controller.ts
import { Body, Controller, Post, Route } from "tsoa";

type PostBody = {
  arg2: string;
};

@Route("test2")
export class Test2Controller extends Controller {
  @Post("/post")
  public post(@Body() body: PostBody) {
    return "ok";
  }
}

If I use @tsoa/[email protected], tsoa spec runs without error.

sample: https://codesandbox.io/p/devbox/tsoa-project-forked-y3vmtd

Current Behavior

If I use @tsoa/[email protected], tsoa spec fails like followings

sample: https://codesandbox.io/p/devbox/tsoa-project-84ng5t

$ npx tsoa spec  
Generate swagger error.
 GenerateMetadataError: Found 2 different model definitions for model PostBody: orig: [{"fileName":"src/TestController.ts","pos":53}], act: [{"fileName":"src/Test2Controller.ts","pos":53}] 
 in 'Test2Controller.post'
    at /workspaces/workspace/node_modules/@tsoa/cli/dist/metadataGeneration/methodGenerator.js:104:23
    at Array.map (<anonymous>)
    at MethodGenerator.buildParameters (/workspaces/workspace/node_modules/@tsoa/cli/dist/metadataGeneration/methodGenerator.js:96:14)
    at MethodGenerator.Generate (/workspaces/workspace/node_modules/@tsoa/cli/dist/metadataGeneration/methodGenerator.js:66:33)
    at /workspaces/workspace/node_modules/@tsoa/cli/dist/metadataGeneration/controllerGenerator.js:46:41
    at Array.map (<anonymous>)
    at ControllerGenerator.buildMethods (/workspaces/workspace/node_modules/@tsoa/cli/dist/metadataGeneration/controllerGenerator.js:46:14)
    at ControllerGenerator.Generate (/workspaces/workspace/node_modules/@tsoa/cli/dist/metadataGeneration/controllerGenerator.js:35:27)
    at /workspaces/workspace/node_modules/@tsoa/cli/dist/metadataGeneration/metadataGenerator.js:210:41
    at Array.map (<anonymous>)

Possible Solution

I think #1498 caused the problem
because Found 2 different model definitions... error message is added at this PR.

Steps to Reproduce

in https://codesandbox.io/p/devbox/tsoa-project-84ng5t

run npx tsoa spec or npx tsoa routes

Context (Environment)

Version of the library: 6.0.0-rc.5
Version of NodeJS: 18

  • Confirm you were using yarn not npm: [ ]

Detailed Description

Please see codesandbox examples.

Breaking change?

@WoH
Copy link
Collaborator

WoH commented Nov 28, 2023

Did it uncover a bug or create a bug?
FWIW I think this was a bug before that is now fixed

@eungkyu
Copy link
Author

eungkyu commented Nov 29, 2023

Did it uncover a bug or create a bug? FWIW I think this was a bug before that is now fixed

type PostBody of TestController.ts and type PostBody of Test2Controller.ts are not the same type.
If it is not a bug, all of the non-exported internal type must have different name.
Is it right?

@WoH
Copy link
Collaborator

WoH commented Nov 30, 2023

All the exposed interfaces must have a different name.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants