Open CodeNinjai opened 7 years ago
I'll have a look on those issues.
I'll need some advice:
I changed behaviour in io/swagger/codegen/languages/JavascriptClientCodegen.java Line 488 toVarName(String name)
and added Logger output.
When generating swagger-codegen/samples/client/petstore/javascript-es6/src/model/List.js I can see that 123-List will be renamed to _123List:
[main] INFO io.swagger.codegen.languages.JavascriptClientCodegen - JL: toVarName() = 123-list
[main] INFO io.swagger.codegen.languages.JavascriptClientCodegen - JL _AFTER: toVarName() = _123_list
[main] INFO io.swagger.codegen.languages.JavascriptClientCodegen - JL _FINAL: toVarName() = _123List
[main] INFO io.swagger.codegen.languages.JavascriptClientCodegen - JL: toVarName() = 123-list
[main] INFO io.swagger.codegen.languages.JavascriptClientCodegen - JL _AFTER: toVarName() = _123_list
[main] INFO io.swagger.codegen.languages.JavascriptClientCodegen - JL _FINAL: toVarName() = _123List
[main] INFO io.swagger.codegen.languages.JavascriptClientCodegen - JL: toVarName() = 123-list
[main] INFO io.swagger.codegen.languages.JavascriptClientCodegen - JL _AFTER: toVarName() = _123_list
[main] INFO io.swagger.codegen.languages.JavascriptClientCodegen - JL _FINAL: toVarName() = _123List
But still the List.js will be generated like this:
export default class List {
/**
* Constructs a new <code>List</code>.
* @alias module:model/List
* @class
*/
constructor() {
}
/**
* Constructs a <code>List</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/List} obj Optional instance to populate.
* @return {module:model/List} The populated <code>List</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new List();
if (data.hasOwnProperty('123-list')) {
obj['123-list'] = ApiClient.convertToType(data['123-list'], 'String');
}
}
return obj;
}
/**
* @member {String} 123-list
*/
123-list = undefined;
}
Any ideas where to look?
For the enum gen the fix worked out straight forward.
@wing328 @frol
@CodeNinjai can you please submit a PR so that we can more easily review the code and clone locally to to repeat the issue?
@wing328 Sure, stand by.
@CodeNinjai when you've time, please file the PR so that we can help review the change.
Description
The Petstore integration tests for JS ES6 failed
Swagger-codegen version
Latest master.
Steps to reproduce
To repeat the issue for javascript-promise-es6
cd samples/client/petstore/javascript-promise-es6 npm install npm test
To repeat the issue for javascript-es6
cd samples/client/petstore/javascript-es6 npm install npm test