Skip to content

Commit 8d395e3

Browse files
authored
Publicize search by PackageType (NuGet#2076)
* Update docs to include new packageType parameter. * Updated some wording. Updated Catalog Data. * Update query form to include packageType. * There was a missing comma.
1 parent fa3ba8d commit 8d395e3

5 files changed

+47
-2
lines changed

docs/api/_data/catalog-package-details.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
"packageHash": "2edCwKLcbcgFJpsAwa883BLtOy8bZpWwbQpiIb71E74k5t2f2WzXEGWbPwntRleUEgSrcxJrh9Orm/TAmgO4NQ==",
2929
"packageHashAlgorithm": "SHA512",
3030
"packageSize": 118348,
31+
"packageTypes": [
32+
{
33+
"@id": "https://api.nuget.org/v3/catalog0/data/2015.02.01.11.18.40/windowsazure.storage.1.0.0.json#packagetypes/DotnetTool",
34+
"@type": "PackageType",
35+
"name": "DotnetTool"
36+
}
37+
],
3138
"projectUrl": "https://github.com/NuGet/NuGetGallery",
3239
"published": "1900-01-01T00:00:00Z",
3340
"requireLicenseAcceptance": false,

docs/api/_data/search-result.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
"authors": [ "NuGet" ],
1414
"totalDownloads": 141896,
1515
"verified": true,
16+
"packageTypes": [
17+
{
18+
"name": "Dependency"
19+
}
20+
],
1621
"versions": [
1722
{
1823
"version": "3.3.0",

docs/api/catalog-resource.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ minClientVersion | string | no |
227227
packageHash | string | yes | The hash of the package, encoding using [standard base 64](https://tools.ietf.org/html/rfc4648#section-4)
228228
packageHashAlgorithm | string | yes |
229229
packageSize | integer | yes | The size of the package .nupkg in bytes
230+
packageTypes | array of objects | no | The package types specified by the author.
230231
projectUrl | string | no |
231232
releaseNotes | string | no |
232233
requireLicenseAgreement | boolean | no | Assume `false` if excluded
@@ -244,6 +245,13 @@ time before the catalog item's commit timestamp.
244245
The `packageHashAlgorithm` is a string defined by the server implementation representing the hashing algorithm used to
245246
produce the `packageHash`. nuget.org always used the `packageHashAlgorithm` value of `SHA512`.
246247

248+
The `packageTypes` property will only be present if a package type was specified by the author. If it is present, it will always have at least one (1) entry. Each item in the `packageTypes` array is a JSON object with the following properties:
249+
250+
Name | Type | Required | Notes
251+
--------- | ------- | -------- | -----
252+
name | string | yes | The name of the package type.
253+
version | string | no | The version of the package type. Only present if the author explicitly specified a version in the nuspec.
254+
247255
The `published` timestamp is the time when the package was last listed.
248256

249257
> [!Note]

docs/api/search-autocomplete-service-resource.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ The following `@type` values are used:
2222
SearchAutocompleteService | The initial release
2323
SearchAutocompleteService/3.0.0-beta | Alias of `SearchAutocompleteService`
2424
SearchAutocompleteService/3.0.0-rc | Alias of `SearchAutocompleteService`
25+
SearchAutocompleteService/3.5.0 | Includes support for `packageType` query parameter
26+
27+
### SearchAutocompleteService/3.5.0
28+
This version introduces support for the `packageType` query parameter, allowing filtering by author defined package types. It is fully backwards compatible with queries to `SearchAutocompleteService`.
2529

2630
## Base URL
2731

@@ -39,7 +43,7 @@ a package typeahead feature in a user interface integrated with a NuGet package
3943

4044
A package with only unlisted versions will not appear in the results.
4145

42-
GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}
46+
GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
4347

4448
### Request parameters
4549

@@ -50,6 +54,7 @@ skip | URL | integer | no | The number of results to skip, for p
5054
take | URL | integer | no | The number of results to return, for pagination
5155
prerelease | URL | boolean | no | `true` or `false` determining whether to include [pre-release packages](../create-packages/prerelease-packages.md)
5256
semVerLevel | URL | string | no | A SemVer 1.0.0 version string
57+
packageType | URL | string | no | The package type to use to filter packages (added in `SearchAutocompleteService/3.5.0`)
5358

5459
The autocomplete query `q` is parsed in a manner that is defined by the server implementation. nuget.org supports
5560
querying for the prefix of package ID tokens, which are pieces of the ID produced by spliting the original by camel
@@ -69,6 +74,10 @@ If `semVerLevel=2.0.0` is provided, both SemVer 1.0.0 and SemVer 2.0.0 compatibl
6974
[SemVer 2.0.0 support for nuget.org](https://github.com/NuGet/Home/wiki/SemVer2-support-for-nuget.org-%28server-side%29)
7075
for more information.
7176

77+
The `packageType` parameter is used to further filter the autocomplete results to only packages that have at least one package type matching the package type name.
78+
If the provided package type is not a valid package type as defined by the [Package Type document](https://github.com/NuGet/Home/wiki/Package-Type-%5BPacking%5D), an empty result will returned.
79+
If the provided package type is empty, no filter will be applied. In other words, passing no value to the `packageType` parameter will behave as if the parameter was not passed.
80+
7281
### Response
7382

7483
The response is JSON document containing up to `take` autocomplete results.

docs/api/search-query-service-resource.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ The following `@type` values are used:
2222
SearchQueryService | The initial release
2323
SearchQueryService/3.0.0-beta | Alias of `SearchQueryService`
2424
SearchQueryService/3.0.0-rc | Alias of `SearchQueryService`
25+
SearchQueryService/3.5.0 | Includes support for `packageType` query parameter
26+
27+
### SearchQueryService/3.5.0
28+
This version introduces support for the `packageType` query parameter and the `packageTypes` response property, allowing filtering by author defined package types. It is fully backwards compatible with queries to `SearchQueryService`.
2529

2630
## Base URL
2731

@@ -41,7 +45,7 @@ package metadata fields may also be considered.
4145

4246
An unlisted package should never appear in search results.
4347

44-
GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}
48+
GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
4549

4650
### Request parameters
4751

@@ -52,6 +56,7 @@ skip | URL | integer | no | The number of results to skip, for p
5256
take | URL | integer | no | The number of results to return, for pagination
5357
prerelease | URL | boolean | no | `true` or `false` determining whether to include [pre-release packages](../create-packages/prerelease-packages.md)
5458
semVerLevel | URL | string | no | A SemVer 1.0.0 version string
59+
packageType | URL | string | no | The package type to use to filter packages (added in `SearchQueryService/3.5.0`)
5560

5661
The search query `q` is parsed in a manner that is defined by the server implementation. nuget.org supports basic
5762
filtering on a [variety of fields](../consume-packages/finding-and-choosing-packages.md#search-syntax). If no
@@ -72,6 +77,10 @@ If `semVerLevel=2.0.0` is provided, both SemVer 1.0.0 and SemVer 2.0.0 compatibl
7277
[SemVer 2.0.0 support for nuget.org](https://github.com/NuGet/Home/wiki/SemVer2-support-for-nuget.org-%28server-side%29)
7378
for more information.
7479

80+
The `packageType` parameter is used to further filter the search results to only packages that have at least one package type matching the package type name.
81+
If the provided package type is not a valid package type as defined by the [Package Type document](https://github.com/NuGet/Home/wiki/Package-Type-%5BPacking%5D), an empty result will returned.
82+
If the provided package type is empty, no filter will be applied. In other words, passing no value to the packageType parameter will behave as if the parameter was not passed.
83+
7584
### Response
7685

7786
The response is JSON document containing up to `take` search results. Search results are grouped by package ID.
@@ -105,6 +114,7 @@ tags | string or array of strings | no |
105114
title | string | no |
106115
totalDownloads | integer | no | This value can be inferred by the sum of downloads in the `versions` array
107116
verified | boolean | no | A JSON boolean indicating whether the package is [verified](../nuget-org/id-prefix-reservation.md)
117+
packageTypes | array of objects | yes | The package types defined by the package author (added in `SearchQueryService/3.5.0`)
108118

109119
On nuget.org, a verified package is one which has a package ID matching a reserved ID prefix and owned by one of the
110120
reserved prefix's owners. For more information, see the
@@ -119,6 +129,12 @@ Name | Type | Required | Notes
119129
version | string | yes | The full SemVer 2.0.0 version string of the package (could contain build metadata)
120130
downloads | integer | yes | The number of downloads for this specific package version
121131

132+
The `packageTypes` array will always consist of at least one (1) item. Package type for a given package ID is considered to be the package types defined by the latest version of the package with respect to the other search parameters. Each item in the `packageTypes` array is a JSON object with the following properties:
133+
134+
Name | Type | Required | Notes
135+
--------- | ------- | -------- | -----
136+
name | string | yes | The name of the package type.
137+
122138
### Sample request
123139

124140
GET https://azuresearch-usnc.nuget.org/query?q=NuGet.Versioning&prerelease=false&semVerLevel=2.0.0

0 commit comments

Comments
 (0)