ardatan / ardatan/feTS

JSONAPI support

Open
#980 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
719
Forks
33
Avg merge
5h 46m
Merged PRs (30d)
60

Description

**Is your feature request related to a problem? Please describe.**

Workday Peakon currently has a large REST API based on the [JSONAPI specification](https://jsonapi.org). We're in the process of defining an OpenAPI spec for the API and using feTS for typing the client/server interaction. However, OpenAPI does not support [sparse fieldsets](https://jsonapi.org/format/#fetching-sparse-fieldsets) and [inclusion of related resources](https://jsonapi.org/format/#fetching-includes), which results in poor type safety. These features mean that the response type varies depending on the request.

**Describe the solution you'd like**

In a perfect world, feTS would understand the query parameters `fields` and `include` from the JSONAPI spec, and alter the response type correspondingly.

I've drafted a small example of how this could work as a user of the library here: https://github.com/andreas/fets-jsonapi/blob/master/index.ts

It's unclear to me whether this fits in core feTS, or whether it would be more suitable as an extension library or plugin.

**Describe alternatives you've considered**

Accepting poor type safety 😭

**Additional context**

As mentioned, this might be slightly outside the core remit of feTS, but @urigo encouraged me to open an issue here 🙂

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked fets-jsonapi index.ts example, then read the JSON:API sparse fieldsets and inclusion specifications. Inspect feTS's existing OpenAPI response-typing and extension points to determine whether fields and include belong in core or a plugin. Done means the scope and integration boundary are settled, with corresponding response types for these query parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.