Skip to content
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

Merged
merged 4 commits into from Jan 24, 2023

Conversation

patrick-medusajs
Copy link
Contributor

@patrick-medusajs patrick-medusajs commented Jan 23, 2023

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 where product is the tag of the route and list 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 fields method and queryParams on all paths.

Match method and queryParams values with equivalent ones from our current JS client package.

Test

  • Ran OAS validator.
  • Ran docs build script.

Expect no visible changes to the documentation.

@patrick-medusajs patrick-medusajs self-assigned this Jan 23, 2023
@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2023

🦋 Changeset detected

Latest commit: bce77ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@medusajs/medusa Patch
@medusajs/inventory Patch

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

Copy link
Contributor Author

@patrick-medusajs patrick-medusajs left a 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

Comment on lines +19 to +20
* x-codegen:
* method: create
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create(
payload: AdminPostGiftCardsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminGiftCardsRes> {

Comment on lines +11 to +12
* x-codegen:
* method: delete
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete(
id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminGiftCardsDeleteRes> {

Comment on lines +11 to +12
* x-codegen:
* method: retrieve
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retrieve(
id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminGiftCardsRes> {

Comment on lines +19 to +21
* x-codegen:
* method: list
* queryParams: AdminGetGiftCardsParams
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list(
query?: AdminGetGiftCardsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminGiftCardsListRes> {

Comment on lines +22 to +23
* x-codegen:
* method: update
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update(
id: string,
payload: AdminPostGiftCardsGiftCardReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminGiftCardsRes> {

Comment on lines +13 to +14
* x-codegen:
* method: deleteVariantPrices
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleteVariantPrices(
priceListId: string,
variantId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminPriceListDeleteBatchRes> {

Comment on lines +14 to +15
* x-codegen:
* method: retrieve
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retrieve(
id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminPriceListRes> {

Comment on lines +136 to +138
* x-codegen:
* method: listProducts
* queryParams: AdminGetPriceListsPriceListProductsParams
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listProducts(
id: string,
query?: AdminGetPriceListsPriceListProductsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<any> {

Comment on lines +117 to +119
* x-codegen:
* method: list
* queryParams: AdminGetPriceListPaginationParams
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list(
query?: AdminGetPriceListPaginationParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminPriceListsListRes> {

Comment on lines +37 to +38
* x-codegen:
* method: update
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update(
id: string,
payload: AdminPostPriceListsPriceListPriceListReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminPriceListRes> {

Copy link
Contributor Author

@patrick-medusajs patrick-medusajs left a 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

@patrick-medusajs patrick-medusajs changed the title feat(oas): declare x-codegen on Admin routes - G to PRI feat(oas): declare x-codegen on Admin routes - D to PRI Jan 23, 2023
@patrick-medusajs patrick-medusajs marked this pull request as ready for review January 23, 2023 20:18
@patrick-medusajs patrick-medusajs requested a review from a team as a code owner January 23, 2023 20:18
@patrick-medusajs patrick-medusajs requested review from shahednasser and a team January 23, 2023 20:18
Copy link
Member

@shahednasser shahednasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kodiakhq kodiakhq bot merged commit 8e41c69 into develop Jan 24, 2023
@kodiakhq kodiakhq bot deleted the feat/oas-x-codegen-admin-DtoPRI branch January 24, 2023 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants