Fix jestOpenAPI call.

This commit is contained in:
Sam Rose 2025-03-03 15:53:33 +00:00
parent 8123a04a8e
commit 2c1b10e4a1
No known key found for this signature in database
2 changed files with 6 additions and 3 deletions

View File

@ -72,6 +72,10 @@ function writeFile(output: any, filename: string) {
return path return path
} }
export function spec() {
return swaggerJsdoc({ ...opts, format: ".json" })
}
export function run() { export function run() {
writeFile(swaggerJsdoc({ ...opts, format: ".json" }), "openapi.json") writeFile(swaggerJsdoc({ ...opts, format: ".json" }), "openapi.json")
return writeFile(swaggerJsdoc({ ...opts, format: ".yaml" }), "openapi.yaml") return writeFile(swaggerJsdoc({ ...opts, format: ".yaml" }), "openapi.yaml")

View File

@ -1,12 +1,11 @@
import jestOpenAPI from "jest-openapi" import jestOpenAPI from "jest-openapi"
import { run as generateSchema } from "../../../../specs/generate" import { spec } from "../../../../specs/generate"
import TestConfiguration from "../TestConfiguration" import TestConfiguration from "../TestConfiguration"
import request, { SuperTest, Test, Response } from "supertest" import request, { SuperTest, Test, Response } from "supertest"
import { ReadStream } from "fs" import { ReadStream } from "fs"
import { getServer } from "../../../app" import { getServer } from "../../../app"
const yamlPath = generateSchema() jestOpenAPI(spec() as any)
jestOpenAPI(yamlPath!)
type Headers = Record<string, string | string[] | undefined> type Headers = Record<string, string | string[] | undefined>
type Method = "get" | "post" | "put" | "patch" | "delete" type Method = "get" | "post" | "put" | "patch" | "delete"