Skip to content

Make schema-profunctor schema names derived and avoid name clashes between scopes.#5151

Merged
fisx merged 21 commits intodevelopfrom
fisx/openapi-swagger-hacking
Apr 8, 2026
Merged

Make schema-profunctor schema names derived and avoid name clashes between scopes.#5151
fisx merged 21 commits intodevelopfrom
fisx/openapi-swagger-hacking

Conversation

@fisx
Copy link
Copy Markdown
Contributor

@fisx fisx commented Mar 23, 2026

Please read commit-by-commit. I've tried to isolate the commits that contain interesting code changes from those just brainlessly fixing type errors.

This PR introduces the following improvements:

  • name clashes between types with same name, but different module path, are no more.
  • no need to make up schema names by hand, writing object instances becomes more convenient.
  • names are more consistent.
  • full backwards-compatibility: the old functions are still accessible under the new name (namedObject for object etc.)

https://wearezeta.atlassian.net/wiki/spaces/ENGINEERIN/history/2686418945/API+changes+v15+-+v16

Screenshot From 2026-04-07 15-06-34

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Mar 23, 2026
@fisx fisx force-pushed the fisx/openapi-swagger-hacking branch 4 times, most recently from b687c71 to 9fd11c8 Compare March 25, 2026 12:46
@fisx fisx changed the title openapi/swagger hacking Make schema-profunctor schema names derived and avoid name clashes between scopes. Mar 25, 2026
@fisx fisx requested a review from Copilot March 25, 2026 12:54
@fisx fisx marked this pull request as ready for review March 25, 2026 12:54
@fisx fisx requested review from a team as code owners March 25, 2026 12:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the schema-profunctor ecosystem to derive OpenAPI schema names automatically (using Typeable) to avoid name clashes across modules/scopes, and propagates the new API across Wire’s public/internal schema definitions. It also introduces small supporting utilities (e.g. versioned schema helpers) and a helper script for generating clients from the produced OpenAPI spec.

Changes:

  • Change Data.Schema.object / enum to derive schema names automatically and introduce namedObject / namedEnum for explicit naming.
  • Update many ToSchema instances and schema helpers across the codebase to use the new derived-name API and add Typeable constraints where required.
  • Add OpenAPI client generation helper script and a changelog entry.

Reviewed changes

Copilot reviewed 125 out of 126 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tools/stern/src/Stern/Types.hs Update ToSchema instances to use derived object names.
tools/stern/src/Stern/Intra.hs Add Typeable cfg constraints for feature config handling.
tools/stern/src/Stern/API/Routes.hs Update schema object naming to derived names.
tools/stern/src/Stern/API.hs Add Typeable cfg constraint for feature routes.
services/galley/test/integration/API/Util/TeamFeature.hs Add Typeable cfg constraints to feature test utilities.
services/galley/src/Galley/API/Teams/Features.hs Add Typeable cfg constraints across feature-setting APIs.
services/cargohold/src/CargoHold/S3.hs Switch schema objects to derived naming.
services/brig/src/Brig/Options.hs Switch enum schema to derived naming.
services/brig/src/Brig/Effects/SFT.hs Switch schema object to derived naming.
services/background-worker/src/Wire/BackendNotificationPusher.hs Make PayloadBundle decode type application explicit.
libs/wire-api/src/Wire/API/UserGroup/Pagination.hs Add Typeable constraint; switch to derived naming in objectWithDocModifier.
libs/wire-api/src/Wire/API/UserGroup.hs Switch multiple schema objects to derived naming.
libs/wire-api/src/Wire/API/UserEvent.hs Switch objects/enums to derived naming; remove explicit nested object names.
libs/wire-api/src/Wire/API/User/Search.hs Remove manual typeRep-based schema naming; use derived object naming.
libs/wire-api/src/Wire/API/User/Scim.hs Switch multiple objects to derived naming; keep explicit naming where versioned.
libs/wire-api/src/Wire/API/User/RichInfo.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/User/Profile.hs Switch object/enum naming to derived naming.
libs/wire-api/src/Wire/API/User/Password.hs Switch objectWithDocModifier naming to derived naming.
libs/wire-api/src/Wire/API/User/Orphans.hs Switch enum naming to derived naming.
libs/wire-api/src/Wire/API/User/IdentityProvider.hs Switch object/enum naming to derived naming.
libs/wire-api/src/Wire/API/User/Handle.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/User/Client/Prekey.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/User/Client/DPoPAccessToken.hs Switch schema object/enum naming to derived naming.
libs/wire-api/src/Wire/API/User/Client.hs Switch many objects/enums to derived naming; keep explicit naming in a few versioned spots.
libs/wire-api/src/Wire/API/User/Auth/Sso.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/User/Auth/ReAuth.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/User/Auth/LegalHold.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/User/Auth.hs Switch objects/enums to derived naming; remove explicit names from doc-modified objects.
libs/wire-api/src/Wire/API/User/Activation.hs Switch objectWithDocModifier naming to derived naming.
libs/wire-api/src/Wire/API/User.hs Switch many objects/enums to derived naming; keep schema composition intact.
libs/wire-api/src/Wire/API/Team/Size.hs Switch objectWithDocModifier naming to derived naming.
libs/wire-api/src/Wire/API/Team/SearchVisibility.hs Switch enum/objectWithDocModifier naming to derived naming.
libs/wire-api/src/Wire/API/Team/Role.hs Switch enum naming to derived naming.
libs/wire-api/src/Wire/API/Team/Permission.hs Switch objectWithDocModifier naming to derived naming.
libs/wire-api/src/Wire/API/Team/Member/Info.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/Team/Member.hs Switch objects/enums to derived naming; add Typeable constraints for polymorphic schemas.
libs/wire-api/src/Wire/API/Team/LegalHold/Internal.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Team/LegalHold/External.hs Switch multiple schema objects to derived naming.
libs/wire-api/src/Wire/API/Team/LegalHold.hs Switch objects/enums to derived naming.
libs/wire-api/src/Wire/API/Team/Invitation.hs Switch objectWithDocModifier/object naming to derived naming.
libs/wire-api/src/Wire/API/Team/Feature.hs Add Typeable constraints; switch objects/enums to derived naming across feature schema types.
libs/wire-api/src/Wire/API/Team/Export.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Team/Conversation.hs Remove explicit object names from doc-modified schemas.
libs/wire-api/src/Wire/API/Team/Collaborator.hs Switch objects/enums to derived naming.
libs/wire-api/src/Wire/API/Team.hs Switch objectWithDocModifier/object/enum naming to derived naming.
libs/wire-api/src/Wire/API/SystemSettings.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/Routes/Version.hs Add versioned schema helpers and switch Version/VersionNumber schemas to derived enum naming.
libs/wire-api/src/Wire/API/Routes/Public/Spar.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/Routes/Public/Galley/Team.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Routes/Public/Galley/MLS.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Routes/Public/Brig/DomainVerification.hs Switch objects/enums to derived naming; add Typeable for versioned/newtype schemas.
libs/wire-api/src/Wire/API/Routes/Public/Brig.hs Remove explicit object name in doc-modified schema.
libs/wire-api/src/Wire/API/Routes/MultiTablePaging.hs Add Typeable constraints; switch page/request schemas to derived naming.
libs/wire-api/src/Wire/API/Routes/Internal/Galley/TeamsIntra.hs Switch objects/enums to derived naming.
libs/wire-api/src/Wire/API/Routes/Internal/Galley/TeamFeatureNoConfigMulti.hs Add Typeable constraints; switch schema object to derived naming.
libs/wire-api/src/Wire/API/Routes/Internal/Galley/ConversationsIntra.hs Switch objects/enums to derived naming.
libs/wire-api/src/Wire/API/Routes/Internal/Brig/EJPD.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/Routes/Internal/Brig/Connection.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/Routes/Internal/Brig.hs Switch schema objects/enums to derived naming; adjust nested object schema usage.
libs/wire-api/src/Wire/API/Routes/FederationDomainConfig.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/Push/V2/Token.hs Switch objectWithDocModifier/enum naming to derived naming.
libs/wire-api/src/Wire/API/Push/V2.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/Provider/Service/Tag.hs Switch enum naming to derived naming.
libs/wire-api/src/Wire/API/Provider/Service.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/Provider/Bot.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/Provider.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/Presence.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Password.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Pagination.hs Switch enum naming to derived naming.
libs/wire-api/src/Wire/API/OAuth.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/Notification.hs Switch objectWithDocModifier naming to derived naming.
libs/wire-api/src/Wire/API/Message.hs Switch schema objects/enums to derived naming; remove explicit names from doc-modified objects.
libs/wire-api/src/Wire/API/Meeting.hs Switch objectWithDocModifier/enum naming to derived naming.
libs/wire-api/src/Wire/API/MLS/SubConversation.hs Switch schemas to derived naming; keep explicit naming where versioned.
libs/wire-api/src/Wire/API/MLS/Message.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/MLS/Keys.hs Add Typeable constraints; switch schema objects to derived naming.
libs/wire-api/src/Wire/API/MLS/KeyPackage.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/MLS/Credential.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Internal/Notification.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Internal/BulkPush.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/History.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/FederationStatus.hs Switch objectWithDocModifier naming to derived naming.
libs/wire-api/src/Wire/API/Event/WebSocketProtocol.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/Event/Team.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/Event/LeaveReason.hs Switch enum naming to derived naming.
libs/wire-api/src/Wire/API/Event/Federation.hs Switch enum/object naming to derived naming.
libs/wire-api/src/Wire/API/Event/FeatureConfig.hs Add Typeable constraints; switch enum/object naming to derived naming.
libs/wire-api/src/Wire/API/Event/Conversation.hs Switch schema objects/enums to derived naming; remove explicit names in doc-modified objects.
libs/wire-api/src/Wire/API/Error/Galley.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/Error.hs Switch objectWithDocModifier/enum naming to derived naming.
libs/wire-api/src/Wire/API/EnterpriseLogin.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/CustomBackend.hs Switch objectWithDocModifier naming to derived naming.
libs/wire-api/src/Wire/API/Conversation/Typing.hs Switch schema object/enum naming to derived naming.
libs/wire-api/src/Wire/API/Conversation/Protocol.hs Switch schema objects/enums to derived naming for protocol/versioned protocol.
libs/wire-api/src/Wire/API/Conversation/Pagination.hs Switch objectWithDocModifier/object naming to derived naming.
libs/wire-api/src/Wire/API/Conversation/Member.hs Switch objectWithDocModifier/object naming to derived naming; keep validation logic intact.
libs/wire-api/src/Wire/API/Conversation/Config.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Conversation/Code.hs Remove explicit object names from doc-modified schema.
libs/wire-api/src/Wire/API/Conversation/CellsState.hs Switch enum naming to derived naming.
libs/wire-api/src/Wire/API/Conversation/Bot.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/Conversation/Action/Tag.hs Switch enum naming to derived naming.
libs/wire-api/src/Wire/API/Conversation/Action.hs Remove explicit object names from doc-modified schema.
libs/wire-api/src/Wire/API/Conversation.hs Add versioned schema helpers usage; add Typeable constraints for polymorphic list schemas; switch many objects/enums to derived naming.
libs/wire-api/src/Wire/API/Connection.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/Component.hs Switch enum naming to derived naming.
libs/wire-api/src/Wire/API/Call/Config.hs Switch objectWithDocModifier/object/enum naming to derived naming.
libs/wire-api/src/Wire/API/Bot/Service.hs Switch schema object to derived naming.
libs/wire-api/src/Wire/API/Bot.hs Switch schema objects to derived naming.
libs/wire-api/src/Wire/API/BackgroundJobs.hs Switch schema objects/enums to derived naming.
libs/wire-api/src/Wire/API/Asset.hs Switch schema objects/enums to derived naming.
libs/wire-api-federation/src/Wire/API/Federation/Version.hs Switch enums/objects to derived naming.
libs/wire-api-federation/src/Wire/API/Federation/BackendNotifications.hs Add Typeable constraint for PayloadBundle schema; switch schema naming to derived naming.
libs/wire-api-federation/src/Wire/API/Federation/API.hs Add Typeable constraints needed by derived schema naming.
libs/wai-utilities/src/Network/Wai/Utilities/JSONResponse.hs Switch schema object to derived naming.
libs/types-common/src/Data/Qualified.hs Add Typeable constraints; switch qualified schemas to derived naming.
libs/types-common/src/Data/LegalHold.hs Switch enum naming to derived naming.
libs/types-common/src/Data/Id.hs Add Typeable constraints; switch ID object schema to derived naming.
libs/types-common/src/Data/HavePendingInvitations.hs Switch enum naming to derived naming.
libs/types-common/src/Data/Code.hs Switch schema object to derived naming.
libs/schema-profunctor/test/unit/Test/Data/Schema.hs Update tests to use derived naming forms and new combinators.
libs/schema-profunctor/src/Data/Schema.hs Introduce derived-name object/enum; add namedObject/namedEnum variants and mkSchemaName.
libs/saml2-web-sso/src/SAML2/WebSSO/Types.hs Switch schema objects/enums to derived naming; add Typeable constraint where needed.
libs/saml2-web-sso/src/SAML2/WebSSO/Orphans.hs Switch enum naming to derived naming.
libs/saml2-web-sso/src/SAML2/WebSSO/Config.hs Switch schema objects to derived naming.
hack/bin/generate-clients.sh Add helper script for downloading swagger.json and generating TS/Kotlin clients via openapi-generator.
changelog.d/4-docs/swagger-hacking Changelog entry documenting the schema naming change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/wire-api/src/Wire/API/User/Client.hs
Comment thread libs/wire-api/src/Wire/API/Team/Feature.hs
Comment thread libs/wire-api/src/Wire/API/Team/Feature.hs
Comment thread libs/wire-api/src/Wire/API/Routes/Version.hs
Comment thread libs/schema-profunctor/src/Data/Schema.hs Outdated
Comment thread libs/wire-api/src/Wire/API/Routes/MultiTablePaging.hs
Comment thread libs/types-common/src/Data/Qualified.hs
Comment thread libs/wire-api/src/Wire/API/User/Scim.hs Outdated
Copy link
Copy Markdown
Contributor

@blackheaven blackheaven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many TODOs and lints to handle, but I'm fine with it.

Comment thread libs/saml2-web-sso/src/SAML2/WebSSO/Types.hs
Comment thread libs/wire-api/src/Wire/API/Conversation/Protocol.hs Outdated
@fisx
Copy link
Copy Markdown
Contributor Author

fisx commented Mar 25, 2026

oops, it's not quite as easy: now the names in the schema declarations are new and neat, but the references still follow the old, clashing pattern. need to think about it more!

Comment thread hack/bin/generate-clients.sh
Comment thread libs/saml2-web-sso/src/SAML2/WebSSO/Types.hs
@fisx fisx force-pushed the fisx/openapi-swagger-hacking branch 2 times, most recently from 7cdeafe to 0819cc2 Compare March 26, 2026 22:16
@fisx fisx force-pushed the fisx/openapi-swagger-hacking branch from 67b7773 to a52ffe8 Compare April 7, 2026 10:26
fisx and others added 5 commits April 7, 2026 14:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
this is fine because the new derived name is at least as unique as
this one.
@fisx fisx force-pushed the fisx/openapi-swagger-hacking branch from a52ffe8 to 9e67f5e Compare April 7, 2026 12:17
fisx added 5 commits April 7, 2026 15:14
It now uses the hash of the unique type rep for disambiguation and
truncates unreasonably long names.
@fisx fisx force-pushed the fisx/openapi-swagger-hacking branch from 9e67f5e to 05d70bb Compare April 7, 2026 13:14
@fisx fisx merged commit 34ba0c0 into develop Apr 8, 2026
10 checks passed
@fisx fisx deleted the fisx/openapi-swagger-hacking branch April 8, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants