@@ -367,21 +367,34 @@ function resolveReferences(obj, level, startDepth = 0) {
367367function getResponseFormat ( req ) {
368368 const accept = req . headers . accept || '' ;
369369
370- // If no Accept header or Accept is */* , default to DDI JSON
371- if ( ! accept || accept === '*/*' || accept . trim ( ) === '' ) {
370+ // If no Accept header or empty , default to DDI JSON
371+ if ( ! accept || accept . trim ( ) === '' ) {
372372 return 'json' ;
373373 }
374374
375- // Only accept DDI-specific formats
375+ // Check for DDI-specific formats first (explicit requests)
376376 if ( accept . includes ( 'application/vnd.ddi.structure+xml;version=3.3' ) ) {
377377 return 'xml' ;
378378 }
379379 if ( accept . includes ( 'application/vnd.ddi.structure+json;version=3.3' ) ) {
380380 return 'json' ;
381381 }
382382
383- // Unsupported format
384- return null ;
383+ // If Accept contains */* (wildcard), default to DDI JSON
384+ // This handles browser requests like "text/html,application/xhtml+xml,*/*;q=0.8"
385+ if ( accept . includes ( '*/*' ) ) {
386+ return 'json' ;
387+ }
388+
389+ // If Accept is exactly */*, default to DDI JSON
390+ if ( accept . trim ( ) === '*/*' ) {
391+ return 'json' ;
392+ }
393+
394+ // For any other Accept header (browser defaults, generic formats, etc.),
395+ // default to DDI JSON instead of returning 406
396+ // This makes the API more user-friendly: JSON by default unless XML is explicitly requested
397+ return 'json' ;
385398}
386399
387400// Helper to send response in appropriate format
0 commit comments