apple / apple/swift-openapi-generator

Support parsing RFC-8288 link header

Open
#791 0 comments 1 reaction 0 assignees View on GitHub
area/runtime kind/feature
Dominant language
Swift
Stars
2k
Forks
182
Avg merge
13h 28m
Merged PRs (30d)
5

Description

### Motivation

It'd be useful if the OpenAPI runtime supported parsing the "link" header

Steps To Reproduce:
1. Call an API that returns links via the "link" header

switch try await client.listRepositories(request) {
case .ok(let ok):
let links = okResponse.headers.link
...
}

Results:
We just get back a link of string, which is difficult to work with. In particular when it's used for pagination like in the Github API for example:

Link: ; rel="next"

We need to parse the links to find the one with the "next" relation, then parse its URL to extract the `page` parameter, so that we can call the API to fetch the next page.

It'd be useful if it at least the links were available in parsed form, so that we only need to deal with the URL itself.

https://datatracker.ietf.org/doc/html/rfc8288
https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api?apiVersion=2022-11-28#using-link-headers

### Proposed solution

See above

### Alternatives considered

_No response_

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the generated response-header access shown in the issue, especially `okResponse.headers.link`, and read RFC-8288 alongside the GitHub pagination example. Trace where the raw Link header becomes available in the Swift runtime, then add coverage demonstrating that relations such as `next` expose their URLs in parsed form.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.