Skip to content

Commit 584ab21

Browse files
committed
Improve code generation with tests
1 parent 6e26971 commit 584ab21

14 files changed

Lines changed: 84 additions & 33 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ skaffold.yaml
1515
.pytest_cache
1616
.overrides
1717
deployment.yaml
18-
.hypothesis
18+
.hypothesis
19+
__pycache__

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ Recommended:
102102
- node >= v14.0.0
103103
- npm >= 8.0.0
104104

105+
### Java Runtime Environment
106+
107+
A JRE is needed to run the code generators based on openapi-generator.
108+
109+
For more info, see [here](https://openapi-generator.tech/docs/installation).
110+
111+
105112
## CloudHarness command line tools
106113
To use the cli tools, install requirements first:
107114

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
harness:
2+
users:
3+
- username: __APP_NAME__
4+
email: __APP_NAME__@testuser.com
5+
clientRoles: []
6+
realmRoles: []

application-templates/base/deploy/values.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ harness:
1414
dependencies:
1515
build:
1616
- cloudharness-base
17-
- cloudharness-flask
17+
- cloudharness-flask
18+
test:
19+
api:
20+
enabled: true
21+
autotest: true
22+
checks:
23+
- all

application-templates/flask-server/backend/.openapi-generator-ignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ setup.py
2626
Dockerfile
2727
src/__main__.py
2828
requirements.txt
29-
test-requirements.txt
29+
test-requirements.txt
30+
.dockerignore

applications/common/server/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ README.md
44
tox.ini
55
git_push.sh
66
test-requirements.txt
7+
setup.py
78

89
# Byte-compiled / optimized / DLL files
910
__pycache__/

applications/common/server/common/openapi/openapi.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,26 @@ paths:
4444
content:
4545
application/json:
4646
schema:
47-
type: string
47+
type: object
4848
description: Sentry DSN for the given application
49+
"400":
50+
content:
51+
application/json:
52+
schema:
53+
type: object
54+
text/html:
55+
schema:
56+
type: string
57+
description: Sentry not configured for the given application
58+
"404":
59+
content:
60+
application/problem+json:
61+
schema:
62+
type: object
63+
text/html:
64+
schema:
65+
type: string
66+
description: Sentry not configured for the given application
4967
summary: Gets the Sentry DSN for a given application
5068
tags:
5169
- Sentry
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"packageName": "samples"}
1+
{}

applications/samples/frontend/src/rest/common.ts

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,34 +83,24 @@ export const setOAuthToObject = async function (object: any, name: string, scope
8383
}
8484
}
8585

86-
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
87-
if (typeof parameter === "object") {
88-
if (Array.isArray(parameter)) {
89-
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
90-
}
91-
else {
92-
Object.keys(parameter).forEach(currentKey =>
93-
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
94-
);
95-
}
96-
}
97-
else {
98-
if (urlSearchParams.has(key)) {
99-
urlSearchParams.append(key, parameter);
100-
}
101-
else {
102-
urlSearchParams.set(key, parameter);
103-
}
104-
}
105-
}
106-
10786
/**
10887
*
10988
* @export
11089
*/
11190
export const setSearchParams = function (url: URL, ...objects: any[]) {
11291
const searchParams = new URLSearchParams(url.search);
113-
setFlattenedQueryParams(searchParams, objects);
92+
for (const object of objects) {
93+
for (const key in object) {
94+
if (Array.isArray(object[key])) {
95+
searchParams.delete(key);
96+
for (const item of object[key]) {
97+
searchParams.append(key, item);
98+
}
99+
} else {
100+
searchParams.set(key, object[key]);
101+
}
102+
}
103+
}
114104
url.search = searchParams.toString();
115105
}
116106

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"packageName": "workflows_api"}
1+
{}

0 commit comments

Comments
 (0)