elasticio / odata2openapi

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

OData v4 functions + actions fail to convert #46

Open vobu opened 4 years ago

vobu commented 4 years ago

debug run showed the code from https://github.com/elasticio/odata2openapi/blob/bab243822101409304cc0cbd4af8baa7a0629519/src/convert.ts#L404 to be the culprit:

const service = await parse(v4metadata) // containing a v4 function
// service.functions[x].isBound is of type String, "true"/"false"
// so above linked code in convert() fails in `bindingParameterFromParameters`
// and no functions are included in the swagger spec
const swagger = await convert(
    service.entitySets,
    {
        functions: service.functions
    },
    service.version
)

if manually converted to the proper Boolean, convert(...) runs w/o an issue:

const service = await parse(v4metadata) // containing a v4 function
service.functions = service.functions.map(singleService => {
    let _service = singleService
    _service.isBound = singleService.isBound === "true" ? true : false
    _service.isComposable = singleService.isComposable === "true" ? true : false
    return _service
})
const swagger = await convert(
    service.entitySets,
    {
        functions: service.functions
    },
    service.version
)

env: