diff --git a/lib/compile/csdl2openapi.js b/lib/compile/csdl2openapi.js index e8955b3..9338a17 100644 --- a/lib/compile/csdl2openapi.js +++ b/lib/compile/csdl2openapi.js @@ -462,7 +462,7 @@ module.exports.csdl2openapi = function ( // if csdl.$Version is 4.01 then protocol is rest if it is less than 4.01 then protocol is odata const protocol = csdl.$Version <= '4.01' ? 'odata/v4' : 'rest'; // append /protocol/{$serviceName} to the URL - servers.forEach(server => { server.url = server.url + '/' + protocol + csdl.$EntityContainer }); + servers.forEach(server => { server.url = server.url + '/' + protocol + '/' + csdl.$EntityContainer }); } catch (err) { throw new Error(`The input server object is invalid.`); } diff --git a/test/lib/compile/openapi.test.js b/test/lib/compile/openapi.test.js index 3b0dd2a..5ae44f6 100644 --- a/test/lib/compile/openapi.test.js +++ b/test/lib/compile/openapi.test.js @@ -189,7 +189,7 @@ describe('OpenAPI export', () => { const serverObj = "[{\n \"url\": \"https://{customer1Id}.saas-app.com:{port}/v2\",\n \"variables\": {\n \"customer1Id\": \"demo\",\n \"description\": \"Customer1 ID assigned by the service provider\"\n }\n}, {\n \"url\": \"https://{customer2Id}.saas-app.com:{port}/v2\",\n \"variables\": {\n \"customer2Id\": \"demo\",\n \"description\": \"Customer2 ID assigned by the service provider\"\n }\n}]" const openapi = toOpenApi(csn, { 'openapi:servers': serverObj }); expect(openapi.servers).toBeTruthy(); - expect(openapi.servers[0].url).toMatch('https://{customer1Id}.saas-app.com:{port}/v2/odata/v4A.EntityContainer') + expect(openapi.servers[0].url).toMatch('https://{customer1Id}.saas-app.com:{port}/v2/odata/v4/A.EntityContainer') });