Skip to content

Commit

Permalink
100% test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Jan 30, 2025
1 parent e1b949b commit 0faa27d
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions test/csdl2openapi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,75 @@ describe("Edge cases", function () {
);
});

it("function with @ parameter aliases", function () {
const csdl = {
$Version: "4.01",
$Reference: {
dummy: {
$Include: [{ $Namespace: "Org.OData.Core.V1", $Alias: "Core" }],
},
},
$EntityContainer: "model.Container",
model: {
$Alias: "this",
FavoritePhotos: [
{
$Kind: "Function",
$Parameter: [
{
$Name: "skip",
$Type: "Edm.Date",
$Collection: true,
"@Core.Description": "Dates to be skipped",
},
{
$Name: "filter",
"@Core.Description": "Boolean expression to filter the result",
},
],
$ReturnType: {},
},
],
Container: {
fav: { $Function: "this.FavoritePhotos" },
},
},
};
const expected = {
paths: {
"/fav": {
get: {
parameters: [
{
name: "@skip",
in: "query",
required: true,
description:
"Dates to be skipped \nThis is a URL-encoded JSON array with items of type Edm.Date, see [Complex and Collection Literals](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_ComplexandCollectionLiterals)",
schema: { type: "string" },
example: "[]",
},
{
name: "@filter",
in: "query",
required: true,
schema: { type: "string", pattern: "^'([^']|'')*'$" },
description:
"Boolean expression to filter the result \nString value needs to be enclosed in single quotes",
},
],
summary: "Invoke function FavoritePhotos",
tags: ["Service Operations"],
},
},
},
};
const actual = csdl2openapi(csdl, { diagram: true });
delete actual.paths["/$batch"];
delete actual.paths["/fav"].get.responses;
assert.deepStrictEqual(actual.paths, expected.paths);
});

it("return type with facets", function () {
const csdl = {
$EntityContainer: "this.Container",
Expand Down

0 comments on commit 0faa27d

Please sign in to comment.