@@ -126,90 +126,313 @@ <h1 class="display-6 d-lg-none fw-bold text-dark mb-4">
126126 </ div >
127127 </ div >
128128
129- < div class ="row g-4 mt-4 ">
130- < div class ="col-12 col-lg-6 ">
131- < div class ="d-flex flex-column h-100 ">
132- < div class ="d-flex align-items-center mb-3 ">
133- < div class ="bg-danger text-white rounded-circle d-flex align-items-center justify-content-center me-3 " style ="width: 40px; height: 40px; ">
134- < i class ="bi bi-x-lg "> </ i >
135- </ div >
136- < h3 class ="h4 mb-0 fw-bold "> Before</ h3 >
129+ < div class ="mt-5 ">
130+ < h3 class ="h4 fw-bold text-center mb-4 "> What's Inside: Sample Schemas from the Library</ h3 >
131+
132+ < style >
133+ .schema-editor-window {
134+ border-radius : 12px ;
135+ overflow : hidden;
136+ box-shadow : 0 0.5rem 1rem rgba (0 , 0 , 0 , 0.15 );
137+ }
138+ .schema-tab {
139+ background : # 1e1e1e ;
140+ color : # 858585 ;
141+ border : none;
142+ border-right : 1px solid # 3c3c3c ;
143+ border-bottom : 2px solid transparent;
144+ padding : 0.75rem 1.5rem ;
145+ font-size : 0.875rem ;
146+ cursor : pointer;
147+ transition : background 0.2s , color 0.2s ;
148+ }
149+ .schema-tab : hover {
150+ background : # 2d2d2d ;
151+ color : # ffffff ;
152+ }
153+ .schema-tab .active {
154+ background : # 2d2d2d ;
155+ color : # ffffff ;
156+ border-bottom-color : # 007acc ;
157+ }
158+ .line-numbers {
159+ color : # 858585 ;
160+ user-select : none;
161+ text-align : right;
162+ padding-right : 1rem ;
163+ border-right : 1px solid # 3c3c3c ;
164+ min-width : 3.5rem ;
165+ width : 3.5rem ;
166+ }
167+ .tab-line-count {
168+ font-size : 0.75rem ;
169+ color : # 666 ;
170+ font-weight : normal;
171+ }
172+ .browse-link {
173+ background : linear-gradient (135deg , # 667eea 0% , # 764ba2 100% );
174+ color : # ffffff ;
175+ font-weight : 600 ;
176+ border-right : none;
177+ text-decoration : none;
178+ display : inline-block;
179+ }
180+ .browse-link : hover {
181+ background : linear-gradient (135deg , # 5568d3 0% , # 6a4193 100% );
182+ color : # ffffff ;
183+ transform : translateY (-1px );
184+ }
185+ </ style >
186+
187+ < div class ="schema-editor-window ">
188+ <!-- Window Controls -->
189+ < div class ="d-flex align-items-center px-3 py-2 " style ="background: #2d2d2d; ">
190+ < div class ="d-flex gap-1 me-3 ">
191+ < div class ="rounded-circle " style ="width: 12px; height: 12px; background: #ff5f56; "> </ div >
192+ < div class ="rounded-circle " style ="width: 12px; height: 12px; background: #ffbd2e; "> </ div >
193+ < div class ="rounded-circle " style ="width: 12px; height: 12px; background: #27c93f; "> </ div >
194+ </ div >
195+ < span class ="small text-white-50 " id ="schema-filename "> jsonrpc/v2.0/request.json</ span >
196+ </ div >
197+
198+ <!-- Tabs -->
199+ < div class ="d-flex " style ="background: #1e1e1e; ">
200+ < button class ="schema-tab active " data-schema ="jsonrpc ">
201+ JSON-RPC Request < span class ="tab-line-count " id ="tab-jsonrpc "> </ span >
202+ </ button >
203+ < button class ="schema-tab " data-schema ="currency ">
204+ ISO Currency < span class ="tab-line-count " id ="tab-currency "> </ span >
205+ </ button >
206+ < button class ="schema-tab " data-schema ="xbrl ">
207+ XBRL Monetary < span class ="tab-line-count " id ="tab-xbrl "> </ span >
208+ </ button >
209+ < button class ="schema-tab " data-schema ="uri ">
210+ URI Reference < span class ="tab-line-count " id ="tab-uri "> </ span >
211+ </ button >
212+ < a href ="https://schemas.sourcemeta.com/sourcemeta/std " class ="schema-tab browse-link " target ="_blank " rel ="noopener noreferrer ">
213+ < i class ="bi bi-box-arrow-up-right me-1 "> </ i > Browse All 300+
214+ </ a >
215+ </ div >
216+
217+ <!-- Editor Content -->
218+ < div style ="max-height: 400px; background: #1e1e1e; overflow-y: auto; ">
219+ < div class ="d-flex " style ="font-size: 0.875rem; line-height: 1.6; ">
220+ < pre class ="m-0 p-3 line-numbers " id ="line-numbers "> 1</ pre >
221+ < pre class ="m-0 p-3 flex-grow-1 "> < code id ="schema-content " class ="language-json text-white-50 "> Loading schema...</ code > </ pre >
137222 </ div >
138- {{< editor filename ="openapi.yaml " type ="fail " language ="yaml " details ="100+ lines of repetitive validation code|Broken regex patterns copied from ChatGPT|Incomplete or incorrect enumerations|No standards compliance guarantees " > }}openapi: 3.1.0
139- paths:
140- /users:
141- post:
142- requestBody:
143- content:
144- application/json:
145- schema:
146- type: object
147- properties:
148- email:
149- type: string
150- pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
151- description: Email address
152- country:
153- type: string
154- pattern: '^[A-Z]{2}$'
155- description: ISO 3166-1 alpha-2 country code
156- currency:
157- type: string
158- enum: [ AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT,
159- BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD,
160- CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD,
161- EGP, ERN, ETB, EUR, FJD, FKP, FOK, GBP, GEL, GGP, GHS, GIP, GMD,
162- GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, IMP, INR, IQD,
163- IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD,
164- KYD, KZT, LAK, LBP, LKR, LRD, LSL ]
165- description: ISO 4217 currency code
166- website:
167- type: string
168- pattern: '^https'
169- description: Website URL
170- created_at:
171- type: string
172- pattern: '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$'
173- description: ISO 8601 datetime
174- language:
175- type: string
176- pattern: '^[a-z]{2}(-[A-Z]{2})?$'
177- description: Language code{{< /editor > }}
178223 </ div >
179- </ div >
180224
181- < div class ="col-12 col-lg-6 ">
182- < div class ="d-flex flex-column h-100 ">
183- < div class ="d-flex align-items-center mb-3 ">
184- < div class ="bg-success text-white rounded-circle d-flex align-items-center justify-content-center me-3 " style ="width: 40px; height: 40px; ">
185- < i class ="bi bi-check-lg "> </ i >
225+ <!-- Footer -->
226+ < div style ="background: #252526; border-top: 1px solid #3c3c3c; ">
227+ < div class ="px-3 py-2 " style ="background: #2d2d30; border-bottom: 1px solid #3c3c3c; ">
228+ < small class ="text-white-50 text-uppercase " style ="font-size: 0.7rem; letter-spacing: 0.5px; ">
229+ < i class ="bi bi-info-circle-fill text-info me-2 "> </ i > About This Schema
230+ </ small >
231+ </ div >
232+ < div class ="p-3 " id ="schema-description ">
233+ < div class ="d-flex align-items-start mb-2 ">
234+ < i class ="bi bi-check-circle-fill text-success me-2 " style ="font-size: 0.85rem; margin-top: 2px; "> </ i >
235+ < span class ="small text-white-50 "> Implements the official JSON-RPC 2.0 specification for remote procedure calls</ span >
236+ </ div >
237+ < div class ="d-flex align-items-start mb-2 ">
238+ < i class ="bi bi-check-circle-fill text-success me-2 " style ="font-size: 0.85rem; margin-top: 2px; "> </ i >
239+ < span class ="small text-white-50 "> Validates request structure, method names, and parameter formats</ span >
240+ </ div >
241+ < div class ="d-flex align-items-start ">
242+ < i class ="bi bi-check-circle-fill text-success me-2 " style ="font-size: 0.85rem; margin-top: 2px; "> </ i >
243+ < span class ="small text-white-50 "> Used by thousands of APIs for standardized RPC communication</ span >
186244 </ div >
187- < h3 class ="h4 mb-0 fw-bold "> After</ h3 >
188245 </ div >
189- {{< editor filename ="openapi.yaml " type ="success " language ="yaml " details ="Clean and readable OpenAPI definitions|Standards-backed validation (IETF RFC's, ISO, etc)|Guaranteed schema correctness|Took 5 minutes to write " > }}openapi: 3.1.0
190- paths:
191- /users:
192- post:
193- requestBody:
194- content:
195- application/json:
196- schema:
197- type: object
198- properties:
199- email:
200- $ref: './std/ietf/email/address.json'
201- country:
202- $ref: './std/iso/country/2020/alpha-2.json'
203- currency:
204- $ref: './std/iso/currency/2015/alpha-code.json'
205- website:
206- $ref: './std/ietf/uri/url.json'
207- created_at:
208- $ref: './std/iso/datetime/2019/datetime/calendar-extended.json'
209- language:
210- $ref: './std/ietf/language/tag.json'{{< /editor > }}
211246 </ div >
212247 </ div >
248+
249+ < script >
250+ ( function ( ) {
251+ const schemas = {
252+ jsonrpc : {
253+ url : 'https://schemas.sourcemeta.com/sourcemeta/std/v0/jsonrpc/v2.0/request.json?bundle=1' ,
254+ filename : 'jsonrpc/v2.0/request.json' ,
255+ description : `
256+ <div class="d-flex align-items-start mb-2">
257+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
258+ <span class="small text-white-50">Implements the official JSON-RPC 2.0 specification for remote procedure calls</span>
259+ </div>
260+ <div class="d-flex align-items-start mb-2">
261+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
262+ <span class="small text-white-50">Validates request structure, method names, and parameter formats</span>
263+ </div>
264+ <div class="d-flex align-items-start">
265+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
266+ <span class="small text-white-50">Critical for JSON-RPC based APIs like MCP (Model Context Protocol)</span>
267+ </div>
268+ ` ,
269+ data : null
270+ } ,
271+ currency : {
272+ url : 'https://schemas.sourcemeta.com/sourcemeta/std/v0/iso/currency/2015/alpha-code.json?bundle=1' ,
273+ filename : 'iso/currency/2015/alpha-code.json' ,
274+ description : `
275+ <div class="d-flex align-items-start mb-2">
276+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
277+ <span class="small text-white-50">Based on ISO 4217 standard for currency codes</span>
278+ </div>
279+ <div class="d-flex align-items-start mb-2">
280+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
281+ <span class="small text-white-50">Covers currencies, funds, and precious metals like gold and silver</span>
282+ </div>
283+ <div class="d-flex align-items-start">
284+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
285+ <span class="small text-white-50">Essential for financial APIs and e-commerce platforms</span>
286+ </div>
287+ ` ,
288+ data : null
289+ } ,
290+ xbrl : {
291+ url : 'https://schemas.sourcemeta.com/sourcemeta/std/v0/xbrl/instance/2003/monetary-item-type.json?bundle=1' ,
292+ filename : 'xbrl/instance/2003/monetary-item-type.json' ,
293+ description : `
294+ <div class="d-flex align-items-start mb-2">
295+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
296+ <span class="small text-white-50">Implements XBRL financial reporting standard</span>
297+ </div>
298+ <div class="d-flex align-items-start mb-2">
299+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
300+ <span class="small text-white-50">Commonly used for accountancy and financial disclosures</span>
301+ </div>
302+ <div class="d-flex align-items-start">
303+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
304+ <span class="small text-white-50">Widely adopted by regulatory bodies and financial authorities worldwide</span>
305+ </div>
306+ ` ,
307+ data : null
308+ } ,
309+ uri : {
310+ url : 'https://schemas.sourcemeta.com/sourcemeta/std/v0/ietf/uri/uri-reference.json?bundle=1' ,
311+ filename : 'ietf/uri/uri-reference.json' ,
312+ description : `
313+ <div class="d-flex align-items-start mb-2">
314+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
315+ <span class="small text-white-50">Implements IETF RFC 3986 for URI validation</span>
316+ </div>
317+ <div class="d-flex align-items-start mb-2">
318+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
319+ <span class="small text-white-50">Validates URLs, URNs, and all URI formats correctly</span>
320+ </div>
321+ <div class="d-flex align-items-start">
322+ <i class="bi bi-check-circle-fill text-success me-2" style="font-size: 0.85rem; margin-top: 2px;"></i>
323+ <span class="small text-white-50">Fully supports both relative and absolute URIs</span>
324+ </div>
325+ ` ,
326+ data : null
327+ }
328+ } ;
329+
330+ const contentElement = document . getElementById ( 'schema-content' ) ;
331+ const lineNumbersElement = document . getElementById ( 'line-numbers' ) ;
332+ const filenameElement = document . getElementById ( 'schema-filename' ) ;
333+ const descriptionElement = document . getElementById ( 'schema-description' ) ;
334+ const tabs = document . querySelectorAll ( '.schema-tab[data-schema]' ) ;
335+
336+ function syntaxHighlight ( json ) {
337+ json = json . replace ( / & / g, '&' ) . replace ( / < / g, '<' ) . replace ( / > / g, '>' ) ;
338+ return json . replace ( / ( " ( \\ u [ a - z A - Z 0 - 9 ] { 4 } | \\ [ ^ u ] | [ ^ \\ " ] ) * " ( \s * : ) ? | \b ( t r u e | f a l s e | n u l l ) \b | - ? \d + (?: \. \d * ) ? (?: [ e E ] [ + \- ] ? \d + ) ? ) / g, function ( match ) {
339+ let cls = 'text-warning' ;
340+ if ( / ^ " / . test ( match ) ) {
341+ if ( / : $ / . test ( match ) ) {
342+ cls = 'text-info' ;
343+ } else {
344+ cls = 'text-success' ;
345+ }
346+ } else if ( / t r u e | f a l s e / . test ( match ) ) {
347+ cls = 'text-primary' ;
348+ } else if ( / n u l l / . test ( match ) ) {
349+ cls = 'text-secondary' ;
350+ }
351+ return '<span class="' + cls + '">' + match + '</span>' ;
352+ } ) ;
353+ }
354+
355+ function updateLineNumbers ( text ) {
356+ const lineCount = text . split ( '\n' ) . length ;
357+ lineNumbersElement . textContent = Array . from ( { length : lineCount } , ( _ , i ) => i + 1 ) . join ( '\n' ) ;
358+ }
359+
360+ function updateTabLineCount ( schemaKey , lineCount ) {
361+ const tabElement = document . getElementById ( 'tab-' + schemaKey ) ;
362+ if ( tabElement ) {
363+ tabElement . textContent = '(' + lineCount + ' lines)' ;
364+ }
365+ }
366+
367+ function loadSchema ( schemaKey ) {
368+ const schema = schemas [ schemaKey ] ;
369+
370+ if ( schema . data ) {
371+ contentElement . innerHTML = schema . data . highlighted ;
372+ updateLineNumbers ( schema . data . formatted ) ;
373+ filenameElement . textContent = schema . filename ;
374+ descriptionElement . innerHTML = schema . description ;
375+ } else {
376+ contentElement . textContent = 'Loading schema...' ;
377+ lineNumbersElement . textContent = '1' ;
378+ fetch ( schema . url )
379+ . then ( response => response . json ( ) )
380+ . then ( data => {
381+ const formatted = JSON . stringify ( data , null , 2 ) ;
382+ const highlighted = syntaxHighlight ( formatted ) ;
383+ const lineCount = formatted . split ( '\n' ) . length ;
384+ schema . data = { formatted, highlighted, lineCount } ;
385+ contentElement . innerHTML = highlighted ;
386+ updateLineNumbers ( formatted ) ;
387+ updateTabLineCount ( schemaKey , lineCount ) ;
388+ filenameElement . textContent = schema . filename ;
389+ descriptionElement . innerHTML = schema . description ;
390+ } )
391+ . catch ( error => {
392+ contentElement . textContent = 'Error loading schema: ' + error . message ;
393+ contentElement . classList . add ( 'text-danger' ) ;
394+ lineNumbersElement . textContent = '1' ;
395+ } ) ;
396+ }
397+ }
398+
399+ tabs . forEach ( tab => {
400+ tab . addEventListener ( 'click' , function ( ) {
401+ const schemaKey = this . getAttribute ( 'data-schema' ) ;
402+
403+ tabs . forEach ( t => t . classList . remove ( 'active' ) ) ;
404+ this . classList . add ( 'active' ) ;
405+
406+ loadSchema ( schemaKey ) ;
407+ } ) ;
408+ } ) ;
409+
410+ // Preload all schemas
411+ Object . keys ( schemas ) . forEach ( schemaKey => {
412+ const schema = schemas [ schemaKey ] ;
413+ fetch ( schema . url )
414+ . then ( response => response . json ( ) )
415+ . then ( data => {
416+ const formatted = JSON . stringify ( data , null , 2 ) ;
417+ const highlighted = syntaxHighlight ( formatted ) ;
418+ const lineCount = formatted . split ( '\n' ) . length ;
419+ schema . data = { formatted, highlighted, lineCount } ;
420+ updateTabLineCount ( schemaKey , lineCount ) ;
421+
422+ // If this is the first schema, display it
423+ if ( schemaKey === 'jsonrpc' ) {
424+ contentElement . innerHTML = highlighted ;
425+ updateLineNumbers ( formatted ) ;
426+ filenameElement . textContent = schema . filename ;
427+ descriptionElement . innerHTML = schema . description ;
428+ }
429+ } )
430+ . catch ( error => {
431+ console . error ( 'Error preloading schema ' + schemaKey + ':' , error ) ;
432+ } ) ;
433+ } ) ;
434+ } ) ( ) ;
435+ </ script >
213436 </ div >
214437{{< /blueprint > }}
215438
0 commit comments