Skip to content

feat(piefed): refresh schema from live swagger#35

Merged
aeharding merged 1 commit into
mainfrom
upgrade-piefed-schema
May 23, 2026
Merged

feat(piefed): refresh schema from live swagger#35
aeharding merged 1 commit into
mainfrom
upgrade-piefed-schema

Conversation

@aeharding
Copy link
Copy Markdown
Owner

Summary

  • Switched the piefed schema source from freamon.github.io/piefed-api/swagger.yaml (last updated Sept 2025) to piefed.social/api/alpha/swagger.json (live). 5193 → 7944 lines, mostly newly-typed endpoints.
  • Fixed two real bugs the stale schema was hiding:
    • createPostReport was missing the required report_remote: true (we already had it on createCommentReport)
    • featurePost was sending snake_case feature_type ("community" / "local") where piefed expects PascalCase
  • Narrowed fromListingType return type in both lemmyv0/compat.ts and piefed/compat.ts — the explicit annotations widened the return to include "Popular" even though the runtime map can't emit it. Removed one resulting @ts-expect-error.
  • Updated the regen instructions in src/providers/piefed/README.

Test plan

  • pnpm test (19 tests pass)
  • pnpm test:types clean
  • Live smoke-tested 6 endpoints against piefed.social (getSite/getPosts/getComments/listCommunities/search/getPost)

Follow-up not in scope

The narrowed fromListingType surfaced a separate type leak in listCommunities: the sort? field from threadiverse's mode-keyed union pulls in v1's snake_case values (e.g. "comments"), which piefed correctly rejects. Restored a focused @ts-expect-error with that explanation; properly threading mode-specific sorts through the BaseClient signatures is a bigger refactor.

The previous schema source (freamon.github.io/piefed-api) hadn't been
updated since Sept 2025; piefed.social serves a current
`/api/alpha/swagger.json` that reflects the live API. Switch to it.

Fixes surfaced by the new types:
- `createPostReport` needs `report_remote: true` (we were sending it on
  `createCommentReport` but not the post variant)
- `featurePost` `feature_type` must be PascalCase (`Community`/`Local`),
  not snake_case

Also narrows two `fromListingType` return annotations that were widened
to the full Lemmy enum even though the maps can't emit the extra values
("Popular"), removing one `@ts-expect-error`.
@aeharding aeharding merged commit c3ae79a into main May 23, 2026
1 check passed
@aeharding aeharding deleted the upgrade-piefed-schema branch May 23, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant