File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed
Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @gitbook/openapi-parser ' : patch
3+ ' @gitbook/react-openapi ' : patch
4+ ---
5+
6+ Optional label in OpenAPI x-codeSamples
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ export type OpenAPIStability = 'experimental' | 'alpha' | 'beta';
7979 */
8080export interface OpenAPICustomCodeSample {
8181 lang : string ;
82- label : string ;
82+ label ? : string ;
8383 source : string ;
8484}
8585
Original file line number Diff line number Diff line change @@ -253,15 +253,11 @@ function getCustomCodeSamples(props: {
253253 if ( customSamples && Array . isArray ( customSamples ) ) {
254254 customCodeSamples = customSamples
255255 . filter ( ( sample ) => {
256- return (
257- typeof sample . label === 'string' &&
258- typeof sample . source === 'string' &&
259- typeof sample . lang === 'string'
260- ) ;
256+ return typeof sample . source === 'string' && typeof sample . lang === 'string' ;
261257 } )
262258 . map ( ( sample , index ) => ( {
263259 key : `custom-sample-${ sample . lang } -${ index } ` ,
264- label : sample . label ,
260+ label : sample . label || sample . lang ,
265261 body : context . renderCodeBlock ( {
266262 code : sample . source ,
267263 syntax : sample . lang ,
You can’t perform that action at this time.
0 commit comments