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

Regression(?) of @tsoaModel deduplication since #1498 #1650

Open
2 of 4 tasks
E-gy opened this issue Jul 8, 2024 · 2 comments
Open
2 of 4 tasks

Regression(?) of @tsoaModel deduplication since #1498 #1650

E-gy opened this issue Jul 8, 2024 · 2 comments
Labels
bug good first issue This issue could be an easy PR for those looking to help contribute help wanted

Comments

@E-gy
Copy link

E-gy commented Jul 8, 2024

As far as i can tell seemingly since #1498, @tsoaModel has lost its meaning for dealing with duplicated model names, when using the js-doc annotation for respecifying types imported from libraries for TSOA.

This seems to be a follow-up on #1516.

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

The following code has a duplicated type - ULID. Once imported from ulidx, and once declared in an purpose-built file and annotated with @tsoaModel. Since we have one and exactly one of the types with identical names with the annotation, we expect TSOA to use that annotation.

MinimalController.ts:

import { Controller, Get, Route} from '@tsoa/runtime';
import { ULID } from './apitypes.js';
import { RealGeo } from './RealGeo';

@Route('garbage/garbage/garbage')
export class GartbageController extends Controller {
	@Get('{stud}')
	public async getStuff(stud: ULID): Promise<RealGeo[]> {
		return [];
	}
}

apitypes.ts:

/**
 * ULID Crockford's base32 string representation.
 * See [ULID Spec](https://github.com/ulid/spec).
 * @pattern [0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}
 * @example "01ARZ3NDEKTSV4RRFFQ69G5FAV"
 * @tsoaModel
 */
export type ULID = string;

RealGeo.ts:

import { ULID } from 'ulidx';

export interface RealGeo {
    id: ULID;
}

Last version where this works correctly* (or at least generates any routes): 6.0.0-rc.2

As-in the routes are still built. It is worth noting that in 6.0.0-rc.2, building the spec with above code does not actually produce any specification what-so-ever, but the command does not print any errors either and simply exits successfully.

Current Behavior

Now take that same code to the latest version of TSOA, and run a route generation to get a following error:

Generate routes error.
 GenerateMetadataError: Found 2 different model definitions for model ULID: orig: [{"fileName":"/workspaces/ReducedExample/node_modules/ulidx/dist/types.d.ts","pos":32}], act: [{"fileName":"/workspaces/ReducedExample/src/api/apitypes.ts","pos":0}] 
 in 'GartbageController.getStuff'

First version where it breaks: 6.0.0-rc.5

Note that still once again running the spec generation produces no spec, and nothing on the error output. This and the above are identical to the current version (6.3.1).

Context (Environment)

Version of NodeJS: v22.4.0 (Reproduced in a node:22.4-alpine3.19 devcontainer)

  • Confirm you were using yarn not npm: all tested versions of TSOA taken from npm.
@WoH WoH added bug help wanted good first issue This issue could be an easy PR for those looking to help contribute labels Jul 17, 2024
@pgerlich
Copy link

pgerlich commented Jul 29, 2024

We're also seeing this issue. Hoping to get some eyes on it? @lukeautry

@ttrreevvoorr
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue This issue could be an easy PR for those looking to help contribute help wanted
Projects
None yet
Development

No branches or pull requests

4 participants