Skip to content

Commit

Permalink
fix(oas): add missing x-codegen + fix schema naming and $ref (#3312)
Browse files Browse the repository at this point in the history
## What

Add missing x-codegen + fix schema naming and $ref 

## Why

OAS code generator was missing information to be able to match current JS client.

## How

Ensure OAS matches JS client methods.
  • Loading branch information
patrick-medusajs authored Feb 22, 2023
1 parent 287c829 commit 935870e
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 17 deletions.
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
* 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
* 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
* 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/AdminReservationsListRes"
* "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
* type: object
* required:
* - reservation
Expand All @@ -69,7 +69,7 @@ export type AdminReservationsRes = {
}

/**
* @schema AdminGetReservationReservationsReq
* @schema AdminReservationsListRes
* 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
* 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

0 comments on commit 935870e

Please sign in to comment.