diff --git a/examples/annotations.openapi3.json b/examples/annotations.openapi3.json index 5765bee4..3385beb0 100644 --- a/examples/annotations.openapi3.json +++ b/examples/annotations.openapi3.json @@ -1505,6 +1505,7 @@ "/ReadListOnlySet": { "get": { "summary": "Supports only read-list", + "description": "Does not support any query options", "tags": [ "ReadListOnlySet" ], @@ -1535,8 +1536,7 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Does not support any query options" + } } }, "/AllSingleton": { @@ -1878,6 +1878,7 @@ "/ReadOnlySingleton": { "get": { "summary": "Supports only read", + "description": "Does not support `$select` and `$expand`", "tags": [ "ReadOnlySingleton" ], @@ -1896,8 +1897,7 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Does not support `$select` and `$expand`" + } } }, "/ReadOnlySingleton/AllOne": { @@ -2454,6 +2454,7 @@ "/TwoReadOnlySet": { "get": { "summary": "Supports read-list", + "description": "Does not support any query options", "tags": [ "TwoReadOnlySet" ], @@ -2484,8 +2485,7 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Does not support any query options" + } } }, "/TwoReadOnlySet(One={One},Two={Two})": { diff --git a/examples/containment.openapi3.json b/examples/containment.openapi3.json index eda0e635..419ef638 100644 --- a/examples/containment.openapi3.json +++ b/examples/containment.openapi3.json @@ -3166,6 +3166,7 @@ ], "get": { "summary": "Supports only read-list", + "description": "Does not support any system query options", "tags": [ "TheWhole" ], @@ -3200,8 +3201,7 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Does not support any system query options" + } } }, "/TheWhole/Many({index_1})/ManyReadByKeyOnly(One={One_2},Two={Two_2})": { @@ -3239,6 +3239,7 @@ ], "get": { "summary": "Supports only read-by-key", + "description": "Does not support `$select`", "tags": [ "TheWhole" ], @@ -3257,8 +3258,7 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Does not support `$select`" + } } }, "/Folders": { diff --git a/examples/descriptions.openapi3.json b/examples/descriptions.openapi3.json index 693fe681..189f0149 100644 --- a/examples/descriptions.openapi3.json +++ b/examples/descriptions.openapi3.json @@ -32,6 +32,7 @@ "/entities": { "get": { "summary": "Query Entity Set - Description", + "description": "Query Entity Set - LongDescription", "tags": [ "entities" ], @@ -151,11 +152,11 @@ } } } - }, - "description": "Query Entity Set - LongDescription" + } }, "post": { "summary": "Create Entity - Description", + "description": "Create Entity - LongDescription", "tags": [ "entities" ], @@ -191,8 +192,7 @@ } } } - }, - "description": "Create Entity - LongDescription" + } } }, "/entities('{id}')": { @@ -211,6 +211,7 @@ ], "get": { "summary": "Read Entity by Key - Description", + "description": "Read Entity by Key - LongDescription", "tags": [ "entities" ], @@ -271,11 +272,11 @@ } } } - }, - "description": "Read Entity by Key - LongDescription" + } }, "patch": { "summary": "Update Entity - Description", + "description": "Update Entity - LongDescription", "tags": [ "entities" ], @@ -304,11 +305,11 @@ } } } - }, - "description": "Update Entity - LongDescription" + } }, "delete": { "summary": "Delete Entity - Description", + "description": "Delete Entity - LongDescription", "tags": [ "entities" ], @@ -326,13 +327,13 @@ } } } - }, - "description": "Delete Entity - LongDescription" + } } }, "/entities('{id}')/self.action": { "post": { "summary": "Action Bound Overload Ext - Description", + "description": "Action Bound Overload - LongDescription", "tags": [ "entities" ], @@ -361,7 +362,6 @@ } } }, - "description": "Action Bound Overload - LongDescription", "parameters": [ { "description": "Property - Description \nProperty - LongDescription", @@ -398,6 +398,7 @@ "/entities('{id}')/self.function": { "get": { "summary": "Function Bound Overload Ext - Description", + "description": "Function Bound Overload - LongDescription", "tags": [ "entities" ], @@ -450,8 +451,7 @@ } } } - }, - "description": "Function Bound Overload - LongDescription" + } } }, "/entities('{id}')/contained": { @@ -470,6 +470,7 @@ ], "get": { "summary": "Query Contained - Description", + "description": "Query Contained - LongDescription", "tags": [ "entities" ], @@ -561,11 +562,11 @@ } } } - }, - "description": "Query Contained - LongDescription" + } }, "post": { "summary": "Create Contained - Description", + "description": "Create Contained - LongDescription", "tags": [ "entities" ], @@ -601,8 +602,7 @@ } } } - }, - "description": "Create Contained - LongDescription" + } } }, "/entities('{id}')/contained('{id_1}')": { @@ -631,6 +631,7 @@ ], "get": { "summary": "Read Contained by Key - Description", + "description": "Read Contained by Key - LongDescription", "tags": [ "entities" ], @@ -673,11 +674,11 @@ } } } - }, - "description": "Read Contained by Key - LongDescription" + } }, "patch": { "summary": "Update Contained - Description", + "description": "Update Contained - LongDescription", "tags": [ "entities" ], @@ -706,11 +707,11 @@ } } } - }, - "description": "Update Contained - LongDescription" + } }, "delete": { "summary": "Delete Contained - Description", + "description": "Delete Contained - LongDescription", "tags": [ "entities" ], @@ -728,13 +729,13 @@ } } } - }, - "description": "Delete Contained - LongDescription" + } } }, "/entities('{id}')/contained('{id_1}')/self.action": { "post": { "summary": "Action Bound Overload Ext subEntity - Description", + "description": "Action Bound Overload subEntity - LongDescription", "tags": [ "entities" ], @@ -753,7 +754,6 @@ } } }, - "description": "Action Bound Overload subEntity - LongDescription", "parameters": [ { "description": "Property - Description \nProperty - LongDescription", @@ -813,6 +813,7 @@ ], "get": { "summary": "Query Related - Description", + "description": "Query Related - LongDescription", "tags": [ "entities", "entities_ext" @@ -916,11 +917,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Query Related - LongDescription" + } }, "post": { "summary": "Create Related - Description", + "description": "Create Related - LongDescription", "tags": [ "entities", "entities_ext" @@ -950,13 +951,13 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Create Related - LongDescription" + } } }, "/entities_ext": { "get": { "summary": "Query Entity Set Ext - Description", + "description": "Query Entity Set Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1059,11 +1060,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Query Entity Set Ext - LongDescription" + } }, "post": { "summary": "Create Entity Ext - Description", + "description": "Create Entity Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1092,8 +1093,7 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Create Entity Ext - LongDescription" + } } }, "/entities_ext('{id}')": { @@ -1112,6 +1112,7 @@ ], "get": { "summary": "Read Entity Set by Key Ext - Description", + "description": "Read Entity Set by Key Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1165,11 +1166,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Read Entity Set by Key Ext - LongDescription" + } }, "patch": { "summary": "Update Entity Ext - Description", + "description": "Update Entity Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1191,11 +1192,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Update Entity Ext - LongDescription" + } }, "delete": { "summary": "Delete Entity Ext - Description", + "description": "Delete Entity Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1206,13 +1207,13 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Delete Entity Ext - LongDescription" + } } }, "/entities_ext('{id}')/self.action": { "post": { "summary": "Action Bound Overload Ext - Description", + "description": "Action Bound Overload - LongDescription", "tags": [ "entities_ext" ], @@ -1241,7 +1242,6 @@ } } }, - "description": "Action Bound Overload - LongDescription", "parameters": [ { "description": "Property - Description \nProperty - LongDescription", @@ -1278,6 +1278,7 @@ "/entities_ext('{id}')/self.function": { "get": { "summary": "Function Bound Overload Ext - Description", + "description": "Function Bound Overload - LongDescription", "tags": [ "entities_ext" ], @@ -1330,8 +1331,7 @@ } } } - }, - "description": "Function Bound Overload - LongDescription" + } } }, "/entities_ext('{id}')/contained": { @@ -1350,6 +1350,7 @@ ], "get": { "summary": "Query Contained Ext - Description", + "description": "Query Contained Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1434,11 +1435,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Query Contained Ext - LongDescription" + } }, "post": { "summary": "Create Contained Ext - Description", + "description": "Create Contained Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1467,8 +1468,7 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Create Contained Ext - LongDescription" + } } }, "/entities_ext('{id}')/contained('{id_1}')": { @@ -1497,6 +1497,7 @@ ], "get": { "summary": "Read Contained by Key Ext - Description", + "description": "Read Contained by Key Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1532,11 +1533,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Read Contained by Key Ext - LongDescription" + } }, "patch": { "summary": "Update Contained Ext - Description", + "description": "Update Contained Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1558,11 +1559,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Update Contained Ext - LongDescription" + } }, "delete": { "summary": "Delete Contained Ext - Description", + "description": "Delete Contained Ext - LongDescription", "tags": [ "entities_ext" ], @@ -1573,13 +1574,13 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Delete Contained Ext - LongDescription" + } } }, "/entities_ext('{id}')/contained('{id_1}')/self.action": { "post": { "summary": "Action Bound Overload Ext subEntity - Description", + "description": "Action Bound Overload subEntity - LongDescription", "tags": [ "entities_ext" ], @@ -1598,7 +1599,6 @@ } } }, - "description": "Action Bound Overload subEntity - LongDescription", "parameters": [ { "description": "Property - Description \nProperty - LongDescription", @@ -1658,6 +1658,7 @@ ], "get": { "summary": "Query Related Ext - Description", + "description": "Query Related Ext - LongDescription", "tags": [ "entities_ext", "entities" @@ -1761,11 +1762,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Query Related Ext - LongDescription" + } }, "post": { "summary": "Create Related Ext - Description", + "description": "Create Related Ext - LongDescription", "tags": [ "entities_ext", "entities" @@ -1795,13 +1796,13 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Create Related Ext - LongDescription" + } } }, "/single": { "get": { "summary": "Read Singleton - Description", + "description": "Read Singleton - LongDescription", "tags": [ "single" ], @@ -1862,11 +1863,11 @@ } } } - }, - "description": "Read Singleton - LongDescription" + } }, "patch": { "summary": "Update Singleton - Description", + "description": "Update Singleton - LongDescription", "tags": [ "single" ], @@ -1895,11 +1896,11 @@ } } } - }, - "description": "Update Singleton - LongDescription" + } }, "delete": { "summary": "Delete Singleton - Description", + "description": "Delete Singleton - LongDescription", "tags": [ "single" ], @@ -1917,13 +1918,13 @@ } } } - }, - "description": "Delete Singleton - LongDescription" + } } }, "/single/self.action": { "post": { "summary": "Action Bound Overload Ext - Description", + "description": "Action Bound Overload - LongDescription", "tags": [ "single" ], @@ -1952,7 +1953,6 @@ } } }, - "description": "Action Bound Overload - LongDescription", "requestBody": { "description": "Action parameters", "content": { @@ -1976,6 +1976,7 @@ "/single/self.function": { "get": { "summary": "Function Bound Overload Ext - Description", + "description": "Function Bound Overload - LongDescription", "tags": [ "single" ], @@ -2017,13 +2018,13 @@ } } } - }, - "description": "Function Bound Overload - LongDescription" + } } }, "/single/contained": { "get": { "summary": "Singleton Query Contained - Description", + "description": "Singleton Query Contained - LongDescription", "tags": [ "single" ], @@ -2108,11 +2109,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Query Contained - LongDescription" + } }, "post": { "summary": "Singleton Create Contained - Description", + "description": "Singleton Create Contained - LongDescription", "tags": [ "single" ], @@ -2141,8 +2142,7 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Create Contained - LongDescription" + } } }, "/single/contained('{id_1}')": { @@ -2160,6 +2160,7 @@ ], "get": { "summary": "Singleton Read Contained by Key - Description", + "description": "Singleton Read Contained by Key - LongDescription", "tags": [ "single" ], @@ -2195,11 +2196,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Read Contained by Key - LongDescription" + } }, "patch": { "summary": "Singleton Update Contained - Description", + "description": "Singleton Update Contained - LongDescription", "tags": [ "single" ], @@ -2221,11 +2222,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Update Contained - LongDescription" + } }, "delete": { "summary": "Singleton Delete Contained - Description", + "description": "Singleton Delete Contained - LongDescription", "tags": [ "single" ], @@ -2236,13 +2237,13 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Delete Contained - LongDescription" + } } }, "/single/contained('{id_1}')/self.action": { "post": { "summary": "Action Bound Overload Ext subEntity - Description", + "description": "Action Bound Overload subEntity - LongDescription", "tags": [ "single" ], @@ -2261,7 +2262,6 @@ } } }, - "description": "Action Bound Overload subEntity - LongDescription", "parameters": [ { "description": "key: id", @@ -2297,6 +2297,7 @@ "/single/related": { "get": { "summary": "Singleton Query Related - Description", + "description": "Singleton Query Related - LongDescription", "tags": [ "single", "entities_ext" @@ -2400,11 +2401,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Query Related - LongDescription" + } }, "post": { "summary": "Singleton Create Related - Description", + "description": "Singleton Create Related - LongDescription", "tags": [ "single", "entities_ext" @@ -2434,13 +2435,13 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Create Related - LongDescription" + } } }, "/single_ext": { "get": { "summary": "Read Singleton Ext - Description", + "description": "Read Singleton Ext - LongDescription", "tags": [ "single_ext" ], @@ -2494,11 +2495,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Read Singleton Ext - LongDescription" + } }, "patch": { "summary": "Update Singleton Ext - Description", + "description": "Update Singleton Ext - LongDescription", "tags": [ "single_ext" ], @@ -2520,13 +2521,13 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Update Singleton Ext - LongDescription" + } } }, "/single_ext/self.action": { "post": { "summary": "Action Bound Overload Ext - Description", + "description": "Action Bound Overload - LongDescription", "tags": [ "single_ext" ], @@ -2555,7 +2556,6 @@ } } }, - "description": "Action Bound Overload - LongDescription", "requestBody": { "description": "Action parameters", "content": { @@ -2579,6 +2579,7 @@ "/single_ext/self.function": { "get": { "summary": "Function Bound Overload Ext - Description", + "description": "Function Bound Overload - LongDescription", "tags": [ "single_ext" ], @@ -2620,13 +2621,13 @@ } } } - }, - "description": "Function Bound Overload - LongDescription" + } } }, "/single_ext/contained": { "get": { "summary": "Singleton Query Contained Ext - Description", + "description": "Singleton Query Contained Ext - LongDescription", "tags": [ "single_ext" ], @@ -2711,11 +2712,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Query Contained Ext - LongDescription" + } }, "post": { "summary": "Singleton Create Contained Ext - Description", + "description": "Singleton Create Contained Ext - LongDescription", "tags": [ "single_ext" ], @@ -2744,8 +2745,7 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Create Contained Ext - LongDescription" + } } }, "/single_ext/contained('{id_1}')": { @@ -2763,6 +2763,7 @@ ], "get": { "summary": "Singleton Read Contained by Key Ext - Description", + "description": "Singleton Read Contained by Key Ext - LongDescription", "tags": [ "single_ext" ], @@ -2798,11 +2799,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Read Contained by Key Ext - LongDescription" + } }, "patch": { "summary": "Singleton Update Contained Ext - Description", + "description": "Singleton Update Contained Ext - LongDescription", "tags": [ "single_ext" ], @@ -2824,11 +2825,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Update Contained Ext - LongDescription" + } }, "delete": { "summary": "Singleton Delete Contained Ext - Description", + "description": "Singleton Delete Contained Ext - LongDescription", "tags": [ "single_ext" ], @@ -2839,13 +2840,13 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Delete Contained Ext - LongDescription" + } } }, "/single_ext/contained('{id_1}')/self.action": { "post": { "summary": "Action Bound Overload Ext subEntity - Description", + "description": "Action Bound Overload subEntity - LongDescription", "tags": [ "single_ext" ], @@ -2864,7 +2865,6 @@ } } }, - "description": "Action Bound Overload subEntity - LongDescription", "parameters": [ { "description": "key: id", @@ -2900,6 +2900,7 @@ "/single_ext/related": { "get": { "summary": "Singleton Query Related Ext - Description", + "description": "Singleton Query Related Ext - LongDescription", "tags": [ "single_ext", "entities" @@ -3003,11 +3004,11 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Query Related Ext - LongDescription" + } }, "post": { "summary": "Singleton Create Related Ext - Description", + "description": "Singleton Create Related Ext - LongDescription", "tags": [ "single_ext", "entities" @@ -3037,13 +3038,13 @@ "4XX": { "$ref": "#/components/responses/error" } - }, - "description": "Singleton Create Related Ext - LongDescription" + } } }, "/actionimport": { "post": { "summary": "Action Import - Description", + "description": "Action Import - LongDescription", "tags": [ "Service Operations" ], @@ -3072,7 +3073,6 @@ } } }, - "description": "Action Import - LongDescription", "requestBody": { "description": "Action parameters", "content": { @@ -3096,6 +3096,7 @@ "/actionimport_ext": { "post": { "summary": "Action Import Ext - Description", + "description": "Action Import Ext - LongDescription", "tags": [ "Service Operations" ], @@ -3124,7 +3125,6 @@ } } }, - "description": "Action Import Ext - LongDescription", "requestBody": { "description": "Action parameters", "content": { @@ -3148,6 +3148,7 @@ "/actionimport_no_descriptions": { "post": { "summary": "Action Unbound Overload - Description", + "description": "Action Unbound Overload Ext - LongDescription", "tags": [ "Service Operations" ], @@ -3176,7 +3177,6 @@ } } }, - "description": "Action Unbound Overload Ext - LongDescription", "requestBody": { "description": "Action parameters", "content": { @@ -3200,6 +3200,7 @@ "/functionimport": { "get": { "summary": "Function Import - Description", + "description": "Function Import - LongDescription", "tags": [ "Service Operations" ], @@ -3241,13 +3242,13 @@ } } } - }, - "description": "Function Import - LongDescription" + } } }, "/functionimport_ext": { "get": { "summary": "Function Import Ext - Description", + "description": "Function Import Ext - LongDescription", "tags": [ "Service Operations" ], @@ -3289,13 +3290,13 @@ } } } - }, - "description": "Function Import Ext - LongDescription" + } } }, "/functionimport_no_descriptions": { "get": { "summary": "Function Unbound Overload - Description", + "description": "Function Unbound Overload Ext - LongDescription", "tags": [ "Service Operations" ], @@ -3337,8 +3338,7 @@ } } } - }, - "description": "Function Unbound Overload Ext - LongDescription" + } } }, "/$batch": { @@ -3383,6 +3383,7 @@ "schemas": { "descriptions.entity": { "title": "Entity Type - Description", + "description": "Entity Type - LongDescription", "type": "object", "properties": { "id": { @@ -3410,11 +3411,11 @@ "related@count": { "$ref": "#/components/schemas/count" } - }, - "description": "Entity Type - LongDescription" + } }, "descriptions.entity-create": { "title": "Entity Type - Description (for create)", + "description": "Entity Type - LongDescription", "type": "object", "properties": { "id": { @@ -3433,13 +3434,12 @@ }, "required": [ "id" - ], - "description": "Entity Type - LongDescription" + ] }, "descriptions.entity-update": { "title": "Entity Type - Description (for update)", - "type": "object", - "description": "Entity Type - LongDescription" + "description": "Entity Type - LongDescription", + "type": "object" }, "descriptions.subEntity": { "title": "subEntity", diff --git a/lib/csdl2openapi.js b/lib/csdl2openapi.js index 0b70aec1..dd435075 100644 --- a/lib/csdl2openapi.js +++ b/lib/csdl2openapi.js @@ -527,6 +527,9 @@ module.exports.csdl2openapi = function ( summary: insertRestrictions.Description || "Add new entity to " + (level > 0 ? "related " : "") + name, + ...(insertRestrictions.LongDescription && { + description: insertRestrictions.LongDescription, + }), tags: [sourceName], requestBody: { description: @@ -548,8 +551,6 @@ module.exports.csdl2openapi = function ( insertRestrictions.ErrorResponses, ), }; - if (insertRestrictions.LongDescription) - pathItem.post.description = insertRestrictions.LongDescription; if (targetName && sourceName != targetName) pathItem.post.tags.push(targetName); @@ -614,6 +615,9 @@ module.exports.csdl2openapi = function ( (level > 0 ? "related " : "") + name + (byKey ? " by key" : ""), + ...(descriptions.LongDescription && { + description: descriptions.LongDescription, + }), tags: [sourceName], parameters: [], responses: response( @@ -640,8 +644,6 @@ module.exports.csdl2openapi = function ( "?$deltatoken=opaque server-generated token for fetching the delta", }; } - if (descriptions.LongDescription) - operation.description = descriptions.LongDescription; if (target && sourceName != targetName) operation.tags.push(targetName); customParameters( @@ -1129,6 +1131,9 @@ module.exports.csdl2openapi = function ( (element.$Collection ? "entity in " : "") + (level > 0 ? "related " : "") + name, + ...(updateRestrictions.LongDescription && { + description: updateRestrictions.LongDescription, + }), tags: [sourceName], requestBody: { description: @@ -1154,8 +1159,6 @@ module.exports.csdl2openapi = function ( updateRestrictions.ErrorResponses, ), }; - if (updateRestrictions.LongDescription) - operation.description = updateRestrictions.LongDescription; customParameters(operation, updateRestrictions); pathItem[updateRestrictions.UpdateMethod?.toLowerCase() || "patch"] = @@ -1195,6 +1198,9 @@ module.exports.csdl2openapi = function ( (element.$Collection ? "entity from " : "") + (level > 0 ? "related " : "") + name, + ...(deleteRestrictions.LongDescription && { + description: deleteRestrictions.LongDescription, + }), tags: [sourceName], responses: response( 204, @@ -1203,8 +1209,6 @@ module.exports.csdl2openapi = function ( deleteRestrictions.ErrorResponses, ), }; - if (deleteRestrictions.LongDescription) - pathItem.delete.description = deleteRestrictions.LongDescription; customParameters(pathItem.delete, deleteRestrictions); } @@ -1572,12 +1576,16 @@ module.exports.csdl2openapi = function ( ) { const name = actionName.indexOf(".") === -1 ? actionName : nameParts(actionName).name; + const description = + actionImport[voc.Core.LongDescription] || + overload[voc.Core.LongDescription]; const pathItem = { post: { summary: actionImport[voc.Core.Description] || overload[voc.Core.Description] || "Invoke action " + name, + ...(description && { description }), tags: [sourceName || "Service Operations"], responses: overload.$ReturnType ? response( @@ -1594,10 +1602,7 @@ module.exports.csdl2openapi = function ( ), }, }; - const description = - actionImport[voc.Core.LongDescription] || - overload[voc.Core.LongDescription]; - if (description) pathItem.post.description = description; + if (prefixParameters.length > 0) pathItem.post.parameters = [...prefixParameters]; let parameters = overload.$Parameter || []; @@ -1750,12 +1755,16 @@ module.exports.csdl2openapi = function ( const pathParameters = implicitAliases ? "" : "(" + pathSegments.join(",") + ")"; + const description = + functionImport[voc.Core.LongDescription] || + overload[voc.Core.LongDescription]; const pathItem = { get: { summary: functionImport[voc.Core.Description] || overload[voc.Core.Description] || "Invoke function " + name, + ...(description && { description }), tags: [sourceName || "Service Operations"], parameters: prefixParameters.concat(params), responses: response( @@ -1766,10 +1775,6 @@ module.exports.csdl2openapi = function ( ), }, }; - const description = - functionImport[voc.Core.LongDescription] || - overload[voc.Core.LongDescription]; - if (description) pathItem.get.description = description; customParameters( pathItem.get, @@ -2242,8 +2247,10 @@ module.exports.csdl2openapi = function ( } } + const description = type[voc.Core.LongDescription]; schemas[schemaName] = { title: (type[voc.Core.Description] || name) + TITLE_SUFFIX[suffix], + ...(description && { description }), type: "object", }; @@ -2253,11 +2260,6 @@ module.exports.csdl2openapi = function ( if (suffix === SUFFIX.create && required.length > 0) schemas[schemaName].required = required; - const description = type[voc.Core.LongDescription]; - if (description) { - schemas[schemaName].description = description; - } - //TODO: make method const derivedTypes = model.derivedTypes[baseName]; if (derivedTypes) { diff --git a/package-lock.json b/package-lock.json index 5bbdb356..ad8cab92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "odata-openapi", - "version": "0.25.2", + "version": "0.25.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "odata-openapi", - "version": "0.25.2", + "version": "0.25.3", "license": "SEE LICENSE IN LICENSE.md", "dependencies": { "@discoveryjs/json-ext": "^0.5.7", diff --git a/package.json b/package.json index 3e043bd2..7035650d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "odata-openapi", - "version": "0.25.2", + "version": "0.25.3", "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",