Skip to content

Commit ba79330

Browse files
authored
Merge pull request #16 from HydrologicEngineeringCenter/15-base-path-fix
Corrects issue with base path duplicating
2 parents 645c06a + 7738423 commit ba79330

File tree

7 files changed

+26
-5
lines changed

7 files changed

+26
-5
lines changed

scripts/docker/buildAll.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@REM runs all scripts start to finish, using docker where windows might be an issue
2+
echo Fetching and Manipulating spec...
3+
.\scripts\docker\buildSpec.cmd && npm run openapi && .\scripts\docker\runPkg.cmd && cd cwmsjs && npm install && npm run build && cd ..
4+
echo Done.

scripts/docker/buildSpec.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@REM Run scripts from windows
2+
docker run --rm -v %cd%:/scripts -w /scripts node:lts bash -c "npm install -g node-jq && npm run buildSpec"

scripts/docker/runPkg.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker run --rm -v %cd%:/scripts -w /scripts node:lts bash -c "npm install -g node-jq && npm run modPackage"

scripts/spec-updates/modSpec.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,10 @@ sed -r 's/"(get|post|patch|put|delete)CwmsData(\w*)"/"\1\2"/g' |
4242
# Change casing of "Timeseries" to "TimeSeries"
4343
sed -r 's/Timeseries/TimeSeries/g' |
4444

45+
# Remove the /cwms-data base path on all endpoints so user can use their own
46+
sed -r 's|"/cwms-data|"/|g' |
47+
# Remove extra slashes
48+
sed -r 's|"//|"/|g' > cwms-swagger-mod.json |
49+
4550
# Write to file
4651
cat > cwms-swagger-mod.json

scripts/spec-updates/servers.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"servers": [
33
{
4-
"url": "https://cwms-data.usace.army.mil",
4+
"url": "https://cwms-data.usace.army.mil/cwms-data",
55
"description": "PRIMARY production server"
66
},
77
{
8-
"url": "https://water.usace.army.mil",
8+
"url": "https://water.usace.army.mil/cwms-data",
99
"description": "Alias for the PRIMARY production server"
1010
}
1111
]
12-
}
12+
}

tests/endpoints/TimeSeries.v2.test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@ test("Test TimeSeries V2", async () => {
1212
});
1313
const ts_api = new TimeSeriesApi(v2_config);
1414
await ts_api
15-
.getTimeSeries({
15+
.getTimeSeriesRaw({
1616
office: "SWT",
1717
name: "KEYS.Elev.Inst.1Hour.0.Ccp-Rev",
1818
})
19+
.then((r) => {
20+
console.log(r.raw.url);
21+
return r.raw.json();
22+
})
1923
.then((data) => {
2024
expect(data?.values).toBeDefined();
25+
})
26+
.catch((e) => {
27+
console.log(e);
28+
throw Error(e);
2129
});
2230
}, 30000);

tests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"test": "npm run jest-modules --",
1717
"test-cicd": "npm run jest-modules -- --runInBand --ci --detectOpenHandles",
1818
"coverage": "npm run test --coverage",
19+
"test:ts": "npm run jest-modules Timeseries.v2.test.js",
1920
"link": "cd ../src && npm link && cd ../tests && npm link cwmsjs"
2021
},
2122
"jest": {
@@ -51,4 +52,4 @@
5152
"typedoc": "^0.25.13",
5253
"typescript": "^4.9.5"
5354
}
54-
}
55+
}

0 commit comments

Comments
 (0)