Skip to content

Commit

Permalink
one test script for all schema versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfhandl committed Feb 6, 2025
1 parent 8440252 commit 64dc09a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 43 deletions.
6 changes: 5 additions & 1 deletion tests/schemas/schema.test.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { readdirSync, readFileSync } from "node:fs";
import YAML from "yaml";
import { validate, setMetaSchemaOutputFormat } from "@hyperjump/json-schema/openapi-3-1";
import { validate as validate30 } from "@hyperjump/json-schema/openapi-3-0";
import { validate as validate31, setMetaSchemaOutputFormat } from "@hyperjump/json-schema/openapi-3-1";
import { BASIC } from "@hyperjump/json-schema/experimental";
import { describe, test, expect } from "vitest";

import contentTypeParser from "content-type";
import { addMediaTypePlugin } from "@hyperjump/browser";
import { buildSchemaDocument } from "@hyperjump/json-schema/experimental";
import { validate } from "mdv";

addMediaTypePlugin("application/schema+yaml", {
parse: async (response) => {
Expand All @@ -27,12 +29,14 @@ const parseYamlFromFile = (filePath) => {
setMetaSchemaOutputFormat(BASIC);

const SCHEMAS = [
{ schema: "./schemas/v3.0/schema.yaml", tests: "./tests/schemas/v3.0", validate: validate30 },
{ schema: "./schemas/v3.1/schema.yaml", tests: "./tests/schemas/v3.1" },
{ schema: "./src/schemas/validation/schema.yaml", tests: "./tests/schemas/vNext" }
];


for (const s of SCHEMAS) {
const validate = s.validate || validate31;
const validateOpenApi = await validate(s.schema);
const folder = s.tests;

Expand Down
1 change: 1 addition & 0 deletions tests/schemas/v3.0/fail/empty.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this example doesn't have any of the required fields
42 changes: 0 additions & 42 deletions tests/schemas/v3.0/schema.test.mjs

This file was deleted.

0 comments on commit 64dc09a

Please sign in to comment.