Skip to content

Commit

Permalink
Bulleted list of allowed derived types
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Oct 10, 2024
1 parent 78d9aa4 commit 3bf41f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions lib/csdl2markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,19 +746,16 @@ module.exports.csdl2markdown = function (filename, csdl, referenced = {}) {
(customType ? "](" + customFile + "#" + np.name + ")" : "") +
(modelElement.$Collection ? "\\]" : "");
if (modelElement[voc.Validation.DerivedTypeConstraint]) {
type +=
" (Allowed derived types: " +
modelElement[voc.Validation.DerivedTypeConstraint]
.map((dt) => {
let link;
if (dt.startsWith("Collection(")) {
dt = dt.substring(11, dt.length - 1);
link = "[.]";
} else link = ".";
return link.replace(".", typeLink({ $Type: dt }));
})
.join(", ") +
")";
type += "<br>Allowed derived types:<ul>";
for (let dt of modelElement[voc.Validation.DerivedTypeConstraint]) {
let link;
if (dt.startsWith("Collection(")) {
dt = dt.substring(11, dt.length - 1);
link = "[.]";
} else link = ".";
type += `<li>${link.replace(".", typeLink({ $Type: dt }))}</li>`;
}
type += "</ul>";
}
return type;
}
Expand Down
2 changes: 1 addition & 1 deletion test/csdl2markdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ describe("Edge cases", function () {
],
};
const mdtype =
"PrimitiveType (Allowed derived types: [Tag](https://github.com/oasis-tcs/odata-vocabularies/blob/main/vocabularies/Org.OData.Core.V1.md#Tag), Duration)";
"PrimitiveType<br>Allowed derived types:<ul><li>[Tag](https://github.com/oasis-tcs/odata-vocabularies/blob/main/vocabularies/Org.OData.Core.V1.md#Tag)</li><li>Duration</li></ul>";
const vocabulary = {
$Version: "4.01",
$Reference: {
Expand Down

0 comments on commit 3bf41f1

Please sign in to comment.