Skip to content

Commit da536d8

Browse files
authored
docs(api): clarify version vs purl usage in query endpoints (#3993)
Documents that `version` and versioned purls are mutually exclusive. Also fixes a small typo. Fixes #1900
1 parent 204d50d commit da536d8

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

docs/api/post-v1-query.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,31 @@ To query multiple packages at once, see further information [here](post-v1-query
2828
| Parameter | Type | Description |
2929
| ------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3030
| `commit` | string | The commit hash to query for. If specified, `version` should not be set. |
31-
| `version` | string | The version string to query for. A fuzzy match is done against upstream versions. If specified, `commit` should not be set. |
31+
| `version` | string | The version string to query for. A fuzzy match is done against upstream versions. If set, `commit` must not be used, and `package.purl` must not include a version. |
3232
| `package` | object | The package to query against. When a `commit` hash is given, this is optional. |
3333
| `page_token` | string | If your previous query fetched a large number of results, the response will be paginated. This is an optional field. Please see the [pagination section](#pagination) for more information. |
3434

3535
Package Objects can be described by package name AND ecosystem OR by the package URL.
3636

37+
### Version rules
38+
39+
- Use either the top-level `version` field or a versioned purl (`pkg:...@<version>`), but not both.
40+
- Requests that specify the version in both places return **400 Bad Request**.
41+
42+
Examples:
43+
44+
Valid:
45+
```json
46+
{ "package": { "name": "jinja2", "ecosystem": "PyPI" }, "version": "3.1.4" }
47+
{ "package": { "purl": "pkg:pypi/[email protected]" } }
48+
{ "package": { "purl": "pkg:pypi/jinja2" }, "version": "3.1.4" }
49+
```
50+
51+
Invalid (400 Bad Request):
52+
```json
53+
{ "package": { "purl": "pkg:pypi/[email protected]" }, "version": "3.1.4" }
54+
```
55+
3756
|---
3857
| Attribute | Type | Description |
3958
| ----------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

docs/api/post-v1-querybatch.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ Query for multiple packages (by either package and version or git commit hash) a
2121

2222
## Parameters
2323

24-
The parameters are the same as those in found [here](post-v1-query.md#parameters), but you can make multiple queries.
24+
The parameters are the same as those in [POST /v1/query](post-v1-query.md#parameters), but you can make multiple queries.
2525

2626
[Instructions are available](#pagination) for handling pagination for querybatch requests.
2727

28+
### Version rules
29+
30+
Each query item must follow the same rules as `/v1/query`:
31+
- Use either `version` or a versioned purl, not both.
32+
- Items with both will return **400 Bad Request**.
33+
2834
## Payload
2935
```json
3036
{

0 commit comments

Comments
 (0)