Make schema-profunctor schema names derived and avoid name clashes between scopes.#5151
Make schema-profunctor schema names derived and avoid name clashes between scopes.#5151
Conversation
e77f6dc to
b687c71
Compare
With this change, schema name is the fully qualified name of the haskell type. If that's not unique, we should probably change those type names. This will avoid collisions in the hash table keeping track of all the schema references in openapi3.
b687c71 to
9fd11c8
Compare
There was a problem hiding this comment.
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/enumto derive schema names automatically and introducenamedObject/namedEnumfor explicit naming. - Update many
ToSchemainstances and schema helpers across the codebase to use the new derived-name API and addTypeableconstraints 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.
|
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! |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…r-hacking' into fisx/openapi-swagger-hacking
5c79fa3 to
7cdeafe
Compare
this is fine because the new derived name is at least as unique as this one.
7cdeafe to
0819cc2
Compare
Co-authored-by: Gautier DI FOLCO <gautier.difolco@wire.com>
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:
namedObjectforobjectetc.)I will add a note to the V16 migration page in confluence that schema names may have changed in weird ways since V15. (Not sure anybody cares, just for completeness sakes.)
Checklist
changelog.d