From 0b84bd57647c0eeacded8804ad50cee8db12cb11 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 12 Jul 2023 10:52:33 +0300 Subject: [PATCH] chore: fix OAS for product search endpoint (#4490) * chore: fix OAS for product search endpoint * added build files --- .../src/lib/models/StorePostSearchReq.ts | 6 ++++- .../src/api/routes/store/products/search.ts | 27 ++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/packages/generated/client-types/src/lib/models/StorePostSearchReq.ts b/packages/generated/client-types/src/lib/models/StorePostSearchReq.ts index 8809a6a4a6..870f1df33b 100644 --- a/packages/generated/client-types/src/lib/models/StorePostSearchReq.ts +++ b/packages/generated/client-types/src/lib/models/StorePostSearchReq.ts @@ -7,7 +7,7 @@ export interface StorePostSearchReq { /** * The query to run the search with. */ - q: string + q?: string /** * How many products to skip in the result. */ @@ -16,4 +16,8 @@ export interface StorePostSearchReq { * Limit the number of products returned. */ limit?: number + /** + * Filter based on the search engine. + */ + filter?: any } diff --git a/packages/medusa/src/api/routes/store/products/search.ts b/packages/medusa/src/api/routes/store/products/search.ts index 9ee874e42f..5a3b36b078 100644 --- a/packages/medusa/src/api/routes/store/products/search.ts +++ b/packages/medusa/src/api/routes/store/products/search.ts @@ -10,14 +10,13 @@ import { validator } from "../../../../utils/validator" * operationId: PostProductsSearch * summary: Search Products * description: "Run a search query on products using the search engine installed on Medusa" - * parameters: - * - (query) q=* {string} The query to run the search with. - * - (query) offset {integer} How many products to skip in the result. - * - (query) limit {integer} Limit the number of products returned. - * - (query) filter {} Filter based on the search engine. + * requestBody: + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/StorePostSearchReq" * x-codegen: * method: search - * queryParams: StorePostSearchReq * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -76,6 +75,22 @@ export default async (req, res) => { res.status(200).send(results) } +/** + * @schema StorePostSearchReq + * type: object + * properties: + * q: + * type: string + * description: The query to run the search with. + * offset: + * type: number + * description: How many products to skip in the result. + * limit: + * type: number + * description: Limit the number of products returned. + * filter: + * description: Filter based on the search engine. + */ export class StorePostSearchReq { @IsOptional() @IsString()