Skip to content
Snippets Groups Projects
Commit b576f2ff authored by Sylvain Renault's avatar Sylvain Renault
Browse files

Compatibility with new NSwag (14.0.7.0)

Using merged common and worldstorage/analysis api
Updated README.md
parent 74a0f499
No related branches found
No related tags found
1 merge request!2Compatibility with new NSwag (14.0.7.0)
......@@ -31,20 +31,54 @@ The referenced submodule contains the OpenAPI specification of the ISG ARF World
git checkout master
cd ..
# Preparing the yaml file (merging)
Before generating the code you must put all referenced YAML file together, otherwies you will get an error in NSwag.For this, we uses a custom tool 'openapi-merger'. This tool only includes file-referenced ref shemas, and do not change local ones (as 'swagger-merger' will do!).
npm install -g openapi-merger
## Patching the openfile JS command
If you have some white char in your path/filename, openapi-merger will failed because of an error with the %20 (white pace) in the pathname. To avoid this, please add a line to the js script 'yaml.js' located in your npm path e.g.
C:\Users\<YOU>\AppData\Roaming\npm\node_modules\openapi-merger\src
In the readYAML function, the first line:
function readYAML(filePath) {
filePath = filePath.replace ("%20", " "); // Bug fixing, SylR/FraunhoferHHI
const str = "" + fs.readFileSync(filePath, "utf8");
return yaml.load(str);
}
## Using it
To start the merging go into the definition folder of the API and execute this:
cd openapi/API/worldstorage
npx openapi-merger -i worldstorageopenapi.yaml -o worldstorageopenapi_merged.yaml
and also here:
cd openapi/API/worldanalysis
npx openapi-merger -i worldanalysisopenapi.yaml -o worldanalysisopenapi_merged.yaml
Don't forget to change the filename in the JSON config file for NSwag to the merged one!!!
# Installing NSwag
npm install nswag -g
You can check the version with
npx nswag version
nswag version
# Code Generation
To generate the code and the DLLs use the following commands:
To generate the c# code use the following commands:
npx nswag run WorldStorageNSwag.json
npx nswag run WorldAnalysisNSwag.json
nswag run WorldStorageNSwag.json
nswag run WorldAnalysisNSwag.json
The generated C# modules (one per definition file) are then contained in the folder `client/csharp-nswag`.
......
......@@ -3,7 +3,7 @@
"defaultVariables": null,
"documentGenerator": {
"fromDocument": {
"url": "API/worldanalysis/worldanalysisopenapi.yaml",
"url": "openapi/API/worldanalysis/worldanalysisopenapi_merged.yaml",
"output": null,
"newLineBehavior": "Auto"
}
......
......@@ -3,7 +3,7 @@
"defaultVariables": null,
"documentGenerator": {
"fromDocument": {
"url": "API/worldstorage/worldstorageopenapi.yaml",
"url": "openapi/API/worldstorage/worldstorageopenapi_merged.yaml",
"output": null,
"newLineBehavior": "Auto"
}
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -16,6 +16,12 @@
"run-script-os": "^1.1.6"
},
"dependencies": {
"dotnet-3.1": "*"
"dotnet": "^1.1.4",
"dotnet-3.1": "*",
"latest": "^0.2.0",
"lts": "^1.2.0",
"net": "^1.0.2",
"nswag": "^14.0.7",
"swagger-merger": "^1.5.4"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment