wcandillon / swagger-js-codegen

A Swagger Codegen for typescript, nodejs & angularjs
Apache License 2.0
693 stars 286 forks source link

Get an error: Class properties must be methods #109

Closed langdonx closed 8 years ago

langdonx commented 8 years ago

test.js created from by pasting the Example from README.md:

$ node test.js
xxx\node_modules\swagger-js-codegen\lib\codegen.js:231
        throw new Error(error.reason + ' in ' + error.evidence + ' ('
              ^
Error: Class properties must be methods. Expected '(' but instead saw 'domain'. in     private domain: string; (E054)
    at xxx\node_modules\swagger-js-codegen\lib\codegen.js:231:23
    at Array.forEach (native)
    at getCode (xxx\node_modules\swagger-js-codegen\lib\codegen.js:229:21)
    at Object.exports.CodeGen.getTypescriptCode (xxx\node_modules\swagger-js-codegen\lib\codegen.js:247:16)
    at Object.<anonymous> (xxx\test.js:8:28)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

Not really sure where to start looking. The word "domain" isn't used in my spec file.

ETA: It looks like it fails linting... when I paste my spec into www.jshint.com, it doesn't produce any errors. Oh, I guess it lints what it generates. Ignoring the errors now to see what the result is.

langdonx commented 8 years ago

It's a bug in the template:

https://github.com/wcandillon/swagger-js-codegen/blob/master/templates/angular-class.mustache#L19

Line 31 and 39 need to use this.domain, assuming they're called correctly and have the correct this.

I'm guessing not a lot of folks use this for Angular 1? :wink:

pixelshaded commented 8 years ago

getting the same error when trying to generate typescript.

langdonx commented 8 years ago

FYI, @wcandillon that fix will still generate bad code for JavaScript angular-class.mustache has a bug in it (line 31+39 are referencing domain when they should be referencing this.domain.

wcandillon commented 8 years ago

@langdonx can you try in v1.3.3 to check if this is fixed?

langdonx commented 8 years ago

Ahh, it does look fixed, sorry! Threw me off that the change wasn't associated w/ the issue.

wcandillon commented 8 years ago

yes sorry it was my mistake

On Sun, Mar 27, 2016 at 6:01 PM, Langdon Oliver notifications@github.com wrote:

Ahh, it does look fixed, sorry! Threw me off that the change wasn't associated w/ the issue.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/wcandillon/swagger-js-codegen/issues/109#issuecomment-202095671