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

fix(oas): add missing x-codegen + fix schema naming and $ref #3312

Merged
merged 4 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-horses-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

fix(oas): add missing x-codegen + fix schema naming and $ref
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { joinLevels } from "./utils/join-levels"
* - (path) id=* {string} The ID of the Inventory Item.
* - (query) expand {string} Comma separated list of relations to include in the results.
* - (query) fields {string} Comma separated list of fields to include in the results.
* x-codegen:
* method: retrieve
* queryParams: AdminGetInventoryItemsItemParams
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(
inventoryItemId: string,
query?: AdminGetInventoryItemsItemParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsRes> {

* x-codeSamples:
* - lang: JavaScript
* label: JS Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ import { AdminInventoryItemsListWithVariantsAndLocationLevelsRes } from "."
* - (query) height {string} height to search for.
* - (query) width {string} width to search for.
* - (query) requires_shipping {string} requires_shipping to search for.
* x-codegen:
* method: list
* queryParams: AdminGetInventoryItemsParams
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?: AdminGetInventoryItemsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsListWithVariantsAndLocationLevelsRes> {

* x-codeSamples:
* - lang: JavaScript
* label: JS Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { FindParams } from "../../../../types/common"
* - (query) limit=20 {integer} Limit the number of stock locations levels returned.
* - (query) expand {string} Comma separated list of relations to include in the results.
* - (query) fields {string} Comma separated list of fields to include in the results.
* x-codegen:
* method: listLocationLevels
* queryParams: AdminGetInventoryItemsItemLocationLevelsParams
Copy link
Contributor Author

Choose a reason for hiding this comment

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

listLocationLevels(
inventoryItemId: string,
query?: AdminGetInventoryItemsItemLocationLevelsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsLocationLevelsRes> {

* x-codeSamples:
* - lang: JavaScript
* label: JS Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { extendedFindParamsMixin } from "../../../../types/common"
* content:
* application/json:
* schema:
* $ref: "#/components/schemas/AdminGetReservationReservationsReq"
* $ref: "#/components/schemas/AdminReservationsRes"
Copy link
Member

Choose a reason for hiding this comment

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

This should be AdminReservationsListRes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch 🎣 . Done in efda8f4

* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { IInventoryService } from "../../../../interfaces"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Reservation to delete.
* x-codegen:
* method: delete
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
Expand Down Expand Up @@ -36,19 +38,7 @@ import { IInventoryService } from "../../../../interfaces"
* content:
* application/json:
* schema:
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Reservation.
* object:
* type: string
* description: The type of the object that was deleted.
* default: reservation
* deleted:
* type: boolean
* description: Whether or not the Reservation was deleted.
* default: true
* $ref: "#/components/schemas/AdminReservationsDeleteRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
24 changes: 22 additions & 2 deletions packages/medusa/src/api/routes/admin/reservations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default (app) => {
}

/**
* @schema AdminPostReservationsReq
* @schema AdminReservationsRes
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: schema name was not matching type name

* type: object
* required:
* - reservation
Expand All @@ -69,7 +69,7 @@ export type AdminReservationsRes = {
}

/**
* @schema AdminGetReservationReservationsReq
* @schema AdminReservationsListRes
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: schema name was not matching type name

* type: object
* required:
* - reservations
Expand Down Expand Up @@ -108,6 +108,26 @@ export const defaultReservationFields = [
"updated_at",
]

/**
* @schema AdminReservationsDeleteRes
* type: object
* required:
* - id
* - object
* - deleted
* properties:
* id:
* type: string
* description: The ID of the deleted Reservation.
* object:
* type: string
* description: The type of the object that was deleted.
* default: reservation
* deleted:
* type: boolean
* description: Whether or not the Reservation was deleted.
* default: true
*/
export type AdminReservationsDeleteRes = DeleteResponse

export * from "./create-reservation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ import {
* - (query) limit=20 {integer} Limit the number of Reservations returned.
* - (query) expand {string} (Comma separated) Which fields should be expanded in the product category.
* - (query) fields {string} (Comma separated) Which fields should be included in the product category.
* x-codegen:
* method: list
* queryParams: AdminGetReservationsParams
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?: AdminGetReservationsParams,
customHeaders: Record<string, unknown> = {}
): ResponsePromise<AdminReservationsListRes> {

* x-codeSamples:
* - lang: Shell
* label: cURL
Expand All @@ -80,7 +83,7 @@ import {
* content:
* application/json:
* schema:
* $ref: "#/components/schemas/AdminGetReservationReservationsReq"
* $ref: "#/components/schemas/AdminReservationsListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down