summary refs log tree commit diff
path: root/scripts/openapi.js
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-14 15:17:30 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-14 15:17:30 +1000
commit029bc8b5f8b017cd335a733770176d8b55696055 (patch)
tree6d5d2fe4d94bfc059a7b43e56acabf53cda793e1 /scripts/openapi.js
parentfix some types not being generated correctly (diff)
downloadserver-029bc8b5f8b017cd335a733770176d8b55696055.tar.xz
Fix bug where different HTTP method handlers would overwrite eachother in spec generation
Diffstat (limited to 'scripts/openapi.js')
-rw-r--r--scripts/openapi.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/openapi.js b/scripts/openapi.js
index 76025e4d..8258a76c 100644
--- a/scripts/openapi.js
+++ b/scripts/openapi.js
@@ -84,7 +84,7 @@ function combineSchemas(schemas) {
 	}
 
 	for (const key in definitions) {
-		const reg = new RegExp(/^[a-zA-Z0-9\.\-_]+$/, "gm");
+		const reg = new RegExp(/^[a-zA-Z0-9.\-_]+$/, "gm");
 		if (!reg.test(key)) {
 			console.error(`Invalid schema name: ${key} (${reg.test(key)})`);
 			continue;
@@ -218,9 +218,12 @@ function apiRoutes() {
 
 		obj.tags = [...(obj.tags || []), getTag(p)].unique();
 
-		specification.paths[path] = {
-			[method]: obj,
-		};
+		specification.paths[path] = Object.assign(
+			specification.paths[path] || {},
+			{
+				[method]: obj,
+			},
+		);
 	});
 }