Skip to content

Commit

Permalink
fix: bugs related to model name casing (zenstackhq#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Aug 23, 2023
1 parent d8c2e87 commit 32d5b26
Show file tree
Hide file tree
Showing 23 changed files with 703 additions and 617 deletions.
1 change: 1 addition & 0 deletions packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"lower-case-first": "^2.0.2",
"openapi-types": "^12.1.0",
"tiny-invariant": "^1.3.1",
"upper-case-first": "^2.0.2",
"yaml": "^2.2.1",
"zod": "3.21.1",
"zod-validation-error": "^0.2.1"
Expand Down
172 changes: 88 additions & 84 deletions packages/plugins/openapi/src/rpc-generator.ts

Large diffs are not rendered by default.

132 changes: 66 additions & 66 deletions packages/plugins/openapi/tests/baseline/rest.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ info:
tags:
- name: user
description: User operations
- name: post
- name: post_Item
description: Post-related operations
paths:
/user:
Expand Down Expand Up @@ -172,7 +172,7 @@ paths:
style: form
explode: false
schema:
$ref: '#/components/schemas/Role'
$ref: '#/components/schemas/role'
- name: filter[posts]
required: false
description: Equality filter for "posts"
Expand Down Expand Up @@ -496,7 +496,7 @@ paths:
style: form
explode: false
schema:
$ref: '#/components/schemas/Role'
$ref: '#/components/schemas/role'
- name: filter[posts]
required: false
description: Equality filter for "posts"
Expand All @@ -513,7 +513,7 @@ paths:
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/PostListResponse'
$ref: '#/components/schemas/post_ItemListResponse'
'403':
description: Request is forbidden
content:
Expand Down Expand Up @@ -690,7 +690,7 @@ paths:
style: form
explode: false
schema:
$ref: '#/components/schemas/Role'
$ref: '#/components/schemas/role'
- name: filter[posts]
required: false
description: Equality filter for "posts"
Expand Down Expand Up @@ -813,12 +813,12 @@ paths:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/_errorResponse'
/post:
/post_Item:
get:
operationId: list-Post
description: List "Post" resources
operationId: list-post_Item
description: List "post_Item" resources
tags:
- post
- post_Item
parameters:
- $ref: '#/components/parameters/include'
- $ref: '#/components/parameters/sort'
Expand Down Expand Up @@ -1032,42 +1032,42 @@ paths:
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/PostListResponse'
$ref: '#/components/schemas/post_ItemListResponse'
'403':
description: Request is forbidden
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/_errorResponse'
post:
operationId: create-Post
description: Create a "Post" resource
operationId: create-post_Item
description: Create a "post_Item" resource
tags:
- post
- post_Item
requestBody:
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/PostCreateRequest'
$ref: '#/components/schemas/post_ItemCreateRequest'
responses:
'201':
description: Successful operation
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/PostResponse'
$ref: '#/components/schemas/post_ItemResponse'
'403':
description: Request is forbidden
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/_errorResponse'
'/post/{id}':
'/post_Item/{id}':
get:
operationId: fetch-Post
description: Fetch a "Post" resource
operationId: fetch-post_Item
description: Fetch a "post_Item" resource
tags:
- post
- post_Item
parameters:
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/include'
Expand All @@ -1077,7 +1077,7 @@ paths:
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/PostResponse'
$ref: '#/components/schemas/post_ItemResponse'
'403':
description: Request is forbidden
content:
Expand All @@ -1091,24 +1091,24 @@ paths:
schema:
$ref: '#/components/schemas/_errorResponse'
put:
operationId: update-Post-put
description: Update a "Post" resource
operationId: update-post_Item-put
description: Update a "post_Item" resource
tags:
- post
- post_Item
parameters:
- $ref: '#/components/parameters/id'
requestBody:
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/PostUpdateRequest'
$ref: '#/components/schemas/post_ItemUpdateRequest'
responses:
'200':
description: Successful operation
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/PostResponse'
$ref: '#/components/schemas/post_ItemResponse'
'403':
description: Request is forbidden
content:
Expand All @@ -1122,24 +1122,24 @@ paths:
schema:
$ref: '#/components/schemas/_errorResponse'
patch:
operationId: update-Post-patch
description: Update a "Post" resource
operationId: update-post_Item-patch
description: Update a "post_Item" resource
tags:
- post
- post_Item
parameters:
- $ref: '#/components/parameters/id'
requestBody:
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/PostUpdateRequest'
$ref: '#/components/schemas/post_ItemUpdateRequest'
responses:
'200':
description: Successful operation
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/PostResponse'
$ref: '#/components/schemas/post_ItemResponse'
'403':
description: Request is forbidden
content:
Expand All @@ -1153,10 +1153,10 @@ paths:
schema:
$ref: '#/components/schemas/_errorResponse'
delete:
operationId: delete-Post
description: Delete a "Post" resource
operationId: delete-post_Item
description: Delete a "post_Item" resource
tags:
- post
- post_Item
parameters:
- $ref: '#/components/parameters/id'
responses:
Expand All @@ -1174,12 +1174,12 @@ paths:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/_errorResponse'
'/post/{id}/author':
'/post_Item/{id}/author':
get:
operationId: fetch-Post-related-author
description: Fetch the related "author" resource for "Post"
operationId: fetch-post_Item-related-author
description: Fetch the related "author" resource for "post_Item"
tags:
- post
- post_Item
parameters:
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/include'
Expand All @@ -1202,12 +1202,12 @@ paths:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/_errorResponse'
'/post/{id}/relationships/author':
'/post_Item/{id}/relationships/author':
get:
operationId: fetch-Post-relationship-author
description: Fetch the "author" relationships for a "Post"
operationId: fetch-post_Item-relationship-author
description: Fetch the "author" relationships for a "post_Item"
tags:
- post
- post_Item
parameters:
- $ref: '#/components/parameters/id'
responses:
Expand All @@ -1230,10 +1230,10 @@ paths:
schema:
$ref: '#/components/schemas/_errorResponse'
put:
operationId: update-Post-relationship-author-put
description: Update "author" relationship for a "Post"
operationId: update-post_Item-relationship-author-put
description: Update "author" relationship for a "post_Item"
tags:
- post
- post_Item
parameters:
- $ref: '#/components/parameters/id'
requestBody:
Expand Down Expand Up @@ -1261,10 +1261,10 @@ paths:
schema:
$ref: '#/components/schemas/_errorResponse'
patch:
operationId: update-Post-relationship-author-patch
description: Update "author" relationship for a "Post"
operationId: update-post_Item-relationship-author-patch
description: Update "author" relationship for a "post_Item"
tags:
- post
- post_Item
parameters:
- $ref: '#/components/parameters/id'
requestBody:
Expand Down Expand Up @@ -1503,9 +1503,9 @@ components:
properties:
jsonapi:
$ref: '#/components/schemas/_jsonapi'
Role:
role:
type: string
description: The "Role" Enum
description: The "role" Enum
enum:
- USER
- ADMIN
Expand Down Expand Up @@ -1533,7 +1533,7 @@ components:
email:
type: string
role:
$ref: '#/components/schemas/Role'
$ref: '#/components/schemas/role'
relationships:
type: object
properties:
Expand Down Expand Up @@ -1572,7 +1572,7 @@ components:
email:
type: string
role:
$ref: '#/components/schemas/Role'
$ref: '#/components/schemas/role'
relationships:
type: object
properties:
Expand Down Expand Up @@ -1610,7 +1610,7 @@ components:
email:
type: string
role:
$ref: '#/components/schemas/Role'
$ref: '#/components/schemas/role'
relationships:
type: object
properties:
Expand Down Expand Up @@ -1673,9 +1673,9 @@ components:
allOf:
- $ref: '#/components/schemas/_links'
- $ref: '#/components/schemas/_pagination'
Post:
post_Item:
type: object
description: The "Post" model
description: The "post_Item" model
required:
- id
- type
Expand Down Expand Up @@ -1707,15 +1707,15 @@ components:
properties:
author:
$ref: '#/components/schemas/_toOneRelationshipWithLinks'
PostCreateRequest:
post_ItemCreateRequest:
type: object
description: Input for creating a "Post"
description: Input for creating a "post_Item"
required:
- data
properties:
data:
type: object
description: The "Post" model
description: The "post_Item" model
required:
- id
- type
Expand Down Expand Up @@ -1752,15 +1752,15 @@ components:
$ref: '#/components/schemas/_toOneRelationship'
meta:
$ref: '#/components/schemas/_meta'
PostUpdateRequest:
post_ItemUpdateRequest:
type: object
description: Input for updating a "Post"
description: Input for updating a "post_Item"
required:
- data
properties:
data:
type: object
description: The "Post" model
description: The "post_Item" model
required:
- id
- type
Expand Down Expand Up @@ -1794,17 +1794,17 @@ components:
$ref: '#/components/schemas/_toOneRelationship'
meta:
$ref: '#/components/schemas/_meta'
PostResponse:
post_ItemResponse:
type: object
description: Response for a "Post"
description: Response for a "post_Item"
required:
- data
properties:
jsonapi:
$ref: '#/components/schemas/_jsonapi'
data:
allOf:
- $ref: '#/components/schemas/Post'
- $ref: '#/components/schemas/post_Item'
- type: object
properties:
relationships:
Expand All @@ -1820,9 +1820,9 @@ components:
$ref: '#/components/schemas/_resource'
links:
$ref: '#/components/schemas/_links'
PostListResponse:
post_ItemListResponse:
type: object
description: Response for a list of "Post"
description: Response for a list of "post_Item"
required:
- data
- links
Expand All @@ -1833,7 +1833,7 @@ components:
type: array
items:
allOf:
- $ref: '#/components/schemas/Post'
- $ref: '#/components/schemas/post_Item'
- type: object
properties:
relationships:
Expand Down
Loading

0 comments on commit 32d5b26

Please sign in to comment.