Skip to content

Commit 1353c82

Browse files
authored
Update API-design-guidelines.md
1 parent 7401b48 commit 1353c82

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

documentation/API-design-guidelines.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,12 @@ Filtering consists of restricting the number of resources queried by specifying
905905
Next, it is specified how it should be used according to the filtering based on the type of data being searched for: a number or a date and the type of operation.
906906

907907
Note: Services may not support all attributes for filtering. In case a query includes an attribute for which filtering is not supported, it may be ignored by the service.
908+
909+
#### Security Considerations
910+
As filtering may reveal sensitive information, privacy and security constraints have to be considered when defining query parameters, e.g. it should not be possible to filter using personal information (such as name, phone number or IP address).
911+
912+
913+
#### Filtering operations
908914

909915
| **Operation** | Numbers | Dates |
910916
|-------------------|------------------------------|-----------------------------------------------|
@@ -917,28 +923,29 @@ Note: Services may not support all attributes for filtering. In case a query in
917923

918924
And according to the filtering based on string and enums data, being searched for:
919925

920-
| **Operation** | **Strings/enums** |
921-
|---------------|-----------------------|
922-
| equal | `GET .../?name=Juan` |
923-
| non equal | `GET .../?name!=Jonh` |
924-
| Contains | `GET .../?name=~Rafa` |
925926

927+
| **Operation** | **Strings/enums** |
928+
| ----- | ----- |
929+
| equal | `GET .../?type=mobile` |
930+
| non equal | `GET .../?type!=mobile` |
931+
| Contains | `GET .../?type=~str` |
926932

927933
**Additional rules**:
928934
- The operator "`&`" is evaluated as an AND between different attributes.
929935
- A Query Param (attribute) can contain one or n values separated by "`,`".
930936
- For operations on numeric, date or enumerated fields, the parameters with the suffixes `.(gte|gt|lte|lt)$` need to be defined, which should be used as comparators for “greater—equal to, greater than, smaller—equal to, smaller than” respectively. Only the parameters needed for given field should be defined e.g., with `.gte` and `.lte` suffixes only.
931937

938+
932939
**Examples**:
933-
- <u>Equals</u>: to search users with the first name "david" and last name "munoz":
934-
- `GET /users?name=david&surname=munoz`
935-
- `GET /users?name=David,Noelia`
940+
- <u>Equals</u>: to search devices with a particular operating system and version or type:
941+
- `GET /device?os=ios&version=17.0.1`
942+
- `GET /device?type=apple,android`
936943
- Search for several values separating them by "`,`".
937944
- <u>Inclusion</u>: if we already have a filter that searches for "equal" and we want to provide it with the possibility of searching for "inclusion", we must include the character "~"
938-
- `GET /users?name=dav`
939-
- Search for the exact name "dav"
940-
- `GET /users?name=~dav`
941-
- Look for names that include "dav"
945+
- `GET /device?version=17.0.1`
946+
- Search for the exact version "17.0.1"
947+
- `GET /device?version=~17.0`
948+
- Look for version strings that include "17.0"
942949
- <u>Greater than / less than</u>: new attributes need to be created with the suffixes `.(gte|gt|lte|lt)$` and included in `get` operation :
943950
```yaml
944951
paths:

0 commit comments

Comments
 (0)