11import vm from "node:vm"
22import { describe , expect , it } from "@jest/globals"
33import type {
4- IRModelArray ,
5- IRModelBoolean ,
6- IRModelNumeric ,
7- IRModelObject ,
8- IRModelString ,
9- } from "../../../core/openapi-types-normalized "
4+ SchemaArray ,
5+ SchemaBoolean ,
6+ SchemaNumber ,
7+ SchemaObject ,
8+ SchemaString ,
9+ } from "../../../core/openapi-types"
1010import { testVersions } from "../../../test/input.test-utils"
1111import type { SchemaBuilderConfig } from "./abstract-schema-builder"
1212import {
13- irModelNumber ,
14- irModelObject ,
15- irModelString ,
1613 schemaBuilderTestHarness ,
14+ schemaNumber ,
15+ schemaObject ,
16+ schemaString ,
1717} from "./schema-builder.test-utils"
1818
1919describe . each ( testVersions ) (
@@ -408,7 +408,7 @@ describe.each(testVersions)(
408408 } )
409409
410410 describe ( "numbers" , ( ) => {
411- const base : IRModelNumeric = {
411+ const base : SchemaNumber = {
412412 nullable : false ,
413413 readOnly : false ,
414414 type : "number" ,
@@ -642,7 +642,7 @@ describe.each(testVersions)(
642642 } )
643643
644644 describe ( "strings" , ( ) => {
645- const base : IRModelString = {
645+ const base : SchemaString = {
646646 nullable : false ,
647647 readOnly : false ,
648648 type : "string" ,
@@ -876,7 +876,7 @@ describe.each(testVersions)(
876876 } )
877877
878878 describe ( "booleans" , ( ) => {
879- const base : IRModelBoolean = {
879+ const base : SchemaBoolean = {
880880 nullable : false ,
881881 readOnly : false ,
882882 type : "boolean" ,
@@ -978,7 +978,7 @@ describe.each(testVersions)(
978978 } )
979979
980980 describe ( "arrays" , ( ) => {
981- const base : IRModelArray = {
981+ const base : SchemaArray = {
982982 nullable : false ,
983983 readOnly : false ,
984984 type : "array" ,
@@ -1061,7 +1061,7 @@ describe.each(testVersions)(
10611061 it ( "supports minItems / maxItems / uniqueItems" , async ( ) => {
10621062 const { code, execute} = await getActualFromModel ( {
10631063 ...base ,
1064- items : { type : "number" , nullable : false , readOnly : false } ,
1064+ items : schemaNumber ( ) ,
10651065 minItems : 1 ,
10661066 maxItems : 3 ,
10671067 uniqueItems : true ,
@@ -1111,7 +1111,7 @@ describe.each(testVersions)(
11111111 } )
11121112
11131113 describe ( "objects" , ( ) => {
1114- const base : IRModelObject = {
1114+ const base : SchemaObject = {
11151115 type : "object" ,
11161116 allOf : [ ] ,
11171117 anyOf : [ ] ,
@@ -1203,8 +1203,8 @@ describe.each(testVersions)(
12031203 describe ( "unions" , ( ) => {
12041204 it ( "can union a string and number" , async ( ) => {
12051205 const { code, execute} = await getActualFromModel (
1206- irModelObject ( {
1207- anyOf : [ irModelString ( ) , irModelNumber ( ) ] ,
1206+ schemaObject ( {
1207+ anyOf : [ schemaString ( ) , schemaNumber ( ) ] ,
12081208 } ) ,
12091209 )
12101210
@@ -1222,17 +1222,17 @@ describe.each(testVersions)(
12221222
12231223 it ( "can union an intersected object and string" , async ( ) => {
12241224 const { code, execute} = await getActualFromModel (
1225- irModelObject ( {
1225+ schemaObject ( {
12261226 anyOf : [
1227- irModelString ( ) ,
1228- irModelObject ( {
1227+ schemaString ( ) ,
1228+ schemaObject ( {
12291229 allOf : [
1230- irModelObject ( {
1231- properties : { foo : irModelString ( ) } ,
1230+ schemaObject ( {
1231+ properties : { foo : schemaString ( ) } ,
12321232 required : [ "foo" ] ,
12331233 } ) ,
1234- irModelObject ( {
1235- properties : { bar : irModelString ( ) } ,
1234+ schemaObject ( {
1235+ properties : { bar : schemaString ( ) } ,
12361236 required : [ "bar" ] ,
12371237 } ) ,
12381238 ] ,
@@ -1275,14 +1275,14 @@ describe.each(testVersions)(
12751275 describe ( "intersections" , ( ) => {
12761276 it ( "can intersect objects" , async ( ) => {
12771277 const { code, execute} = await getActualFromModel (
1278- irModelObject ( {
1278+ schemaObject ( {
12791279 allOf : [
1280- irModelObject ( {
1281- properties : { foo : irModelString ( ) } ,
1280+ schemaObject ( {
1281+ properties : { foo : schemaString ( ) } ,
12821282 required : [ "foo" ] ,
12831283 } ) ,
1284- irModelObject ( {
1285- properties : { bar : irModelString ( ) } ,
1284+ schemaObject ( {
1285+ properties : { bar : schemaString ( ) } ,
12861286 required : [ "bar" ] ,
12871287 } ) ,
12881288 ] ,
@@ -1315,22 +1315,22 @@ describe.each(testVersions)(
13151315 // TODO: https://github.com/hapijs/joi/issues/3057
13161316 it . skip ( "can intersect unions" , async ( ) => {
13171317 const { code, execute} = await getActualFromModel (
1318- irModelObject ( {
1318+ schemaObject ( {
13191319 allOf : [
1320- irModelObject ( {
1320+ schemaObject ( {
13211321 oneOf : [
1322- irModelObject ( {
1323- properties : { foo : irModelString ( ) } ,
1322+ schemaObject ( {
1323+ properties : { foo : schemaString ( ) } ,
13241324 required : [ "foo" ] ,
13251325 } ) ,
1326- irModelObject ( {
1327- properties : { bar : irModelString ( ) } ,
1326+ schemaObject ( {
1327+ properties : { bar : schemaString ( ) } ,
13281328 required : [ "bar" ] ,
13291329 } ) ,
13301330 ] ,
13311331 } ) ,
1332- irModelObject ( {
1333- properties : { id : irModelString ( ) } ,
1332+ schemaObject ( {
1333+ properties : { id : schemaString ( ) } ,
13341334 required : [ "id" ] ,
13351335 } ) ,
13361336 ] ,
@@ -1377,7 +1377,7 @@ describe.each(testVersions)(
13771377
13781378 describe ( "unspecified schemas when allowAny: true" , ( ) => {
13791379 const config : SchemaBuilderConfig = { allowAny : true }
1380- const base : IRModelObject = {
1380+ const base : SchemaObject = {
13811381 type : "object" ,
13821382 allOf : [ ] ,
13831383 anyOf : [ ] ,
@@ -1482,7 +1482,7 @@ describe.each(testVersions)(
14821482
14831483 describe ( "unspecified schemas when allowAny: false" , ( ) => {
14841484 const config : SchemaBuilderConfig = { allowAny : false }
1485- const base : IRModelObject = {
1485+ const base : SchemaObject = {
14861486 type : "object" ,
14871487 allOf : [ ] ,
14881488 anyOf : [ ] ,
0 commit comments