-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): automatically download openapi specs on preinstall (#218)
- Loading branch information
Showing
5 changed files
with
37 additions
and
2,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const fs = require('fs/promises'); | ||
|
||
const folder = "node_modules"; | ||
|
||
fs.readFile("connector/gradle/libs.versions.toml") | ||
.then(versions => { | ||
const edcRow = versions.toString().split('\n').filter(row => row.startsWith("edc = "))[0]; | ||
return edcRow.substring(7, edcRow.length - 1) | ||
}) | ||
.then(edcVersion => { | ||
const context = "management-api"; | ||
const resourceUrl = `https://eclipse-edc.github.io/Connector/openapi/${context}/${edcVersion}/${context}.yaml`; | ||
|
||
return fetch(resourceUrl) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error(`Failed to download ${context} openapi spec`); | ||
} | ||
return response.text() | ||
}) | ||
.then(text => text.replaceAll("example: null", "")) | ||
.then(text => fs.writeFile(`${folder}/${context}.yml`, text)); | ||
}) | ||
.catch(error => { | ||
console.error('Error downloading openapi specs:', error); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.