Skip to content

Commit b62a2be

Browse files
authored
Migrate to new postgres package (#100)
* migrate package * more maybe fixes * maybe fix * fixes * all tests passing on local * test names * date parsing correctly * improvements * doc * remove single array of all of * add sime important tests * schemas * fix io * fix faulty cast
1 parent 03ba9a6 commit b62a2be

109 files changed

Lines changed: 1304 additions & 1018 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.

bun.lockb

-1.51 KB
Binary file not shown.

open-api/generate.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import "@/lib/extensions"
2+
13
import { apiVersion } from "@/core/version"
24
import { router } from "@/routes/index"
35
import { registry } from "@/schema/registry"
@@ -52,7 +54,8 @@ const fixAllOfNullable = (schema: unknown) => {
5254
if (!schema || typeof schema !== "object" || "$ref" in schema) return
5355

5456
if ("allOf" in schema && Array.isArray(schema["allOf"])) {
55-
schema["allOf"] = schema["allOf"]!.filter(item => {
57+
// nullable is defined in the wrong place
58+
const allOf = schema["allOf"].filter(item => {
5659
if ("nullable" in item && item.nullable === true) {
5760
Object.entries(item).forEach(([k, v]) => {
5861
// @ts-expect-error Generic object
@@ -62,6 +65,17 @@ const fixAllOfNullable = (schema: unknown) => {
6265
}
6366
return true
6467
})
68+
69+
// If there is only one item in the allOf array, we can just redefine the properties on the parent schema
70+
if (allOf.length === 1) {
71+
for (const [k, v] of Object.entries(allOf[0])) {
72+
// @ts-expect-error Redefine the property on the parent schema
73+
schema[k] = v
74+
}
75+
delete schema["allOf"]
76+
} else {
77+
schema["allOf"] = allOf
78+
}
6579
} else {
6680
Object.values(schema).forEach(child => {
6781
fixAllOfNullable(child)

0 commit comments

Comments
 (0)