File tree 2 files changed +35
-2
lines changed
2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,21 @@ export interface OpenAPICustomOperationProperties {
47
47
* Description in Document format.
48
48
*/
49
49
'x-gitbook-description-document' ?: object ;
50
+
51
+ /**
52
+ * Enums with name and description
53
+ */
54
+ 'x-enumDescriptions' ?: object ;
55
+
56
+ /**
57
+ * Enums with name and description
58
+ */
59
+ 'x-gitbook-enum' ?: {
60
+ [ key : string ] : {
61
+ description : string ;
62
+ name : string ;
63
+ } ;
64
+ } ;
50
65
}
51
66
52
67
/**
Original file line number Diff line number Diff line change @@ -242,15 +242,33 @@ function OpenAPISchemaEnum(props: {
242
242
} ) {
243
243
const { schema } = props ;
244
244
245
- if ( ! schema . enum || ! schema . enum . length || ! schema [ 'x-enumDescriptions' ] ) {
245
+ if ( ! schema . enum ?. length || ( ! schema [ 'x-enumDescriptions' ] && ! schema [ 'x-gitbook-enum' ] ) ) {
246
246
return null ;
247
247
}
248
248
249
249
const enumValues = ( ( ) => {
250
+ if ( schema [ 'x-gitbook-enum' ] ) {
251
+ return Object . entries ( schema [ 'x-gitbook-enum' ] ) . map ( ( [ _ , { description, name } ] ) => {
252
+ return {
253
+ value : name ,
254
+ description,
255
+ } ;
256
+ } ) ;
257
+ }
258
+
259
+ if ( schema [ 'x-enumDescriptions' ] ) {
260
+ return Object . entries ( schema [ 'x-enumDescriptions' ] ) . map ( ( [ value , description ] ) => {
261
+ return {
262
+ value,
263
+ description,
264
+ } ;
265
+ } ) ;
266
+ }
267
+
250
268
return schema . enum . map ( ( value ) => {
251
269
return {
252
270
value,
253
- description : schema [ 'x-enumDescriptions' ] ?. [ value ] ,
271
+ description : undefined ,
254
272
} ;
255
273
} ) ;
256
274
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments