Skip to content

Commit

Permalink
Merge branch 'develop' into fix/totals-service-custom-item
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl authored Jan 16, 2023
2 parents 4915574 + 27a29ef commit 62bdd87
Show file tree
Hide file tree
Showing 54 changed files with 329 additions and 302 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-mails-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

chore(oas): replace response with $ref class JSDoc (Admin SHI-V)
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* shipping_option:
* $ref: "#/components/schemas/ShippingOption"
* $ref: "#/components/schemas/AdminShippingOptionsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Shipping Option.
* object:
* type: string
* description: The type of the object that was deleted.
* default: shipping-option
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
* $ref: "#/components/schemas/AdminShippingOptionsDeleteRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
* content:
* application/json:
* schema:
* type: object
* properties:
* shipping_option:
* $ref: "#/components/schemas/ShippingOption"
* $ref: "#/components/schemas/AdminShippingOptionsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
37 changes: 36 additions & 1 deletion packages/medusa/src/api/routes/admin/shipping-options/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Router } from "express"
import { ShippingOption } from "../../../.."
import { PaginatedResponse, DeleteResponse } from "../../../../types/common"
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
import middlewares from "../../../middlewares"
import { FlagRouter } from "../../../../utils/flag-router"
import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/tax-inclusive-pricing"
Expand Down Expand Up @@ -52,14 +52,49 @@ export const defaultFields = [

export const defaultRelations = ["region", "profile", "requirements"]

/**
* @schema AdminShippingOptionsListRes
* type: object
* properties:
* shipping_options:
* type: array
* items:
* $ref: "#/components/schemas/ShippingOption"
* count:
* type: integer
* description: The total number of items available
*/
export type AdminShippingOptionsListRes = PaginatedResponse & {
shipping_options: ShippingOption[]
}

/**
* @schema AdminShippingOptionsRes
* type: object
* properties:
* shipping_option:
* $ref: "#/components/schemas/ShippingOption"
*/
export type AdminShippingOptionsRes = {
shipping_option: ShippingOption
}

/**
* @schema AdminShippingOptionsDeleteRes
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Shipping Option.
* object:
* type: string
* description: The type of the object that was deleted.
* default: shipping-option
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
*/
export type AdminShippingOptionsDeleteRes = DeleteResponse

export * from "./create-shipping-option"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* shipping_options:
* type: array
* items:
* $ref: "#/components/schemas/ShippingOption"
* count:
* type: integer
* description: The total number of items available
* $ref: "#/components/schemas/AdminShippingOptionsListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ import { validator } from "../../../../utils/validator"
* content:
* application/json:
* schema:
* type: object
* properties:
* shipping_option:
* $ref: "#/components/schemas/ShippingOption"
* $ref: "#/components/schemas/AdminShippingOptionsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* shipping_profile:
* $ref: "#/components/schemas/ShippingProfile"
* $ref: "#/components/schemas/AdminShippingProfilesRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,7 @@ import { ShippingProfileService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Shipping Profile.
* object:
* type: string
* description: The type of the object that was deleted.
* default: shipping_profile
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
* $ref: "#/components/schemas/AdminDeleteShippingProfileRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ import { ShippingProfileService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* shipping_profile:
* $ref: "#/components/schemas/ShippingProfile"
* $ref: "#/components/schemas/AdminShippingProfilesRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
36 changes: 34 additions & 2 deletions packages/medusa/src/api/routes/admin/shipping-profiles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,47 @@ export const defaultAdminShippingProfilesFields: (keyof ShippingProfile)[] = [
"metadata",
]

export type AdminDeleteShippingProfileRes = DeleteResponse

export const defaultAdminShippingProfilesRelations: (keyof ShippingProfile)[] =
["products", "shipping_options"]

/**
* @schema AdminDeleteShippingProfileRes
* type: object
* properties:
* id:
* type: string
* description: The ID of the deleted Shipping Profile.
* object:
* type: string
* description: The type of the object that was deleted.
* default: shipping_profile
* deleted:
* type: boolean
* description: Whether or not the items were deleted.
* default: true
*/
export type AdminDeleteShippingProfileRes = DeleteResponse

/**
* @schema AdminShippingProfilesRes
* type: object
* properties:
* shipping_profile:
* $ref: "#/components/schemas/ShippingProfile"
*/
export type AdminShippingProfilesRes = {
shipping_profile: ShippingProfile
}

/**
* @schema AdminShippingProfilesListRes
* type: object
* properties:
* shipping_profiles:
* type: array
* items:
* $ref: "#/components/schemas/ShippingProfile"
*/
export type AdminShippingProfilesListRes = {
shipping_profiles: ShippingProfile[]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ import { ShippingProfileService } from "../../../../services"
* content:
* application/json:
* schema:
* type: object
* properties:
* shipping_profiles:
* type: array
* items:
* $ref: "#/components/schemas/ShippingProfile"
* $ref: "#/components/schemas/AdminShippingProfilesListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* shipping_profile:
* $ref: "#/components/schemas/ShippingProfile"
* $ref: "#/components/schemas/AdminShippingProfilesRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Request, Response } from "express"
import { Type } from "class-transformer"
import { ValidateNested, IsOptional, IsString, IsObject } from "class-validator"
import { IsObject, IsOptional, IsString, ValidateNested } from "class-validator"

import { IStockLocationService } from "../../../../interfaces"
import { FindParams } from "../../../../types/common"
Expand Down Expand Up @@ -53,10 +53,7 @@ import { FindParams } from "../../../../types/common"
* content:
* application/json:
* schema:
* type: object
* properties:
* stock_location:
* $ref: "#/components/schemas/StockLocationDTO"
* $ref: "#/components/schemas/AdminStockLocationsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ import { FindParams } from "../../../../types/common"
* content:
* application/json:
* schema:
* type: object
* properties:
* stock_location:
* $ref: "#/components/schemas/StockLocationDTO"
* $ref: "#/components/schemas/AdminStockLocationsRes"
*/
export default async (req: Request, res: Response) => {
const { id } = req.params
Expand Down
29 changes: 26 additions & 3 deletions packages/medusa/src/api/routes/admin/stock-locations/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Router } from "express"
import "reflect-metadata"
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
import { PaginatedResponse } from "../../../../types/common"
import { StockLocationDTO } from "../../../../types/stock-location"
import middlewares, {
transformBody,
Expand Down Expand Up @@ -85,12 +85,35 @@ export const defaultAdminStockLocationFields: (keyof StockLocationDTO)[] = [

export const defaultAdminStockLocationRelations = []

/**
* @schema AdminStockLocationsRes
* type: object
* properties:
* stock_location:
* $ref: "#/components/schemas/StockLocationDTO"
*/
export type AdminStockLocationsRes = {
stock_location: StockLocationDTO
}

export type AdminStockLocationsDeleteRes = DeleteResponse

/**
* @schema AdminStockLocationsListRes
* type: object
* properties:
* stock_locations:
* type: array
* items:
* $ref: "#/components/schemas/StockLocationDTO"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
*/
export type AdminStockLocationsListRes = PaginatedResponse & {
stock_locations: StockLocationDTO[]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,7 @@ import { Request, Response } from "express"
* content:
* application/json:
* schema:
* type: object
* properties:
* stock_locations:
* type: array
* items:
* $ref: "#/components/schemas/StockLocationDTO"
* count:
* type: integer
* description: The total number of items available
* offset:
* type: integer
* description: The number of items skipped before these items
* limit:
* type: integer
* description: The number of items per page
* $ref: "#/components/schemas/AdminStockLocationsListRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Request, Response } from "express"
import { Type } from "class-transformer"
import { ValidateNested, IsOptional, IsString, IsObject } from "class-validator"
import { IsObject, IsOptional, IsString, ValidateNested } from "class-validator"

import { IStockLocationService } from "../../../../interfaces"
import { FindParams } from "../../../../types/common"
Expand Down Expand Up @@ -53,10 +53,7 @@ import { FindParams } from "../../../../types/common"
* content:
* application/json:
* schema:
* type: object
* properties:
* stock_location:
* $ref: "#/components/schemas/StockLocationDTO"
* $ref: "#/components/schemas/AdminStockLocationsRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
5 changes: 1 addition & 4 deletions packages/medusa/src/api/routes/admin/store/add-currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ import { EntityManager } from "typeorm"
* content:
* application/json:
* schema:
* type: object
* properties:
* store:
* $ref: "#/components/schemas/Store"
* $ref: "#/components/schemas/AdminStoresRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
Expand Down
Loading

0 comments on commit 62bdd87

Please sign in to comment.