@@ -498,11 +498,16 @@ const Schema = t.type({
498498});
499499```
500500
501- #### 6.2.4 Deprecated Enum Values
501+ #### 6.2.4 Enum Documentation
502502
503- When using ` t.keyof ` to define enums, you can mark specific enum values as deprecated
504- using the ` @deprecated ` tag. Deprecated values will be collected into an
505- ` x-enumsDeprecated ` array in the OpenAPI specification.
503+ When using ` t.keyof ` to define enums, you can add descriptions and deprecation notices
504+ to individual enum values. These will be output as ` x-enumDescriptions ` and
505+ ` x-enumsDeprecated ` in the OpenAPI specification.
506+
507+ - ** ` @description ` ** - Adds a description for a specific enum value. All enum value
508+ descriptions are collected into an ` x-enumDescriptions ` object in the OpenAPI spec.
509+ - ** ` @deprecated ` ** - Marks specific enum values as deprecated. All deprecated enum
510+ values are collected into an ` x-enumsDeprecated ` array in the OpenAPI spec.
506511
507512``` typescript
508513import * as t from ' io-ts' ;
@@ -512,11 +517,23 @@ import * as t from 'io-ts';
512517 */
513518export const TransactionStatus = t .keyof (
514519 {
520+ /**
521+ * @description Transaction is waiting for approval from authorized users
522+ */
515523 pendingApproval: 1 ,
516- /** @deprecated */
524+ /**
525+ * @description Transaction was canceled by the user
526+ * @deprecated
527+ */
517528 canceled: 1 ,
518- /** @deprecated */
529+ /**
530+ * @description Transaction was rejected by approvers
531+ * @deprecated
532+ */
519533 rejected: 1 ,
534+ /**
535+ * @description Transaction has been successfully completed
536+ */
520537 completed: 1 ,
521538 },
522539 ' TransactionStatus' ,
@@ -530,6 +547,12 @@ This will generate the following OpenAPI schema:
530547 "TransactionStatus" : {
531548 "type" : " string" ,
532549 "enum" : [" pendingApproval" , " canceled" , " rejected" , " completed" ],
550+ "x-enumDescriptions" : {
551+ "pendingApproval" : " Transaction is waiting for approval from authorized users" ,
552+ "canceled" : " Transaction was canceled by the user" ,
553+ "rejected" : " Transaction was rejected by approvers" ,
554+ "completed" : " Transaction has been successfully completed"
555+ },
533556 "x-enumsDeprecated" : [" canceled" , " rejected" ]
534557 }
535558}
0 commit comments