You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mirror the v0.1 spec consistency fixes from the canonical VDP repo.
The spec page is now regenerated from VDP/view-descriptor-protocol.md
with the site's abbreviation definitions appended, keeping the two
copies from drifting.
@@ -122,29 +122,31 @@ A single API response may offer multiple views (e.g., a summary view and a detai
122
122
}
123
123
```
124
124
125
-
When only a single view is needed, the top-level object IS the view descriptor (no `views` wrapper). When multiple views are present, the `views` key wraps them. A client SHOULD use `default` when no specific view is requested.
125
+
When only a single view is needed, the top-level object IS the view descriptor (no `views` wrapper). When multiple views are present, the `views` key wraps them.
126
+
127
+
How a client chooses among named views is out of scope: view names are agreed between server and client out of band, and the client selects based on its own context (device class, container size, user preference, etc.). A client SHOULD use the `default` view when it has no reason to select another. If no `default` view exists and the client has no basis for choosing, it MUST select one of the available views; the choice is client-defined.
126
128
127
129
### 3.5 Slot Arrays
128
130
129
131
A single slot can accept multiple templates, rendered in sequence within the insertion point. This is useful when composing multiple independent components into a single region:
@@ -266,6 +268,8 @@ When a view descriptor is provided via multiple mechanisms, precedence is:
266
268
2.`Link` header with `rel="view-descriptor"`
267
269
3.`View-Template` header
268
270
271
+
If both `_view` and `_views` appear in the same response, `_views` takes precedence and `_view` MUST be ignored.
272
+
269
273
## 5. View Descriptor Resources
270
274
271
275
### 5.1 Media Type
@@ -309,10 +313,11 @@ Servers MUST NOT use the media type `version` parameter to version individual vi
309
313
310
314
### 5.4 URL Resolution
311
315
312
-
Template URLs in a view descriptor MAY be relative references (RFC 3986 Section 4.2). Clients MUST resolve relative URLs using the following base URL, in order of precedence:
316
+
Template URLs in a view descriptor MAY be relative references (RFC 3986 Section 4.2). Clients MUST resolve relative URLs against a base URL determined by the transport that delivered the descriptor:
313
317
314
318
1.**Standalone view descriptor resource**: The URL of the view descriptor resource itself (i.e., the URL used to fetch it via the `Link` header).
315
319
2.**Inline transport** (`_view` / `_views`): The URL of the API response containing the view descriptor.
320
+
3.**`View-Template` header**: The URL of the API response carrying the header.
316
321
317
322
Nested slot template URLs resolve against the same base URL as the root template URL — the base does not change at each nesting level.
318
323
@@ -345,10 +350,10 @@ Servers SHOULD use absolute URLs when view descriptors may be consumed by multip
345
350
346
351
When different clients require different templates (e.g., HTML for web, Compose for Android, SwiftUI for iOS), the server SHOULD use standard HTTP content negotiation to select the appropriate view descriptor. VDP does not define a mechanism for shipping multiple platform variants in a single response — the server selects and returns one view descriptor per request.
347
352
348
-
Servers MAY use the `Accept` header, custom headers, or query parameters to determine the client's rendering platform:
353
+
Negotiation applies to whichever request returns the view descriptor: the fetch of the standalone view descriptor resource (Section 4.1), or the API request itself when the descriptor is inline (Section 4.2). Servers MAY use custom headers or query parameters to determine the client's rendering platform:
349
354
350
355
```http
351
-
GET /api/dashboard HTTP/1.1
356
+
GET /views/dashboard.json HTTP/1.1
352
357
Accept: application/vdp+json
353
358
X-VDP-Platform: android
354
359
```
@@ -382,7 +387,7 @@ Not every insertion point in a template needs to appear in the view descriptor.
@@ -529,6 +534,7 @@ When fetching a template URL fails (HTTP 404, 5xx, network error, timeout):
529
534
- Clients MUST NOT fail the entire render if a single slot's template is unavailable.
530
535
- Clients SHOULD skip the unavailable slot and render the remaining template tree.
531
536
- Clients MAY display a placeholder or the template's default slot content in place of the failed slot.
537
+
- For slot arrays (Section 3.5), a failed array element is skipped; the remaining elements render in their declared order.
532
538
- Clients SHOULD log or report the failure for diagnostic purposes.
533
539
534
540
### 9.2 Slot Name Mismatch
@@ -557,11 +563,11 @@ Error handling follows the principle that a failure stays as local as possible:
557
563
558
564
## 10. Security Considerations
559
565
560
-
-**Template URL validation**: Clients MUST validate template URLs against an allowlist of trusted domains. Rendering arbitrary templates from untrusted sources is a code injection risk.
566
+
-**Template URL validation**: Clients MUST validate template URLs against an allowlist of trusted URL prefixes (see `trustedTemplateUrls`, Section 13.2). Rendering arbitrary templates from untrusted sources is a code injection risk.
561
567
-**CORS**: Template resources served cross-origin MUST include appropriate CORS headers.
562
-
-**Content Security Policy**: Template URLs SHOULD be included in the `script-src` or `style-src`CSP directives as appropriate.
568
+
-**Content Security Policy**: Browser clients fetching templates at runtime SHOULD include template origins in the `connect-src` CSP directive. `script-src` or `style-src`apply only where templates are loaded as executable scripts or stylesheets.
563
569
-**Template sandboxing**: Clients SHOULD render templates in a sandboxed context to prevent template injection attacks.
564
-
-**HTTPS**: Template URLs MUST use HTTPS in production. Clients SHOULD reject HTTP template URLs.
570
+
-**HTTPS**: Template URLs MUST use HTTPS. Clients SHOULD reject `http:` template URLs, with an exception permitted for loopback addresses during local development.
565
571
566
572
## 11. Relationship to Existing Standards
567
573
@@ -598,7 +604,7 @@ APIs SHOULD advertise VDP support so clients can detect it programmatically.
598
604
599
605
### 13.1 OPTIONS Response
600
606
601
-
An API endpoint supporting VDP MUST advertise it in its `OPTIONS` response, using the `VDP-Support` and `VDP-Version` headers:
607
+
An API endpoint supporting VDP SHOULD advertise it in its `OPTIONS` response, using the `VDP-Support` and `VDP-Version` headers:
602
608
603
609
```http
604
610
OPTIONS /api/dashboard HTTP/1.1
@@ -617,7 +623,7 @@ APIs MAY expose a discovery document at `/.well-known/vdp`:
Each entry in `endpoints` maps an API path to the URL of its view descriptor resource (`descriptor`). This allows clients to prefetch view descriptors and preload templates before making data requests. The `trustedTemplateDomains` field provides the template URL allowlist referenced in Section 10.
644
+
The discovery document is not a view descriptor and MUST NOT be served as `application/vdp+json`; it is served as plain `application/json`.
645
+
646
+
Each entry in `endpoints` maps an API path to the URL of its view descriptor resource (`descriptor`). This allows clients to prefetch view descriptors and preload templates before making data requests.
647
+
648
+
The `trustedTemplateUrls` field provides the template URL allowlist referenced in Section 10. Each entry is a URL prefix: a template URL is trusted if and only if, after RFC 3986 normalization, it begins with one of the listed entries. Entries SHOULD end with a trailing slash so that `https://templates.example.com/` cannot accidentally match `https://templates.example.com.evil.host/`.
0 commit comments