Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Unreleased]

### Fixed
- Reading json from project root

## Version 1.2.3 - 28.05.2025

Expand Down
14 changes: 10 additions & 4 deletions lib/compile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ function toOpenApiOptions(csdl, csn, options = {}) {
}

if (result["config-file"]) {
if (fs.existsSync(result["config-file"])) {
const fileContent = require(result["config-file"]);
if (!fs.existsSync(result["config-file"])) {
throw new Error("Unable to find openapi config file " + result["config-file"]);
}

try{
const fileData = fs.readFileSync(result["config-file"], "utf-8");
const fileContent = JSON.parse(fileData);

Object.keys(fileContent).forEach((key) => {
if (key === "odata-version" && !result["odataVersion"]) {
result["odataVersion"] = fileContent[key];
Expand All @@ -104,8 +110,8 @@ function toOpenApiOptions(csdl, csn, options = {}) {
result[key] = JSON.stringify(fileContent[key]);
}
});
} else {
throw new Error("Error while parsing the openapi configuration file " + result["config-file"]);
}catch(err){
throw new Error("Unable to parse OpenAPI config " + result["config-file"], { cause: err });
}
}

Expand Down
Loading