diff --git a/src/common/utils.ts b/src/common/utils.ts index a11a8c9c9..314012af6 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -690,21 +690,96 @@ export const filterDescription = }\n \ '; -export const fullQueryExample = - '{ "fields": ["field1", "field2"], "limits": {"limit": 1, "skip": 1, "order": "asc"}}'; +export const fullQueryExampleLimits = + '{"limit": 1, "skip": 1, "order": "creationTime:desc"}'; -export const fullQueryDescription = +export const datasetsFullQueryExampleFields = + '{"mode":{},"ownerGroup":["group1"],"scientific":[{"lhs":"sample","relation":"EQUAL_TO_STRING","rhs":"my sample"},{"lhs":"temperature","relation":"GREATER_THAN","rhs":10,"unit":"celsius"}]}'; + +export const fullQueryDescriptionLimits = '
\n \ {\n \ - "fields?": [ "field1", "field2", ...],\n \ - "limits?": {\n \ - "limit": number,\n \ - "skip": number,\n \ - "order": [ascending, descending]\n \ - }\n \ + "limit": number,\n \ + "skip": number,\n \ + "order": [ascending, descending]\n \ }\n \'; +export const datasetsFullQueryDescriptionFields = + '
\n \ +{\n \ + "mode":{\n \ + "key": "value",\n \ + },\n \ + "text": string,'; + +export const proposalsFullQueryExampleFields = + '{"text": "some text", "proposalId": "proposal_id"}'; + +export const proposalsFullQueryDescriptionFields = + '\n \ + "creationTime": { \n \ + "begin": string,\n \ + "end": string,\n \ + },\n \ + "type": ["type1", ...], \n \ + "creationLocation": ["creationLocation1", ...], \n \ + "ownerGroup": ["group1", ...], \n \ + "keywords": ["keyword1", ...], \n \ + "isPublished: boolean, \n \ + "scientific": [ \n \ + {\n \ + "lhs": >,\n \ + "relation":["EQUAL_TO_STRING","EQUAL_TO_NUMERIC","GREATER_THAN","LESS_THAN"],\n \ + "rhs": ,\n \ + "unit": ,\n \ + },\n \ + ...\n \ + ],\n \ + "metadataKey": "metadata", \n \ + "_id": "item id", \n \ + "userGroups": ["group1", ...], \n \ + "sharedWith": "email", \n \ +}\n \ +
\n \ +{\n \ + "text": string,'; + +export const samplesFullQueryExampleFields = + '{"text": "some text", "metadataKey": "key", "characteristics": [{"lhs":"material","relation":"EQUAL_TO_STRING","rhs":"my material"}]}'; + +export const samplesFullQueryDescriptionFields = + '\n \ + "startTime": { \n \ + "begin": string,\n \ + "end": string,\n \ + },\n \ + "proposalId": { "regex": string, "options": string }, \n \ + "title": { "regex": string, "options": string }, \n \ + "firstname": { "regex": string, "options": string }, \n \ + "lastname": { "regex": string, "options": string }, \n \ + "endTime": { \n \ + "begin": string,\n \ + "end": string,\n \ + },\n \ + "userGroups": ["group1", ...],\n \ +}\n \ +
\n \ +{\n \ + "text": string,'; + export const parseBoolean = (v: unknown): boolean => { switch (v) { case true: diff --git a/src/datasets/datasets.controller.ts b/src/datasets/datasets.controller.ts index 99d6812a0..12063aaff 100644 --- a/src/datasets/datasets.controller.ts +++ b/src/datasets/datasets.controller.ts @@ -86,6 +86,10 @@ import { CreateDatasetDatablockDto } from "src/datablocks/dto/create-dataset-dat import { filterDescription, filterExample, + datasetsFullQueryDescriptionFields, + fullQueryDescriptionLimits, + datasetsFullQueryExampleFields, + fullQueryExampleLimits, replaceLikeOperator, } from "src/common/utils"; import { TechniqueClass } from "./schemas/technique.schema"; @@ -558,17 +562,20 @@ export class DatasetsController { @ApiQuery({ name: "fields", description: - "Define the query conditions using mongoDB syntax as JSON object. It also supports the `text` search, if you want to look for strings anywhere in the dataset. Please refer to mongo documentation for more information about the syntax", + "Database filters to apply when retrieving datasets\n" + + datasetsFullQueryDescriptionFields, required: false, type: String, - example: {}, + example: datasetsFullQueryExampleFields, }) @ApiQuery({ name: "limits", - description: "Define further query parameters like skip, limit, order", + description: + "Define further query parameters like skip, limit, order\n" + + fullQueryDescriptionLimits, required: false, type: String, - example: '{ "skip": 0, "limit": 25, "order": "creationTime:desc" }', + example: fullQueryExampleLimits, }) @ApiResponse({ status: 200, diff --git a/src/proposals/proposals.controller.ts b/src/proposals/proposals.controller.ts index 9489aea35..b52ebcf84 100644 --- a/src/proposals/proposals.controller.ts +++ b/src/proposals/proposals.controller.ts @@ -54,8 +54,10 @@ import { validate, ValidatorOptions } from "class-validator"; import { filterDescription, filterExample, - fullQueryDescription, - fullQueryExample, + fullQueryDescriptionLimits, + fullQueryExampleLimits, + proposalsFullQueryDescriptionFields, + proposalsFullQueryExampleFields, } from "src/common/utils"; import { JWTUser } from "src/auth/interfaces/jwt-user.interface"; @@ -222,13 +224,22 @@ export class ProposalsController { "It returns a list of proposals matching the query provided.\n \ + "metadataKey": string, \n \ + "charactersitics": [ \n \ + {\n \ + "lhs": >,\n \ + "relation":["EQUAL_TO_STRING","EQUAL_TO_NUMERIC","GREATER_THAN","LESS_THAN"],\n \ + "rhs": ,\n \ + "unit": ,\n \ + },\n \ + ...\n \ + ],\n \ +}\n \ +