elasticio / odata2openapi

OData to OpenAPI Converter
https://www.elastic.io
MIT License
33 stars 23 forks source link

Issue when implementing odata2openapi #17

Closed Coopyrightdmin closed 7 years ago

Coopyrightdmin commented 7 years ago

I try to use this module to transform odata metadata.xml file into json. As per documentation, I have implemented the following code:

const o2oapi = require('odata2openapi');

function_B (content) {
  o2oapi.parse(content)  
    .then(entitySets => convert(entitySets))
    .then(swagger => console.log(JSON.stringify(swagger, null, 2)))
    .catch(error => console.error(error));
 }

The content variable is a metadata xml stream that I can display on console. I can also see the following result when logging the parse method of function B:

Promise {
 { entitySets: [ [Object], [Object] ],
   version: '1.0',
   complexTypes: [],
   singletons: [],
   actions: [],
   functions: [],
   defaultNamespace: 'ZEXAMPLE_SRV',
   entityTypes: [ [Object], [Object] ] } }

Unfortunately, I am not able to get the final result 'from swagger' to pass to another function C.

function_A (content, x, y, z){
  function_C (function_B (content), x, y ,z);
}

I have tried to adapt my code without any success. Could you please advice?

Attached my metadata file. metadata.zip

Coopyrightdmin commented 7 years ago

Issue has been solved as described there: https://stackoverflow.com/questions/47576230/promise-issue-with-odata-file-parsing. I was quite surprised having to send EntitySets.entitySets to the convert method.