typescript-rest-swagger
typescript-rest-swagger copied to clipboard
Unknown Type: IntersectionType
Hello, I've come across a very strange bug.
I have a class named Application
located in ./entities/Application.ts
, with the following definition
export class Application {
test: string;
}
I also have an application-controller
located in ./controllers/application-controller.ts
with the following contents:
import { POST, Path } from 'typescript-rest';
import { Application } from '../entities/Application';
/**
* This is a demo operation to show how to use typescript-rest library.
*/
@Path('/application')
export class ApplicationController {
/**
* Create an application
* @param application The Application entity that is to be created
* @return Promise<Application> The Application that has just been created
*/
@POST
async createApplication(application: Application): Promise<Application> {
// some async stuff
return application;
}
}
When I run npm run swagger
I get the following output:
There was a problem resolving type of 'Application'.
~/.../node_modules/typescript-rest-swagger/dist/metadata/methodGenerator.js:57
throw new Error("Error generate parameter method: '" + controllerId.text + "." + methodId.text + "' argument: " + parameterId.text + " " + e);
^
Error: Error generate parameter method: 'ApplicationController.createApplication' argument: application Error: Unknown type: IntersectionType
at ~/.../node_modules/typescript-rest-swagger/dist/metadata/methodGenerator.js:57:23
So the strange thing is, that if I change the name of the class Application
to something else (like Test
or Application1
) swagger runs fine.
This is very strange behaviour. Am I missing something?
Did you ever resolve this issue? I have the same issue.
Same problem
@mnishizawa Sorry for only replying now.
I had to workaround it by just renaming the class to a different, more specifice name...
I too faced this issue and fixed it with the solution suggested by @FrikkieSnyman
The reason I think, it worked, is because of the conflict with some existing class name.
In my case, I was exporting type User
and a class at another place with name User