Skip to content

Commit a341ba0

Browse files
committed
feat: 完善枚举类型注释
1 parent c73dd86 commit a341ba0

19 files changed

Lines changed: 47 additions & 3 deletions

.changeset/odd-webs-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openapi-ts-request': patch
3+
---
4+
5+
增加枚举注释

templates/enum.njk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
{%- if list.length > 0 %}
55
{% for type in list -%}
66
{%- if type.isEnum %}
7+
{%- if type.description%}
8+
/** {{ type.description }} */
9+
{%- endif %}
710
export enum {{ type.typeName | safe }} {{ type.type }};
811

912
export type I{{ type.typeName | safe }} = keyof typeof {{ type.typeName }}

templates/interface.njk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
{%- endfor %}
4444
{%- else %}
4545
{%- if type.isEnum %}
46+
{%- if type.description%}
4647
/** {{ type.description }} */
48+
{%- endif %}
4749
export enum {{ type.typeName | safe }} {{ type.type }};
4850

4951
export type I{{ type.typeName | safe }} = keyof typeof {{ type.typeName }}

test/__snapshots__/common/小驼峰命名文件和请求函数.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ export type PetUsingPutResponses = {
411411
405: unknown;
412412
};
413413

414+
/** Order Status */
414415
export enum StatusEnum {
415416
'placed' = 'placed',
416417
'approved' = 'approved',
@@ -419,6 +420,7 @@ export enum StatusEnum {
419420

420421
export type IStatusEnum = keyof typeof StatusEnum;
421422

423+
/** pet status in the store */
422424
export enum StatusEnum2 {
423425
'available' = 'available',
424426
'pending' = 'pending',

test/__snapshots__/common/支持 null 类型作为默认值.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ export type PetUsingPutResponses = {
411411
405: unknown;
412412
};
413413

414+
/** Order Status */
414415
export enum StatusEnum {
415416
'placed' = 'placed',
416417
'approved' = 'approved',
@@ -419,6 +420,7 @@ export enum StatusEnum {
419420

420421
export type IStatusEnum = keyof typeof StatusEnum;
421422

423+
/** pet status in the store */
422424
export enum StatusEnum2 {
423425
'available' = 'available',
424426
'pending' = 'pending',

test/__snapshots__/common/正常命名文件和请求函数.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ export type PetUsingPutResponses = {
411411
405: unknown;
412412
};
413413

414+
/** Order Status */
414415
export enum StatusEnum {
415416
'placed' = 'placed',
416417
'approved' = 'approved',
@@ -419,6 +420,7 @@ export enum StatusEnum {
419420

420421
export type IStatusEnum = keyof typeof StatusEnum;
421422

423+
/** pet status in the store */
422424
export enum StatusEnum2 {
423425
'available' = 'available',
424426
'pending' = 'pending',

test/__snapshots__/common/测试 number类型 枚举.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export type CityGetRes = {
154154
};
155155

156156
export type CityPutRes = {
157+
/** Poi2CategoryEnum poi2分类 */
157158
city: Poi2CategoryEnum;
158159
};
159160

@@ -162,6 +163,7 @@ export type HTTPValidationError = {
162163
detail?: ValidationError[];
163164
};
164165

166+
/** poi2分类 */
165167
export enum Poi2CategoryEnum {
166168
'STRING_NUMBER_-1' = '-1',
167169
'STRING_NUMBER_-1000' = '-1000',

test/__snapshots__/common/测试 number类型 枚举,使用 desc 解析枚举.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export type ResultOutputUserInfoOutput = {
3535
data?: UserInfoOutput;
3636
};
3737

38+
/** 系统用户角色:User(普通用户)=0,Agent(经纪人)=1,Admin(管理员)=2 */
3839
export enum SysUserRole {
3940
User = 0,
4041
Agent = 1,
@@ -50,6 +51,7 @@ export type UserInfoOutput = {
5051
avatar?: string;
5152
/** 手机号 */
5253
phone?: string;
54+
/** 系统用户角色:User(普通用户)=0,Agent(经纪人)=1,Admin(管理员)=2 */
5355
role?: SysUserRole;
5456
};
5557
/* eslint-disable */

test/__snapshots__/common/测试 tags 为 undefined.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type PetFindByStatusUsingGetResponses = {
7070
400: unknown;
7171
};
7272

73+
/** pet status in the store */
7374
export enum StatusEnum {
7475
'available' = 'available',
7576
'pending' = 'pending',

test/__snapshots__/common/测试 tags 为[].snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type PetFindByStatusUsingGetResponses = {
7070
400: unknown;
7171
};
7272

73+
/** pet status in the store */
7374
export enum StatusEnum {
7475
'available' = 'available',
7576
'pending' = 'pending',

0 commit comments

Comments
 (0)