From c8f976753f7ac8ea04f1cdee611cd4b6c4ae84d3 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Sat, 29 Feb 2020 13:09:52 +0100 Subject: [PATCH] Check for @odata.type and @type in authorization annotations (#67) --- lib/csdl2openapi.js | 5 +++-- package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/csdl2openapi.js b/lib/csdl2openapi.js index 9bad0675..377cffcb 100644 --- a/lib/csdl2openapi.js +++ b/lib/csdl2openapi.js @@ -1929,7 +1929,8 @@ module.exports.csdl2openapi = function ( const scheme = {}; const flow = {}; if (auth.Description) scheme.description = auth.Description; - const type = auth['@type'].substr(auth['@type'].lastIndexOf('.') + 1); + const qualifiedType = auth['@type'] || auth['@odata.type'] + const type = qualifiedType.substr(qualifiedType.lastIndexOf('.') + 1); let unknown = false switch (type) { case 'ApiKey': @@ -1978,7 +1979,7 @@ module.exports.csdl2openapi = function ( break; default: unknown = true - console.warn('Unknown Authorization type ' + auth['@type']); + console.warn('Unknown Authorization type ' + qualifiedType); } if (!unknown) schemes[auth.Name] = scheme; }); diff --git a/package.json b/package.json index b14067d3..01c26eea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "odata-openapi", - "version": "0.4.0", + "version": "0.4.1", "description": "Convert OData CSDL XML or CSDL JSON to OpenAPI", "homepage": "https://github.com/oasis-tcs/odata-openapi/blob/master/lib/README.md", "bugs": "https://github.com/oasis-tcs/odata-openapi/issues",