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
feat(oas): declare x-codegen on Admin routes - D to PRI #3092
Conversation
🦋 Changeset detectedLatest commit: bce77ab The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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
* x-codegen: | ||
* method: create |
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.
medusa/packages/medusa-js/src/resources/admin/gift-cards.ts
Lines 17 to 20 in 75f9c7a
create( | |
payload: AdminPostGiftCardsReq, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<AdminGiftCardsRes> { |
* x-codegen: | ||
* method: delete |
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.
medusa/packages/medusa-js/src/resources/admin/gift-cards.ts
Lines 40 to 43 in 75f9c7a
delete( | |
id: string, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<AdminGiftCardsDeleteRes> { |
* x-codegen: | ||
* method: retrieve |
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.
medusa/packages/medusa-js/src/resources/admin/gift-cards.ts
Lines 51 to 54 in 75f9c7a
retrieve( | |
id: string, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<AdminGiftCardsRes> { |
* x-codegen: | ||
* method: list | ||
* queryParams: AdminGetGiftCardsParams |
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.
medusa/packages/medusa-js/src/resources/admin/gift-cards.ts
Lines 62 to 65 in 75f9c7a
list( | |
query?: AdminGetGiftCardsParams, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<AdminGiftCardsListRes> { |
* x-codegen: | ||
* method: update |
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.
medusa/packages/medusa-js/src/resources/admin/gift-cards.ts
Lines 28 to 32 in 75f9c7a
update( | |
id: string, | |
payload: AdminPostGiftCardsGiftCardReq, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<AdminGiftCardsRes> { |
* x-codegen: | ||
* method: deleteVariantPrices |
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.
medusa/packages/medusa-js/src/resources/admin/price-lists.ts
Lines 107 to 111 in 75f9c7a
deleteVariantPrices( | |
priceListId: string, | |
variantId: string, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<AdminPriceListDeleteBatchRes> { |
* x-codegen: | ||
* method: retrieve |
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.
medusa/packages/medusa-js/src/resources/admin/price-lists.ts
Lines 43 to 46 in 75f9c7a
retrieve( | |
id: string, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<AdminPriceListRes> { |
* x-codegen: | ||
* method: listProducts | ||
* queryParams: AdminGetPriceListsPriceListProductsParams |
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.
medusa/packages/medusa-js/src/resources/admin/price-lists.ts
Lines 65 to 69 in 75f9c7a
listProducts( | |
id: string, | |
query?: AdminGetPriceListsPriceListProductsParams, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<any> { |
* x-codegen: | ||
* method: list | ||
* queryParams: AdminGetPriceListPaginationParams |
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.
medusa/packages/medusa-js/src/resources/admin/price-lists.ts
Lines 51 to 54 in 75f9c7a
list( | |
query?: AdminGetPriceListPaginationParams, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<AdminPriceListsListRes> { |
* x-codegen: | ||
* method: update |
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.
medusa/packages/medusa-js/src/resources/admin/price-lists.ts
Lines 26 to 30 in 75f9c7a
update( | |
id: string, | |
payload: AdminPostPriceListsPriceListPriceListReq, | |
customHeaders: Record<string, any> = {} | |
): ResponsePromise<AdminPriceListRes> { |
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
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
What
Declare
x-codegen
in OAS for Admin routes - D to PRI.Why
We are introducing a new
x-codegen
OpenApi extension, also known as vendor extension, in order to help with passing information down to code generators.In our case, we wish to declare the
method
name that we would expect to call on a client. This mimics our current JS client package.E.g.
medusaClient.product.list
whereproduct
is the tag of the route andlist
is the x-codegen.method value.We are also defining the name of a potential typed object for query parameters. OAS 3.0 does not allow to bundle query parameters under a single definition but it is not uncommon to see API clients handle all query parameters as a single typed object, like our JS client package. With x-codegen.queryParams, a code generator can create a named and typed object to bundle all query parameters for a given route.
E.g.
medusaClient.customer.retrieve(id: string, queryParams: AdminGetCustomerParams)
How
Declare
x-codegen
as an object with fieldsmethod
andqueryParams
on all paths.Match method and queryParams values with equivalent ones from our current JS client package.
Test
Expect no visible changes to the documentation.