> ## Documentation Index
> Fetch the complete documentation index at: https://docs.uplink.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Semantic schemas

> Find vocabulary types in connector output with produces, and decode them with UplinkVocabulary

Connectors returning the same kind of data — Netflix, Spotify, and Verizon all returning plans and bills — should look the same in your app. The Uplink [semantic vocabulary](https://docs.uplink.build/vocabulary/overview.md) makes that possible: connectors return their data as canonical types (`uplink:Subscription`, `uplink:Bill`, …), and you write one renderer per type.

## Output is an object

An action's output is always a JSON object. Its fields hold vocabulary values, alone or in arrays. Verizon's `fetchAll` returns, among others:

```json theme={null}
{
  "identity": { "email": "jane.doe@example.com", "displayName": "JANE DOE" },
  "subscriptions": [{ "id": "5550101234", "name": "iPhone 15 Pro", "description": "Unlimited Plus", "status": "active", "amount": "$45.00" }],
  "bill": { "sourceId": "123456789-00001", "nextBillDate": "2026-11-22", "nextBillAmount": "$142.37" },
  "usage": [{ "subjectId": "5550101234", "metric": "data", "used": 38.62, "unit": "GB" }],
  "accountType": "wireless"
}
```

`identity` is an `uplink:AccountIdentity`, `subscriptions` an array of `uplink:Subscription`, `bill` a single `uplink:Bill`, and `usage` an array of `uplink:Usage`. `accountType` is Verizon-specific.

Field names differ between connectors — Verizon returns one `bill`, Chase an array of `bills` — so don't hard-code them. Read them from `produces`.

## `produces`

Every connector in the catalog lists the vocabulary values its actions return. `ConnectorListItem`, `ConnectorDetail`, and the `connector` on each `ConnectionWithGrants` all carry it:

```swift theme={null}
public struct ProducedOutput {
    public let action: String  // "fetchAll"
    public let field: String   // "subscriptions"
    public let type: String    // "uplink:Subscription/v1"
    public let many: Bool      // true when the field is an array
}
```

The catalog derives `produces` from each action's published output schema, so you can choose a renderer before running anything:

```swift theme={null}
let showsBilling = connector.produces.contains { $0.type == Bill.vocabularyType }
```

Fields that aren't in `produces` are connector-specific.

> [!NOTE]
>
> Each invocation also reports an `outputType`, a label for its whole output — usually connector-specific, such as `atomic:VerizonAccount`. Dispatch on `produces`, not `outputType`.

## Decode with `UplinkVocabulary`

The `UplinkVocabulary` Swift package has a `Codable` struct for every vocabulary type. Each exposes its identifier as `vocabularyType`:

```swift theme={null}
dependencies: [
    .package(url: "https://github.com/uplink-code/uplink-vocabulary", from: "0.7.0")
],
targets: [
    .target(
        name: "YourApp",
        dependencies: [
            .product(name: "UplinkVocabulary", package: "uplink-vocabulary")
        ]
    )
]
```

```swift theme={null}
import UplinkVocabulary

Subscription.vocabularyType // "uplink:Subscription/v1"
```

Decode one `produces` entry out of an action's output:

```swift theme={null}
import Foundation
import UplinkUI
import UplinkVocabulary

func values<T: VocabularyEntity>(
    _ type: T.Type, in output: Data, at produced: ProducedOutput
) throws -> [T] {
    let object = try JSONSerialization.jsonObject(with: output) as? [String: Any]
    guard let value = object?[produced.field], !(value is NSNull) else { return [] }
    let data = try JSONSerialization.data(withJSONObject: value)
    return produced.many
        ? try JSONDecoder().decode([T].self, from: data)
        : [try JSONDecoder().decode(T.self, from: data)]
}
```

Then dispatch on each entry's type:

```swift theme={null}
func render(_ result: UplinkConnectActionResult, from connector: ConnectorDetail) throws {
    guard let output = result.snapshot.outputData else { return }

    for produced in connector.produces where produced.action == result.action {
        switch produced.type {
        case Subscription.vocabularyType:
            showSubscriptions(try values(Subscription.self, in: output, at: produced))
        case Bill.vocabularyType:
            showBills(try values(Bill.self, in: output, at: produced))
        default:
            break // a type this app doesn't render yet
        }
    }
}
```

New connectors that return types you already handle work without changes.

Most types keep money and dates as strings, the way the provider shows them; banking and usage types use numbers. Each type's page in the [vocabulary](https://docs.uplink.build/vocabulary/overview.md) says which. Enums decode values they don't know instead of failing, so a new case in the vocabulary doesn't break older apps.

## Without the package

You can mirror the JSON Schemas from [`@uplink-code/vocabulary`](https://www.npmjs.com/package/@uplink-code/vocabulary) as your own `Codable` structs. Match the field names exactly, and keep string fields — including dates — as `String`:

```swift theme={null}
struct Route: Codable {
    let name: String
    let url: String
    let distance: String        // formatted with unit, e.g. "18.4 km"
    let elevation: String       // e.g. "312 m"
    let durationSeconds: Double?
    let createdAt: String?      // ISO 8601 when the source gives one
}
```

## What's next

> [card] [Semantic vocabulary](https://docs.uplink.build/vocabulary/overview.md)
>
> Every type and its fields

> [card] [Displaying invocation state](https://docs.uplink.build/connectors-ios/invocation-state.md)
>
> Observe progress until the output is ready


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.