-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(oas): replace response with $ref class JSDoc (Admin O-PRI) #3018
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self-review: highlighting noteworthy code changes.
* object: | ||
* type: string | ||
* description: The type of the object that was deleted. | ||
* default: item_change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced format
with default
for consistency's sake.
* object: | ||
* type: string | ||
* description: The type of the object that was deleted. | ||
* default: order_edit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced format
with default
for consistency's sake.
export type AdminOrdersRes = { | ||
order: Order | ||
} | ||
|
||
export type AdminDeleteRes = DeleteResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too generic, plus could not find any usage in the codebase.
* type: integer | ||
* description: The number of items per page | ||
*/ | ||
export type AdminPriceListsProductsListRes = PaginatedResponse & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing declaration for admin/price-lists/list-price-list-products.ts
.
JS client has response typed as any
. See file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some small comments 🙂
* properties: | ||
* order_edits: | ||
* type: array | ||
* $ref: "#/components/schemas/OrderEdit" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original OAS for this one seems to be incorrect. This should be under the items
property since order_edits
is an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Fixed in 5d88100
* type: boolean | ||
* description: Whether or not the items were deleted. | ||
* default: true | ||
*/ | ||
export type AdminPriceListDeleteBatchRes = { | ||
ids: string[] | ||
deleted: boolean | ||
object: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to OAS and isn't necessarily something that should be looked into in this PR: seems like there is an inconsistency across different files in how this type of response is defined. In some places, the default value is set within the type definition (for example, object: 'payment_collection'
) whereas in other places like here the type is generic. Maybe this is something to take into account if we want to automatically generate OAS comments in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. I believe that latest approach is to declare object:
as a constant. The way to do it in OAS would be to declare object
as the following:
object:
- type: string
- description: The type of the object that was deleted.
- enum: [money-amount]
- default: money-amount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Scope
Admin routes directories O to PRI.
What
Move inline OAS response schema declaration under their respective class declarations in order to expose them through
#/components/schemas
. Replace inline OAS response schema with a$ref
reference pointing to the newly declared schema.Why
Having response declared as its own "named" schema will allow OAS code generators to output typed entities/DTO that can be consumed without having to reference the route/operation.
How
Declare a new @Schema JSDoc for each "Res" class used to parse and validate request body. Move the current inline requestBody to the new @Schema.
Test
Expect no visible changes to the documentation.