@@ -3,7 +3,7 @@ import { FakeCabidela } from "./lib/fake-cabidela";
33import { getMetaData } from "../src/helpers" ;
44
55describe ( "ref and subschema" , ( ) => {
6- let schema :any ;
6+ let schema : any ;
77 if ( process . env . AJV ) {
88 schema = {
99 $id : "http://example.com/schemas/main" ,
@@ -68,6 +68,73 @@ describe("ref and subschema", () => {
6868 test . skipIf ( process . env . AJV ) ( "consolidated schema" , ( ) => {
6969 const cabidela = new FakeCabidela ( schema , { subSchemas : [ contactSchema ] } ) ;
7070 const cs = cabidela . getSchema ( ) ;
71+ expect ( cs ) . toStrictEqual ( {
72+ $id : "http://example.com/schemas/main" ,
73+ type : "object" ,
74+ properties : {
75+ name : {
76+ type : "string" ,
77+ } ,
78+ contacts : {
79+ type : "object" ,
80+ properties : {
81+ email : {
82+ type : "string" ,
83+ } ,
84+ phone : {
85+ type : "string" ,
86+ } ,
87+ } ,
88+ required : [ "email" , "phone" ] ,
89+ } ,
90+ address : {
91+ type : "object" ,
92+ properties : {
93+ street : {
94+ type : "string" ,
95+ } ,
96+ city : {
97+ type : "string" ,
98+ } ,
99+ zip : {
100+ type : "string" ,
101+ } ,
102+ country : {
103+ type : "string" ,
104+ } ,
105+ } ,
106+ required : [ "street" , "city" , "zip" , "country" ] ,
107+ } ,
108+ balance : {
109+ type : "object" ,
110+ properties : {
111+ currency : {
112+ type : "string" ,
113+ } ,
114+ amount : {
115+ type : "number" ,
116+ } ,
117+ } ,
118+ required : [ "currency" , "amount" ] ,
119+ } ,
120+ } ,
121+ required : [ "name" , "contacts" , "address" ] ,
122+ } ) ;
123+ } ) ;
124+
125+ test . skipIf ( process . env . AJV ) ( "consolidated root schema" , ( ) => {
126+ const cabidela = new FakeCabidela (
127+ {
128+ $ref : "customer#/contacts" ,
129+ } ,
130+ { subSchemas : [ contactSchema ] } ,
131+ ) ;
132+ const cs = cabidela . getSchema ( ) ;
133+ expect ( cs ) . toStrictEqual ( {
134+ type : "object" ,
135+ properties : { email : { type : "string" } , phone : { type : "string" } } ,
136+ required : [ "email" , "phone" ] ,
137+ } ) ;
71138 } ) ;
72139
73140 test . skipIf ( process . env . AJV ) ( "$defs" , ( ) => {
0 commit comments