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';
79
79
*/
80
80
export interface OpenAPICustomCodeSample {
81
81
lang : string ;
82
- label : string ;
82
+ label ? : string ;
83
83
source : string ;
84
84
}
85
85
Original file line number Diff line number Diff line change @@ -253,15 +253,11 @@ function getCustomCodeSamples(props: {
253
253
if ( customSamples && Array . isArray ( customSamples ) ) {
254
254
customCodeSamples = customSamples
255
255
. 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' ;
261
257
} )
262
258
. map ( ( sample , index ) => ( {
263
259
key : `custom-sample-${ sample . lang } -${ index } ` ,
264
- label : sample . label ,
260
+ label : sample . label || sample . lang ,
265
261
body : context . renderCodeBlock ( {
266
262
code : sample . source ,
267
263
syntax : sample . lang ,
You can’t perform that action at this time.
0 commit comments