Skip to content

Commit 7560899

Browse files
authored
Add doc for ReadmeUriTemplate (#3382)
* add new resource doc * Updated the implementation guide * remove extra line * Update URL placeholders to required
1 parent 487e059 commit 7560899

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

docs/TOC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
#### [Package metadata](api/registration-base-url-resource.md)
129129
#### [Push and delete](api/package-publish-resource.md)
130130
#### [Push symbol packages](api/symbol-package-publish-resource.md)
131+
#### [README URI](api/readme-template-resource.md)
131132
#### [Report abuse URL](api/report-abuse-resource.md)
132133
#### [Repository signatures](api/repository-signatures-resource.md)
133134
#### [Search](api/search-query-service-resource.md)

docs/api/implementation-guide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ To assist authors of existing NuGet repositories keep up to date with NuGet's ne
3535
||Added `packageTypes` query parameter to `SearchQueryService` requests|
3636
|2021|[Embedded readme](#embedded-files)|
3737
|2023|[PreAuthenticate authenticated requests](#url-structure-for-authenticated-feeds) <br/> [`VulnerabilityInfo` resource](#known-vulnerabilities-database-vulnerabilityinfo)|
38+
|2025|[Enable embedded README downloads](#enable-embedded-readme-downloads)|
3839

3940
## Owner field
4041

@@ -140,3 +141,7 @@ In this case, every request to the service index will have additional latency, d
140141

141142
While NuGet's V3 API was designed to work on a static file server, the search resource is the exception that always requires a dynamic web service to process requests.
142143
If you wish to host search, or indeed any other NuGet API resource, on different servers, in order to benefit from `HttpClientHandler`'s `PreAuthenticate`, you will need to use a reverse proxy to ensure all customer facing URLs in the service index meet the "same or subdirectory" rule.
144+
145+
## Enable embedded README downloads
146+
147+
A [new resource](./readme-template-resource.md) was documented for constructing a URL that can be used to download a README for a given package. This will allow client, like the Package Management UI in VS, to display the embedded README for packages which haven't been previously installed by the user. The client will construct this URL and attempt to download the README, using the response to the request to determine if a README is available. This means servers should expect multiple requests to the constructed endpoint as users navigate the PM UI.

docs/api/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Resource name | Required
6161
[PackageBaseAddress](package-base-address-resource.md) | yes | Get package content (.nupkg).
6262
[PackageDetailsUriTemplate](package-details-template-resource.md) | no | Construct a URL to access a package details web page.
6363
[PackagePublish](package-publish-resource.md) | yes | Push and delete (or unlist) packages.
64+
[ReadmeUriTemplate](readme-template-resource.md) | no | Construct a URL to access a package's README.
6465
[RegistrationsBaseUrl](registration-base-url-resource.md) | yes | Get package metadata.
6566
[ReportAbuseUriTemplate](report-abuse-resource.md) | no | Construct a URL to access a report abuse web page.
6667
[RepositorySignatures](repository-signatures-resource.md) | no | Get certificates used for repository signing.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: README Uri Template, NuGet API
3+
description: The README uri template allows clients to download the readme for a package, if available.
4+
author: jgonz120
5+
ms.author: jongonza
6+
ms.date: 1/6/2025
7+
ms.topic: reference
8+
ms.reviewer:
9+
---
10+
11+
# README Uri Template
12+
13+
It is possible for a client to build a URL that can be used to download a README for a specific package.
14+
This will enable the clients to render the package's README without downloading the entire package.
15+
16+
The resource used for building this URL is the `ReadmeUriTemplate` resource found in the
17+
[service index](service-index.md).
18+
19+
## Versioning
20+
21+
The following `@type` values are used:
22+
23+
@type value | Notes
24+
--------------------------------- | -----
25+
ReadmeUriTemplate/6.13.0 | The initial release
26+
27+
## URL template
28+
29+
The URL for the following API is the value of the `@id` property associated with one of the aforementioned
30+
resource `@type` values.
31+
32+
## HTTP methods
33+
34+
The constructed URL must support the HTTP method `GET`
35+
36+
## Construct the URL
37+
38+
Given a known package ID and version, the client implementation can construct a URL to download the README.
39+
40+
The value of the `@id` is a URL string containing any of the following placeholder tokens:
41+
42+
### URL placeholders
43+
44+
Name | Type | Required | Notes
45+
----------- | ------- | -------- | -----
46+
`{lower_id}` | string | yes | The package ID, lowercased
47+
`{lower_version}` | string | yes | The package version, lowercased
48+
49+
Both `lower_id` and `lower_version` are lowercased using the rules implemented by .NET's
50+
[`System.String.ToLowerInvariant()`](/dotnet/api/system.string.tolowerinvariant?view=netstandard-2.0#System_String_ToLowerInvariant&preserve-view=true)
51+
method.
52+
53+
The `lower_version` is the desired package version normalized using NuGet's version
54+
[normalization rules](../concepts/package-versioning.md#normalized-version-numbers). This means that build metadata
55+
that is allowed by the SemVer 2.0.0 specification must be excluded in this case.
56+
57+
### Response body
58+
59+
If the package has a readme, a 200 status code is returned. The response body will be the readme
60+
content itself.
61+
62+
If the package does not have a readme, a 404 status code is returned.

0 commit comments

Comments
 (0)