Skip to content

Commit

Permalink
feat: joi number min/max validation (#143)
Browse files Browse the repository at this point in the history
#140 but for `joi` schema builders.

also unifies the test harness between `zod` and `joi` schema builder
tests, hopefully helping me be less lazy about improving the `joi`
schema builder in lockstep with `zod`.
  • Loading branch information
mnahkies authored Apr 6, 2024
1 parent a597b35 commit 179ea58
Show file tree
Hide file tree
Showing 5 changed files with 380 additions and 302 deletions.
11 changes: 7 additions & 4 deletions packages/openapi-code-generator/src/test/input.test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {logger} from "../core/logger"
import {OpenapiLoader} from "../core/openapi-loader"
import {OpenapiValidator} from "../core/openapi-validator"

type Version = "3.0.x" | "3.1.x"
export type OpenApiVersion = "3.0.x" | "3.1.x"

function getTestVersions(): Version[] {
function getTestVersions(): OpenApiVersion[] {
if (process.argv.find((arg) => ["--updateSnapshot", "-u"].includes(arg))) {
logger.warn("Running with --updateSnapshot - only testing one version")
return ["3.0.x"]
Expand All @@ -19,7 +19,7 @@ function getTestVersions(): Version[] {

export const testVersions = getTestVersions()

function fileForVersion(version: Version) {
function fileForVersion(version: OpenApiVersion) {
switch (version) {
case "3.0.x":
return path.join(__dirname, "unit-test-inputs-3.0.3.yaml")
Expand All @@ -30,7 +30,10 @@ function fileForVersion(version: Version) {
}
}

export async function unitTestInput(version: Version, skipValidation = false) {
export async function unitTestInput(
version: OpenApiVersion,
skipValidation = false,
) {
const validator = await OpenapiValidator.create()

if (skipValidation) {
Expand Down
Loading

0 comments on commit 179ea58

Please sign in to comment.