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

chore(oas): replace response with $ref to res class JSDoc OAS (Admin A-C) #3002

Merged
merged 2 commits into from
Jan 12, 2023

Conversation

patrick-medusajs
Copy link
Contributor

Scope

Admin routes directories A to C.

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

  • Ran OAS validator.
  • Ran docs build script.

Expect no visible changes to the documentation.

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

changeset-bot bot commented Jan 11, 2023

⚠️ No Changeset found

Latest commit: e7be6ba

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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.

export type AdminBatchJobRes = {
batch_job: BatchJob
}

export type AdminBatchJobDeleteRes = DeleteResponse
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't find usage in codebase. Delete operation not implemented.

Copy link
Member

Choose a reason for hiding this comment

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

indeed, it is mostly for consistency if the client lib want to use it

Comment on lines +130 to +134
export type AdminDeleteProductsFromCollectionRes = {
id: string
object: string
removed_products: string[]
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

admin/collections/remove-products.ts response shape had not equivalent class declared.

Our JS client is wrongfully typed with AdminCollectionsDeleteRes. See file.

* limit:
* type: integer
* description: The number of items per page
* $ref: "#/components/schemas/AdminCustomersListRes"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this endpoint references a response shape from admin/customers/ and not admin/customer-groups/ since it returns a list of customers.

export type AdminCustomersRes = {
customer: Customer
}

export type AdminCustomersDeleteRes = DeleteResponse
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't find usage in codebase. Delete operation not implemented.

@patrick-medusajs patrick-medusajs marked this pull request as ready for review January 11, 2023 21:13
@patrick-medusajs patrick-medusajs requested a review from a team as a code owner January 11, 2023 21:13
Copy link
Contributor

@riqwan riqwan left a comment

Choose a reason for hiding this comment

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

lgtm! 🎉 would get a second pair of eyes on this tho.

Copy link
Contributor

@fPolic fPolic left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

Looping in @shahednasser for final sign off 💪

Copy link
Member

@adrien2p adrien2p left a comment

Choose a reason for hiding this comment

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

LGTM

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!

Copy link
Contributor

@pKorsholm pKorsholm left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

Hehe should be good to merge! 😄

@olivermrbl olivermrbl merged commit d10ffa8 into develop Jan 12, 2023
@olivermrbl olivermrbl deleted the chore/oas-response-schema-AtoC branch January 12, 2023 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants