Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 32d5b26

Browse files
authored
fix: bugs related to model name casing (zenstackhq#645)
1 parent d8c2e87 commit 32d5b26

File tree

23 files changed

+703
-617
lines changed

23 files changed

+703
-617
lines changed

packages/plugins/openapi/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"lower-case-first": "^2.0.2",
3232
"openapi-types": "^12.1.0",
3333
"tiny-invariant": "^1.3.1",
34+
"upper-case-first": "^2.0.2",
3435
"yaml": "^2.2.1",
3536
"zod": "3.21.1",
3637
"zod-validation-error": "^0.2.1"

packages/plugins/openapi/src/rpc-generator.ts

Lines changed: 88 additions & 84 deletions
Large diffs are not rendered by default.

packages/plugins/openapi/tests/baseline/rest.baseline.yaml

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ info:
55
tags:
66
- name: user
77
description: User operations
8-
- name: post
8+
- name: post_Item
99
description: Post-related operations
1010
paths:
1111
/user:
@@ -172,7 +172,7 @@ paths:
172172
style: form
173173
explode: false
174174
schema:
175-
$ref: '#/components/schemas/Role'
175+
$ref: '#/components/schemas/role'
176176
- name: filter[posts]
177177
required: false
178178
description: Equality filter for "posts"
@@ -496,7 +496,7 @@ paths:
496496
style: form
497497
explode: false
498498
schema:
499-
$ref: '#/components/schemas/Role'
499+
$ref: '#/components/schemas/role'
500500
- name: filter[posts]
501501
required: false
502502
description: Equality filter for "posts"
@@ -513,7 +513,7 @@ paths:
513513
content:
514514
application/vnd.api+json:
515515
schema:
516-
$ref: '#/components/schemas/PostListResponse'
516+
$ref: '#/components/schemas/post_ItemListResponse'
517517
'403':
518518
description: Request is forbidden
519519
content:
@@ -690,7 +690,7 @@ paths:
690690
style: form
691691
explode: false
692692
schema:
693-
$ref: '#/components/schemas/Role'
693+
$ref: '#/components/schemas/role'
694694
- name: filter[posts]
695695
required: false
696696
description: Equality filter for "posts"
@@ -813,12 +813,12 @@ paths:
813813
application/vnd.api+json:
814814
schema:
815815
$ref: '#/components/schemas/_errorResponse'
816-
/post:
816+
/post_Item:
817817
get:
818-
operationId: list-Post
819-
description: List "Post" resources
818+
operationId: list-post_Item
819+
description: List "post_Item" resources
820820
tags:
821-
- post
821+
- post_Item
822822
parameters:
823823
- $ref: '#/components/parameters/include'
824824
- $ref: '#/components/parameters/sort'
@@ -1032,42 +1032,42 @@ paths:
10321032
content:
10331033
application/vnd.api+json:
10341034
schema:
1035-
$ref: '#/components/schemas/PostListResponse'
1035+
$ref: '#/components/schemas/post_ItemListResponse'
10361036
'403':
10371037
description: Request is forbidden
10381038
content:
10391039
application/vnd.api+json:
10401040
schema:
10411041
$ref: '#/components/schemas/_errorResponse'
10421042
post:
1043-
operationId: create-Post
1044-
description: Create a "Post" resource
1043+
operationId: create-post_Item
1044+
description: Create a "post_Item" resource
10451045
tags:
1046-
- post
1046+
- post_Item
10471047
requestBody:
10481048
content:
10491049
application/vnd.api+json:
10501050
schema:
1051-
$ref: '#/components/schemas/PostCreateRequest'
1051+
$ref: '#/components/schemas/post_ItemCreateRequest'
10521052
responses:
10531053
'201':
10541054
description: Successful operation
10551055
content:
10561056
application/vnd.api+json:
10571057
schema:
1058-
$ref: '#/components/schemas/PostResponse'
1058+
$ref: '#/components/schemas/post_ItemResponse'
10591059
'403':
10601060
description: Request is forbidden
10611061
content:
10621062
application/vnd.api+json:
10631063
schema:
10641064
$ref: '#/components/schemas/_errorResponse'
1065-
'/post/{id}':
1065+
'/post_Item/{id}':
10661066
get:
1067-
operationId: fetch-Post
1068-
description: Fetch a "Post" resource
1067+
operationId: fetch-post_Item
1068+
description: Fetch a "post_Item" resource
10691069
tags:
1070-
- post
1070+
- post_Item
10711071
parameters:
10721072
- $ref: '#/components/parameters/id'
10731073
- $ref: '#/components/parameters/include'
@@ -1077,7 +1077,7 @@ paths:
10771077
content:
10781078
application/vnd.api+json:
10791079
schema:
1080-
$ref: '#/components/schemas/PostResponse'
1080+
$ref: '#/components/schemas/post_ItemResponse'
10811081
'403':
10821082
description: Request is forbidden
10831083
content:
@@ -1091,24 +1091,24 @@ paths:
10911091
schema:
10921092
$ref: '#/components/schemas/_errorResponse'
10931093
put:
1094-
operationId: update-Post-put
1095-
description: Update a "Post" resource
1094+
operationId: update-post_Item-put
1095+
description: Update a "post_Item" resource
10961096
tags:
1097-
- post
1097+
- post_Item
10981098
parameters:
10991099
- $ref: '#/components/parameters/id'
11001100
requestBody:
11011101
content:
11021102
application/vnd.api+json:
11031103
schema:
1104-
$ref: '#/components/schemas/PostUpdateRequest'
1104+
$ref: '#/components/schemas/post_ItemUpdateRequest'
11051105
responses:
11061106
'200':
11071107
description: Successful operation
11081108
content:
11091109
application/vnd.api+json:
11101110
schema:
1111-
$ref: '#/components/schemas/PostResponse'
1111+
$ref: '#/components/schemas/post_ItemResponse'
11121112
'403':
11131113
description: Request is forbidden
11141114
content:
@@ -1122,24 +1122,24 @@ paths:
11221122
schema:
11231123
$ref: '#/components/schemas/_errorResponse'
11241124
patch:
1125-
operationId: update-Post-patch
1126-
description: Update a "Post" resource
1125+
operationId: update-post_Item-patch
1126+
description: Update a "post_Item" resource
11271127
tags:
1128-
- post
1128+
- post_Item
11291129
parameters:
11301130
- $ref: '#/components/parameters/id'
11311131
requestBody:
11321132
content:
11331133
application/vnd.api+json:
11341134
schema:
1135-
$ref: '#/components/schemas/PostUpdateRequest'
1135+
$ref: '#/components/schemas/post_ItemUpdateRequest'
11361136
responses:
11371137
'200':
11381138
description: Successful operation
11391139
content:
11401140
application/vnd.api+json:
11411141
schema:
1142-
$ref: '#/components/schemas/PostResponse'
1142+
$ref: '#/components/schemas/post_ItemResponse'
11431143
'403':
11441144
description: Request is forbidden
11451145
content:
@@ -1153,10 +1153,10 @@ paths:
11531153
schema:
11541154
$ref: '#/components/schemas/_errorResponse'
11551155
delete:
1156-
operationId: delete-Post
1157-
description: Delete a "Post" resource
1156+
operationId: delete-post_Item
1157+
description: Delete a "post_Item" resource
11581158
tags:
1159-
- post
1159+
- post_Item
11601160
parameters:
11611161
- $ref: '#/components/parameters/id'
11621162
responses:
@@ -1174,12 +1174,12 @@ paths:
11741174
application/vnd.api+json:
11751175
schema:
11761176
$ref: '#/components/schemas/_errorResponse'
1177-
'/post/{id}/author':
1177+
'/post_Item/{id}/author':
11781178
get:
1179-
operationId: fetch-Post-related-author
1180-
description: Fetch the related "author" resource for "Post"
1179+
operationId: fetch-post_Item-related-author
1180+
description: Fetch the related "author" resource for "post_Item"
11811181
tags:
1182-
- post
1182+
- post_Item
11831183
parameters:
11841184
- $ref: '#/components/parameters/id'
11851185
- $ref: '#/components/parameters/include'
@@ -1202,12 +1202,12 @@ paths:
12021202
application/vnd.api+json:
12031203
schema:
12041204
$ref: '#/components/schemas/_errorResponse'
1205-
'/post/{id}/relationships/author':
1205+
'/post_Item/{id}/relationships/author':
12061206
get:
1207-
operationId: fetch-Post-relationship-author
1208-
description: Fetch the "author" relationships for a "Post"
1207+
operationId: fetch-post_Item-relationship-author
1208+
description: Fetch the "author" relationships for a "post_Item"
12091209
tags:
1210-
- post
1210+
- post_Item
12111211
parameters:
12121212
- $ref: '#/components/parameters/id'
12131213
responses:
@@ -1230,10 +1230,10 @@ paths:
12301230
schema:
12311231
$ref: '#/components/schemas/_errorResponse'
12321232
put:
1233-
operationId: update-Post-relationship-author-put
1234-
description: Update "author" relationship for a "Post"
1233+
operationId: update-post_Item-relationship-author-put
1234+
description: Update "author" relationship for a "post_Item"
12351235
tags:
1236-
- post
1236+
- post_Item
12371237
parameters:
12381238
- $ref: '#/components/parameters/id'
12391239
requestBody:
@@ -1261,10 +1261,10 @@ paths:
12611261
schema:
12621262
$ref: '#/components/schemas/_errorResponse'
12631263
patch:
1264-
operationId: update-Post-relationship-author-patch
1265-
description: Update "author" relationship for a "Post"
1264+
operationId: update-post_Item-relationship-author-patch
1265+
description: Update "author" relationship for a "post_Item"
12661266
tags:
1267-
- post
1267+
- post_Item
12681268
parameters:
12691269
- $ref: '#/components/parameters/id'
12701270
requestBody:
@@ -1503,9 +1503,9 @@ components:
15031503
properties:
15041504
jsonapi:
15051505
$ref: '#/components/schemas/_jsonapi'
1506-
Role:
1506+
role:
15071507
type: string
1508-
description: The "Role" Enum
1508+
description: The "role" Enum
15091509
enum:
15101510
- USER
15111511
- ADMIN
@@ -1533,7 +1533,7 @@ components:
15331533
email:
15341534
type: string
15351535
role:
1536-
$ref: '#/components/schemas/Role'
1536+
$ref: '#/components/schemas/role'
15371537
relationships:
15381538
type: object
15391539
properties:
@@ -1572,7 +1572,7 @@ components:
15721572
email:
15731573
type: string
15741574
role:
1575-
$ref: '#/components/schemas/Role'
1575+
$ref: '#/components/schemas/role'
15761576
relationships:
15771577
type: object
15781578
properties:
@@ -1610,7 +1610,7 @@ components:
16101610
email:
16111611
type: string
16121612
role:
1613-
$ref: '#/components/schemas/Role'
1613+
$ref: '#/components/schemas/role'
16141614
relationships:
16151615
type: object
16161616
properties:
@@ -1673,9 +1673,9 @@ components:
16731673
allOf:
16741674
- $ref: '#/components/schemas/_links'
16751675
- $ref: '#/components/schemas/_pagination'
1676-
Post:
1676+
post_Item:
16771677
type: object
1678-
description: The "Post" model
1678+
description: The "post_Item" model
16791679
required:
16801680
- id
16811681
- type
@@ -1707,15 +1707,15 @@ components:
17071707
properties:
17081708
author:
17091709
$ref: '#/components/schemas/_toOneRelationshipWithLinks'
1710-
PostCreateRequest:
1710+
post_ItemCreateRequest:
17111711
type: object
1712-
description: Input for creating a "Post"
1712+
description: Input for creating a "post_Item"
17131713
required:
17141714
- data
17151715
properties:
17161716
data:
17171717
type: object
1718-
description: The "Post" model
1718+
description: The "post_Item" model
17191719
required:
17201720
- id
17211721
- type
@@ -1752,15 +1752,15 @@ components:
17521752
$ref: '#/components/schemas/_toOneRelationship'
17531753
meta:
17541754
$ref: '#/components/schemas/_meta'
1755-
PostUpdateRequest:
1755+
post_ItemUpdateRequest:
17561756
type: object
1757-
description: Input for updating a "Post"
1757+
description: Input for updating a "post_Item"
17581758
required:
17591759
- data
17601760
properties:
17611761
data:
17621762
type: object
1763-
description: The "Post" model
1763+
description: The "post_Item" model
17641764
required:
17651765
- id
17661766
- type
@@ -1794,17 +1794,17 @@ components:
17941794
$ref: '#/components/schemas/_toOneRelationship'
17951795
meta:
17961796
$ref: '#/components/schemas/_meta'
1797-
PostResponse:
1797+
post_ItemResponse:
17981798
type: object
1799-
description: Response for a "Post"
1799+
description: Response for a "post_Item"
18001800
required:
18011801
- data
18021802
properties:
18031803
jsonapi:
18041804
$ref: '#/components/schemas/_jsonapi'
18051805
data:
18061806
allOf:
1807-
- $ref: '#/components/schemas/Post'
1807+
- $ref: '#/components/schemas/post_Item'
18081808
- type: object
18091809
properties:
18101810
relationships:
@@ -1820,9 +1820,9 @@ components:
18201820
$ref: '#/components/schemas/_resource'
18211821
links:
18221822
$ref: '#/components/schemas/_links'
1823-
PostListResponse:
1823+
post_ItemListResponse:
18241824
type: object
1825-
description: Response for a list of "Post"
1825+
description: Response for a list of "post_Item"
18261826
required:
18271827
- data
18281828
- links
@@ -1833,7 +1833,7 @@ components:
18331833
type: array
18341834
items:
18351835
allOf:
1836-
- $ref: '#/components/schemas/Post'
1836+
- $ref: '#/components/schemas/post_Item'
18371837
- type: object
18381838
properties:
18391839
relationships:

0 commit comments

Comments
 (0)