Skip to content

Commit 12c4d87

Browse files
chore: reduce release merge conflicts by stabilizing OpenAPI client headers (#507)
1 parent 6bff840 commit 12c4d87

66 files changed

Lines changed: 157 additions & 64 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"generate:api:application-server": "npm run generate:api:application-server:specs && npm run generate:api:application-server:client",
1212
"generate:api:intelligence-service:clean": "shx rm -rf server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice",
1313
"generate:api:intelligence-service:specs": "cd server/intelligence-service && poetry run openapi",
14-
"generate:api:intelligence-service:client": "npx openapi-generator-cli generate -i server/intelligence-service/openapi.yaml -g java --library resttemplate --api-package de.tum.in.www1.hephaestus.intelligenceservice.api --model-package de.tum.in.www1.hephaestus.intelligenceservice.model --invoker-package de.tum.in.www1.hephaestus.intelligenceservice --additional-properties useJakartaEe=true,performBeanValidation=true,hideGenerationTimestamp=true,openApiNullable=true,serializationLibrary=jackson --package-name de.tum.in.www1.hephaestus.intelligenceservice -o tmp/java-client && shx mkdir -p server/application-server/src/main/java/de/tum/in/www1/hephaestus && shx cp -r tmp/java-client/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice server/application-server/src/main/java/de/tum/in/www1/hephaestus/ && shx rm -rf tmp",
14+
"generate:api:intelligence-service:client": "npx openapi-generator-cli generate -i server/intelligence-service/openapi.yaml -g java --library resttemplate --api-package de.tum.in.www1.hephaestus.intelligenceservice.api --model-package de.tum.in.www1.hephaestus.intelligenceservice.model --invoker-package de.tum.in.www1.hephaestus.intelligenceservice --additional-properties useJakartaEe=true,performBeanValidation=true,hideGenerationTimestamp=true,openApiNullable=true,serializationLibrary=jackson --package-name de.tum.in.www1.hephaestus.intelligenceservice -o tmp/java-client && shx mkdir -p server/application-server/src/main/java/de/tum/in/www1/hephaestus && shx cp -r tmp/java-client/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice server/application-server/src/main/java/de/tum/in/www1/hephaestus/ && shx rm -rf tmp && node scripts/postprocess-openapi-java.mjs",
1515
"generate:api:intelligence-service": "npm run generate:api:intelligence-service:clean && npm run generate:api:intelligence-service:specs && npm run generate:api:intelligence-service:client",
1616
"generate:api": "npm run generate:api:intelligence-service && npm run generate:api:application-server",
1717
"format:java": "prettier --write server/application-server/src/**/*.java --config-precedence prefer-file --config server/application-server/.prettierrc.yaml --ignore-path server/application-server/.prettierignore",
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env node
2+
import { promises as fs } from 'node:fs';
3+
import path from 'node:path';
4+
import { fileURLToPath } from 'node:url';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
8+
const repoRoot = path.resolve(__dirname, '..');
9+
const targetDir = path.join(
10+
repoRoot,
11+
'server',
12+
'application-server',
13+
'src',
14+
'main',
15+
'java',
16+
'de',
17+
'tum',
18+
'in',
19+
'www1',
20+
'hephaestus',
21+
'intelligenceservice',
22+
);
23+
24+
const replacementText =
25+
'The version of the OpenAPI document is defined in server/intelligence-service/openapi.yaml.';
26+
27+
async function walk(dir) {
28+
const entries = await fs.readdir(dir, { withFileTypes: true });
29+
const files = await Promise.all(
30+
entries.map(async (entry) => {
31+
const fullPath = path.join(dir, entry.name);
32+
if (entry.isDirectory()) {
33+
return walk(fullPath);
34+
}
35+
if (entry.isFile() && entry.name.endsWith('.java')) {
36+
return [fullPath];
37+
}
38+
return [];
39+
}),
40+
);
41+
return files.flat();
42+
}
43+
44+
async function processFile(filePath) {
45+
const content = await fs.readFile(filePath, 'utf8');
46+
if (!content.includes('The version of the OpenAPI document:')) {
47+
return false;
48+
}
49+
const updated = content.replace(
50+
/^\s*\* The version of the OpenAPI document.*$/gm,
51+
` * ${replacementText}`,
52+
);
53+
if (updated === content) {
54+
return false;
55+
}
56+
await fs.writeFile(filePath, updated, 'utf8');
57+
return true;
58+
}
59+
60+
async function main() {
61+
try {
62+
await fs.access(targetDir);
63+
} catch (error) {
64+
if (error && error.code === 'ENOENT') {
65+
console.warn(`Target directory not found: ${targetDir}`);
66+
return;
67+
}
68+
throw error;
69+
}
70+
71+
const javaFiles = await walk(targetDir);
72+
let changedCount = 0;
73+
74+
for (const file of javaFiles) {
75+
if (await processFile(file)) {
76+
changedCount += 1;
77+
}
78+
}
79+
80+
console.log(`Processed ${javaFiles.length} Java files. Updated ${changedCount} files.`);
81+
}
82+
83+
main().catch((error) => {
84+
console.error(error);
85+
process.exitCode = 1;
86+
});

server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/JavaTimeFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Hephaestus Intelligence Service API
33
* API documentation for the Hephaestus Intelligence Service.
44
*
5-
* The version of the OpenAPI document: 0.9.2-rc.1
5+
* The version of the OpenAPI document is defined in server/intelligence-service/openapi.yaml.
66
* Contact: felixtj.dietrich@tum.de
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/RFC3339DateFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Hephaestus Intelligence Service API
33
* API documentation for the Hephaestus Intelligence Service.
44
*
5-
* The version of the OpenAPI document: 0.9.2-rc.1
5+
* The version of the OpenAPI document is defined in server/intelligence-service/openapi.yaml.
66
* Contact: felixtj.dietrich@tum.de
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/model/BadPractice.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Hephaestus Intelligence Service API
33
* API documentation for the Hephaestus Intelligence Service.
44
*
5-
* The version of the OpenAPI document: 0.9.2-rc.1
5+
* The version of the OpenAPI document is defined in server/intelligence-service/openapi.yaml.
66
* Contact: felixtj.dietrich@tum.de
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/model/BadPracticeStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Hephaestus Intelligence Service API
33
* API documentation for the Hephaestus Intelligence Service.
44
*
5-
* The version of the OpenAPI document: 0.9.2-rc.1
5+
* The version of the OpenAPI document is defined in server/intelligence-service/openapi.yaml.
66
* Contact: felixtj.dietrich@tum.de
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/model/ChatRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Hephaestus Intelligence Service API
33
* API documentation for the Hephaestus Intelligence Service.
44
*
5-
* The version of the OpenAPI document: 0.9.2-rc.1
5+
* The version of the OpenAPI document is defined in server/intelligence-service/openapi.yaml.
66
* Contact: felixtj.dietrich@tum.de
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/model/ChatResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Hephaestus Intelligence Service API
33
* API documentation for the Hephaestus Intelligence Service.
44
*
5-
* The version of the OpenAPI document: 0.9.2-rc.1
5+
* The version of the OpenAPI document is defined in server/intelligence-service/openapi.yaml.
66
* Contact: felixtj.dietrich@tum.de
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/model/CreateDocumentInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Hephaestus Intelligence Service API
33
* API documentation for the Hephaestus Intelligence Service.
44
*
5-
* The version of the OpenAPI document: 0.9.2-rc.1
5+
* The version of the OpenAPI document is defined in server/intelligence-service/openapi.yaml.
66
* Contact: felixtj.dietrich@tum.de
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/model/CreateDocumentOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Hephaestus Intelligence Service API
33
* API documentation for the Hephaestus Intelligence Service.
44
*
5-
* The version of the OpenAPI document: 0.9.2-rc.1
5+
* The version of the OpenAPI document is defined in server/intelligence-service/openapi.yaml.
66
* Contact: felixtj.dietrich@tum.de
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

0 commit comments

Comments
 (0)