@@ -4,7 +4,8 @@ const path = require('path');
44const X_CODE_SAMPLES_PROPERTY = 'x-codeSamples' ;
55
66const LANGUAGES = [
7- { lang : 'JavaScript' , label : 'JS client' } ,
7+ { lang : 'JavaScript' , label : 'JS client' , langSuffix : 'js' } ,
8+ { lang : 'cURL' , label : 'Apify CLI' , langSuffix : 'sh' } ,
89] ;
910
1011/**
@@ -24,12 +25,19 @@ function CodeSamplesDecorator(target) {
2425
2526 const codeSamples = [ ] ;
2627
27- for ( const { lang, label } of LANGUAGES ) {
28- const codeSamplePath = path . join ( __dirname , `../../openapi/code_samples/${ lang . toLowerCase ( ) } /${ target . operationId } .js` ) ;
28+ LANGUAGES . forEach ( ( { lang, label, langSuffix } ) => {
29+ // For some reason, the operationId for resurrect run is PostResurrectRun,
30+ // so we change it here to keep the file names consistent
31+ const operationId = target . operationId === 'PostResurrectRun' ? 'actorRun_resurrect_post' : target . operationId ;
32+
33+ const codeSamplePath = path . join (
34+ __dirname ,
35+ `../../openapi/code_samples/${ lang . toLowerCase ( ) } /${ operationId } .${ langSuffix } ` ,
36+ ) ;
2937
3038 if ( ! existsSync ( codeSamplePath ) ) {
3139 // Just use this console log in development to see which operations are missing a code sample.
32- // console.log(`Missing code sample for operation ${target.operationId}`);
40+ console . log ( `Missing code sample for operation ${ target . operationId } . ${ langSuffix } ` ) ;
3341 return ;
3442 }
3543
@@ -40,7 +48,7 @@ function CodeSamplesDecorator(target) {
4048 $ref : codeSamplePath ,
4149 } ,
4250 } ) ;
43- }
51+ } ) ;
4452
4553 if ( codeSamples . length ) {
4654 target [ X_CODE_SAMPLES_PROPERTY ] = codeSamples ;
0 commit comments