@@ -50,6 +50,31 @@ export class SchemaFormatters {
5050 $content : parsedSchema . content ,
5151 } ;
5252 } ,
53+ // JSON-LD schema type formatters
54+ [ SCHEMA_TYPES . JSONLD_CONTEXT ] : ( parsedSchema ) => {
55+ // Format JSON-LD context as an object with proper content formatting
56+ return {
57+ ...parsedSchema ,
58+ $content : parsedSchema . content ,
59+ content : this . formatObjectContent ( parsedSchema . content ) ,
60+ } ;
61+ } ,
62+ [ SCHEMA_TYPES . JSONLD_ENTITY ] : ( parsedSchema ) => {
63+ // Format JSON-LD entity as an object with proper content formatting
64+ return {
65+ ...parsedSchema ,
66+ $content : parsedSchema . content ,
67+ content : this . formatObjectContent ( parsedSchema . content ) ,
68+ } ;
69+ } ,
70+ [ SCHEMA_TYPES . JSONLD_TYPE ] : ( parsedSchema ) => {
71+ // Format JSON-LD type as an object with proper content formatting
72+ return {
73+ ...parsedSchema ,
74+ $content : parsedSchema . content ,
75+ content : this . formatObjectContent ( parsedSchema . content ) ,
76+ } ;
77+ } ,
5378 } ;
5479 inline = {
5580 [ SCHEMA_TYPES . ENUM ] : ( parsedSchema ) => {
@@ -89,6 +114,82 @@ export class SchemaFormatters {
89114 ) ,
90115 } ;
91116 } ,
117+ // JSON-LD inline formatters - reuse OBJECT formatter logic
118+ [ SCHEMA_TYPES . JSONLD_CONTEXT ] : ( parsedSchema ) => {
119+ // Handle JSON-LD context inline formatting similar to object
120+ if ( typeof parsedSchema . content === "string" )
121+ return {
122+ ...parsedSchema ,
123+ typeIdentifier : this . config . Ts . Keyword . Type ,
124+ content : this . schemaUtils . safeAddNullToType ( parsedSchema . content ) ,
125+ } ;
126+
127+ return {
128+ ...parsedSchema ,
129+ typeIdentifier : this . config . Ts . Keyword . Type ,
130+ content : this . schemaUtils . safeAddNullToType (
131+ parsedSchema ,
132+ parsedSchema . content ?. length
133+ ? this . config . Ts . ObjectWrapper (
134+ this . formatObjectContent ( parsedSchema . content ) ,
135+ )
136+ : this . config . Ts . RecordType (
137+ this . config . Ts . Keyword . String ,
138+ this . config . Ts . Keyword . Any ,
139+ ) ,
140+ ) ,
141+ } ;
142+ } ,
143+ [ SCHEMA_TYPES . JSONLD_ENTITY ] : ( parsedSchema ) => {
144+ // Handle JSON-LD entity inline formatting similar to object
145+ if ( typeof parsedSchema . content === "string" )
146+ return {
147+ ...parsedSchema ,
148+ typeIdentifier : this . config . Ts . Keyword . Type ,
149+ content : this . schemaUtils . safeAddNullToType ( parsedSchema . content ) ,
150+ } ;
151+
152+ return {
153+ ...parsedSchema ,
154+ typeIdentifier : this . config . Ts . Keyword . Type ,
155+ content : this . schemaUtils . safeAddNullToType (
156+ parsedSchema ,
157+ parsedSchema . content ?. length
158+ ? this . config . Ts . ObjectWrapper (
159+ this . formatObjectContent ( parsedSchema . content ) ,
160+ )
161+ : this . config . Ts . RecordType (
162+ this . config . Ts . Keyword . String ,
163+ this . config . Ts . Keyword . Any ,
164+ ) ,
165+ ) ,
166+ } ;
167+ } ,
168+ [ SCHEMA_TYPES . JSONLD_TYPE ] : ( parsedSchema ) => {
169+ // Handle JSON-LD type inline formatting similar to object
170+ if ( typeof parsedSchema . content === "string" )
171+ return {
172+ ...parsedSchema ,
173+ typeIdentifier : this . config . Ts . Keyword . Type ,
174+ content : this . schemaUtils . safeAddNullToType ( parsedSchema . content ) ,
175+ } ;
176+
177+ return {
178+ ...parsedSchema ,
179+ typeIdentifier : this . config . Ts . Keyword . Type ,
180+ content : this . schemaUtils . safeAddNullToType (
181+ parsedSchema ,
182+ parsedSchema . content ?. length
183+ ? this . config . Ts . ObjectWrapper (
184+ this . formatObjectContent ( parsedSchema . content ) ,
185+ )
186+ : this . config . Ts . RecordType (
187+ this . config . Ts . Keyword . String ,
188+ this . config . Ts . Keyword . Any ,
189+ ) ,
190+ ) ,
191+ } ;
192+ } ,
92193 } ;
93194
94195 formatSchema = (
0 commit comments