Skip to content

Generated code does not seem to compile #6

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

Closed
inthegarage opened this issue Apr 10, 2017 · 6 comments
Closed

Generated code does not seem to compile #6

inthegarage opened this issue Apr 10, 2017 · 6 comments

Comments

@inthegarage
Copy link

In the generated file DefaultAPI.ts I am getting quite a few errors regarding the instance of check. For instance:

    if (contentPackageId !== undefined) {
        if(contentPackageId instanceof Date) {

Is generated for my yaml file and yet when an attempt to compile this I get:

[INFO] ERROR in src/app/api/DefaultApi.ts (353,16): The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
[INFO] src/app/api/DefaultApi.ts (354,79): Property 'd' does not exist on type 'string & Date'.

There are several of these in the file generally regarding a passed in parameter and a check around that parameter to see if it is of type 'Date'.
I have seen the following issue reported here, but that seems very out of date and resolved a long time ago:

microsoft/TypeScript#2775

As this is generated code, how can I effect the operation and get the code to compile successfully?
I'm using swagger-codegen 2.2.2 maven plugin, with setting:
typescript-angular2

@briosheje
Copy link

briosheje commented Apr 24, 2017

I've got the same issue here: in each api file I can't get over these errors (all seems to be related to instanceof left-hand side being "string" instead of "any" and the next few lines with the .d . All seems to be related with Date checks anyway).

Not sure whether it's related to the typescript version itself (using ~2.1.5 here) or if it's a bug.

Also, there is another compile issue with the Filter parameter, passed as: filter[]?: Array<string> when it should be: filter?: Array<string> instead.

@inthegarage
Copy link
Author

I was using ~2.0.0 which actually equates to 2.0.10. I just tried with the latest 2.2.2 and no change, so this seems to be a bug not a version issue.
As a functional request, I'd prefer that the app.api and other items was optional and we can choose to just have the models or the models and support software. I'm having to delete half of them at the moment as they are not required in the way we are doing things.

@inthegarage
Copy link
Author

inthegarage commented May 2, 2017

@briosheje Looks like this is fixed in master and if you do a build of 2.2.3-SNAPSHOT, you get completely different api code. Not ideal, but a better work around.

@inthegarage
Copy link
Author

@briosheje Yeah confirmed, it's fixed in Master.

@MTyson
Copy link

MTyson commented Jun 9, 2017

Errors everywhere. Beware. Time sink.

This plugin is completely broken and does not work at all.

@inthegarage
Copy link
Author

inthegarage commented Sep 14, 2017

This is now fixed as 2.2.3 of the swagger plugin is released. If you have this issue, move to 2.2.3.
Closing issue.

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

No branches or pull requests

3 participants