Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
fix(chart.getPanels): make the query params optional
Browse files Browse the repository at this point in the history
When the array is empty, the SDK strips the query param from the query,
so the schema doesn't type check
  • Loading branch information
Arinono committed Mar 20, 2023
1 parent a3a4ad9 commit 1a76ef6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/routes/chart/get-panels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const kindsResources = ['pinGroups', 'pins'] as const;
type KindsResources = typeof kindsResources[number];

type Request = {
query: Record<KindsHashIds, Array<HashId>>;
query: Partial<Record<KindsHashIds, Array<HashId>>>;
}

type Panel = {
Expand All @@ -24,10 +24,10 @@ type Panel = {
},
};

type Response = Record<KindsResources, Array<{
type Response = Partial<Record<KindsResources, Array<{
hashId: HashId,
panel: Panel,
}>>;
}>>>;

const charts = (apiVersion: number) => Joi.object().keys({
lastMode: Joi.string().valid('manual', 'automatic').example('automatic').required(),
Expand All @@ -41,19 +41,19 @@ const controllerGeneratorOptions: ControllerGeneratorOptionsWithClient = {
method: 'get',
path: '/panels',
query: Joi.object().keys({
pinGroupHashIds: Joi.array().items(Joi.string()).max(30).required(),
pinHashIds: Joi.array().items(Joi.string()).max(30).required(),
pinGroupHashIds: Joi.array().items(Joi.string()).max(30),
pinHashIds: Joi.array().items(Joi.string()).max(30),
}).required(),
right: { environment: 'READ' },
response: (apiVersion: number): Joi.ObjectSchema => Joi.object().keys({
pinGroups: Joi.array().items(Joi.object().keys({
hashId: Joi.string().required().example('dao97'),
panel: charts(apiVersion),
}).required()).required(),
}).required()),
pins: Joi.array().items(Joi.object().keys({
hashId: Joi.string().required().example('e13d57'),
panel: charts(apiVersion),
}).required()).required(),
}).required()),
}),
description: 'Get multiple chart panels from pinGroups and grids',
};
Expand Down

0 comments on commit 1a76ef6

Please sign in to comment.