-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: enhance REST API OpenAPI spec with nested filter example (#7366)
- Loading branch information
1 parent
c6a676e
commit 8162786
Showing
2 changed files
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { OrderByDirection } from 'src/engine/api/graphql/workspace-query-builder/interfaces/record.interface'; | ||
|
||
import { DEFAULT_CONJUNCTION } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/add-default-conjunction.utils'; | ||
import { FilterComparators } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/parse-base-filter.utils'; | ||
import { Conjunctions } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/parse-filter.utils'; | ||
import { DEFAULT_ORDER_DIRECTION } from 'src/engine/api/rest/input-factories/order-by-input.factory'; | ||
import { | ||
computeDepthParameters, | ||
computeEndingBeforeParameters, | ||
|
@@ -9,10 +13,6 @@ import { | |
computeOrderByParameters, | ||
computeStartingAfterParameters, | ||
} from 'src/engine/core-modules/open-api/utils/parameters.utils'; | ||
import { DEFAULT_ORDER_DIRECTION } from 'src/engine/api/rest/input-factories/order-by-input.factory'; | ||
import { FilterComparators } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/parse-base-filter.utils'; | ||
import { Conjunctions } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/parse-filter.utils'; | ||
import { DEFAULT_CONJUNCTION } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/add-default-conjunction.utils'; | ||
|
||
describe('computeParameters', () => { | ||
describe('computeLimit', () => { | ||
|
@@ -83,7 +83,9 @@ describe('computeParameters', () => { | |
name: 'filter', | ||
in: 'query', | ||
description: `Filters objects returned. | ||
Should have the following shape: **field_1[COMPARATOR]:value_1,field_2[COMPARATOR]:value_2,...** | ||
Should have the following shape: **field_1[COMPARATOR]:value_1,field_2[COMPARATOR]:value_2... | ||
To filter on nested objects use **field.nestedField[COMPARATOR]:value_1 | ||
** | ||
Available comparators are **${Object.values(FilterComparators).join( | ||
'**, **', | ||
)}**. | ||
|
@@ -102,6 +104,10 @@ describe('computeParameters', () => { | |
value: 'createdAt[gte]:"2023-01-01"', | ||
description: 'A simple filter param', | ||
}, | ||
simpleNested: { | ||
value: 'emails.primaryEmail[eq]:[email protected]', | ||
description: 'A simple nested filter param', | ||
}, | ||
complex: { | ||
value: | ||
'or(createdAt[gte]:"2024-01-01",createdAt[lte]:"2023-01-01",not(id[is]:NULL))', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,10 @@ import { OpenAPIV3_1 } from 'openapi-types'; | |
|
||
import { OrderByDirection } from 'src/engine/api/graphql/workspace-query-builder/interfaces/record.interface'; | ||
|
||
import { DEFAULT_CONJUNCTION } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/add-default-conjunction.utils'; | ||
import { FilterComparators } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/parse-base-filter.utils'; | ||
import { Conjunctions } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/parse-filter.utils'; | ||
import { DEFAULT_ORDER_DIRECTION } from 'src/engine/api/rest/input-factories/order-by-input.factory'; | ||
import { DEFAULT_CONJUNCTION } from 'src/engine/api/rest/core/query-builder/utils/filter-utils/add-default-conjunction.utils'; | ||
|
||
export const computeLimitParameters = ( | ||
fromMetadata = false, | ||
|
@@ -73,7 +73,9 @@ export const computeFilterParameters = (): OpenAPIV3_1.ParameterObject => { | |
name: 'filter', | ||
in: 'query', | ||
description: `Filters objects returned. | ||
Should have the following shape: **field_1[COMPARATOR]:value_1,field_2[COMPARATOR]:value_2,...** | ||
Should have the following shape: **field_1[COMPARATOR]:value_1,field_2[COMPARATOR]:value_2... | ||
To filter on nested objects use **field.nestedField[COMPARATOR]:value_1 | ||
** | ||
Available comparators are **${Object.values(FilterComparators).join( | ||
'**, **', | ||
)}**. | ||
|
@@ -82,7 +84,9 @@ export const computeFilterParameters = (): OpenAPIV3_1.ParameterObject => { | |
).join('**, **')}**. | ||
Default root conjunction is **${DEFAULT_CONJUNCTION}**. | ||
To filter **null** values use **field[is]:NULL** or **field[is]:NOT_NULL** | ||
To filter using **boolean** values use **field[eq]:true** or **field[eq]:false**`, | ||
To filter using **boolean** values use **field[eq]:true** or **field[eq]:false** | ||
`, | ||
|
||
required: false, | ||
schema: { | ||
type: 'string', | ||
|
@@ -92,6 +96,10 @@ export const computeFilterParameters = (): OpenAPIV3_1.ParameterObject => { | |
value: 'createdAt[gte]:"2023-01-01"', | ||
description: 'A simple filter param', | ||
}, | ||
simpleNested: { | ||
value: 'emails.primaryEmail[eq]:[email protected]', | ||
description: 'A simple nested filter param', | ||
}, | ||
complex: { | ||
value: | ||
'or(createdAt[gte]:"2024-01-01",createdAt[lte]:"2023-01-01",not(id[is]:NULL))', | ||
|