<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://forge.etsi.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.3"
          urlbase="https://forge.etsi.org/bugzilla/"
          
          maintainer="Helpdesk@etsi.org"
>

    <bug>
          <bug_id>86</bug_id>
          
          <creation_ts>2018-12-05 22:53:41 +0100</creation_ts>
          <short_desc>OperationIDs with . in it preclude server generation</short_desc>
          <delta_ts>2019-01-21 16:28:51 +0100</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>MEC</product>
          <component>GS 011</component>
          <version>Release 1</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Normal</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michele Carignani">michele.carignani</reporter>
          <assigned_to name="walter FEATHERSTONE">walter.featherstone</assigned_to>
          <cc>fabio.giust</cc>
    
    <cc>michele.carignani</cc>
    
    <cc>sebastian.mueller</cc>
    
    <cc>walter.featherstone</cc>
          
          <cf_doc_version>Any</cf_doc_version>
          <cf_oas_category>---</cf_oas_category>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>153</commentid>
    <comment_count>0</comment_count>
    <who name="Michele Carignani">michele.carignani</who>
    <bug_when>2018-12-05 22:53:41 +0100</bug_when>
    <thetext>The operationIds defined in the Swagger file will prevent the generation of a server stub, because the dot is a reserved token in several languages.

Please change them to include an underscore (_) instead of the dot (.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>154</commentid>
    <comment_count>1</comment_count>
    <who name="walter FEATHERSTONE">walter.featherstone</who>
    <bug_when>2018-12-06 01:24:24 +0100</bug_when>
    <thetext>For clarification, which languages? I&apos;ve not come across this problem before.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155</commentid>
    <comment_count>2</comment_count>
    <who name="Michele Carignani">michele.carignani</who>
    <bug_when>2018-12-06 14:20:23 +0100</bug_when>
    <thetext>I have seen the issue with the nodejs-server generation (Javascript). The tool uses the operationId as the name of a function called to handle the request.

When the program is loaded, functions with dots inside will trigger a syntax error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>171</commentid>
    <comment_count>3</comment_count>
    <who name="walter FEATHERSTONE">walter.featherstone</who>
    <bug_when>2019-01-11 17:31:05 +0100</bug_when>
    <thetext>I&apos;m still struggling with this one, since I&apos;ve not has this problem with nodejs. 

https://editor.swagger.io/ -&gt; Generate Server -&gt; nodejs-server works fine, e.g. DefaultService.js:

exports.applicationsDnsRule.GET = function(appInstanceId,dnsRuleId) {
  return new Promise(function(resolve, reject) {
    var examples = {};
    examples[&apos;application/json&apos;] = {
  &quot;DnsRule&quot; : {
    &quot;dnsRuleId&quot; : &quot;DnsRule1&quot;,
    &quot;domainName&quot; : &quot;www.example.com&quot;,
    &quot;ipAddressType&quot; : &quot;IP_V4&quot;,
    &quot;ipAddress&quot; : &quot;146.241.7.3&quot;,
    &quot;ttl&quot; : 300,
    &quot;state&quot; : &quot;ACTIVE&quot;
  }
};
    if (Object.keys(examples).length &gt; 0) {
      resolve(examples[Object.keys(examples)[0]]);
    } else {
      resolve();
    }
  });
}

And Default.js:
module.exports.applicationsDnsRule.GET = function applicationsDnsRule.GET (req, res, next) {
  var appInstanceId = req.swagger.params[&apos;appInstanceId&apos;].value;
  var dnsRuleId = req.swagger.params[&apos;dnsRuleId&apos;].value;
  Default.applicationsDnsRule.GET(appInstanceId,dnsRuleId)
    .then(function (response) {
      utils.writeJson(res, response);
    })
    .catch(function (response) {
      utils.writeJson(res, response);
    });
};</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>183</commentid>
    <comment_count>4</comment_count>
    <who name="Michele Carignani">michele.carignani</who>
    <bug_when>2019-01-18 15:51:48 +0100</bug_when>
    <thetext>Hi!

I will need to check again. Maybe the different result is given by different versions of Javascript/Node.

Cannot try at the moment, will update asap.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>184</commentid>
    <comment_count>5</comment_count>
    <who name="Fabio Giust">fabio.giust</who>
    <bug_when>2019-01-21 13:59:42 +0100</bug_when>
    <thetext>Hi,

I tried to reproduce the error Michele talks about.

I generated the Mp1/MEC 011 node.js server, using the swagger editor tool.

system: Linux host-vm01 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
npm --version 6.4.1

here is the error message i got


&gt; mp1-api@1.1.1 start /home/fgiust/MEC_APIs/MEC_011
&gt; node index.js

Error initializing middleware
/home/fgiust/MEC_APIs/MEC_011/controllers/Default.js:6
module.exports.applicationsDnsRule.GET = function applicationsDnsRule.GET (req, res, next) {
                                                                     ^

SyntaxError: Unexpected token .
    at new Script (vm.js:79:7)
    at createScript (vm.js:251:10)
    at Object.runInThisContext (vm.js:303:10)
    at Module._compile (internal/modules/cjs/loader.js:656:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mp1-api@1.1.1 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mp1-api@1.1.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/fgiust/.npm/_logs/2019-01-21T12_50_23_857Z-debug.log</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185</commentid>
    <comment_count>6</comment_count>
    <who name="Fabio Giust">fabio.giust</who>
    <bug_when>2019-01-21 14:07:44 +0100</bug_when>
    <thetext>Hi,

i tried to fix the bug as Michele suggested, by replacing the .GET into _GET (for all verbs in facts), and obtained a partial solution.
the server starts, but with an unexpected behavior: 

request:
GET http://127.0.0.1:8081/exampleAPI/mp1/v1/timing/timing_caps
response:
rror: Cannot resolve the configured swagger-router handler: Default_TimingCaps_GET
    at swaggerRouter (/home/fgiust/MEC_APIs/MEC_011_fix/node_modules/swagger-tools/middleware/swagger-router.js:414:18)
    at call (/home/fgiust/MEC_APIs/MEC_011_fix/node_modules/connect/index.js:239:7)
    at next (/home/fgiust/MEC_APIs/MEC_011_fix/node_modules/connect/index.js:183:5)
    at /home/fgiust/MEC_APIs/MEC_011_fix/node_modules/swagger-tools/middleware/swagger-validator.js:352:30
    at /home/fgiust/MEC_APIs/MEC_011_fix/node_modules/async/lib/async.js:52:16
    at /home/fgiust/MEC_APIs/MEC_011_fix/node_modules/async/lib/async.js:361:13
    at /home/fgiust/MEC_APIs/MEC_011_fix/node_modules/async/lib/async.js:52:16
    at async.forEachOf.async.eachOf (/home/fgiust/MEC_APIs/MEC_011_fix/node_modules/async/lib/async.js:236:30)
    at _asyncMap (/home/fgiust/MEC_APIs/MEC_011_fix/node_modules/async/lib/async.js:355:9)
    at Object.map (/home/fgiust/MEC_APIs/MEC_011_fix/node_modules/async/lib/async.js:337:20)

apparently there is problem now in routing the request to the right handler</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>186</commentid>
    <comment_count>7</comment_count>
    <who name="walter FEATHERSTONE">walter.featherstone</who>
    <bug_when>2019-01-21 15:59:39 +0100</bug_when>
    <thetext>I wasn&apos;t having problems previously, but now I agree. Ok, I&apos;ll accept the merge request.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>187</commentid>
    <comment_count>8</comment_count>
    <who name="walter FEATHERSTONE">walter.featherstone</who>
    <bug_when>2019-01-21 16:28:51 +0100</bug_when>
    <thetext>Proposed changes accepted</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>