Skip to content

Add a mechanism to generate Identifiable conformance when types include an id property #806

@edorphy

Description

@edorphy

Motivation

I'm using this project to generate client and types for the App Store Connect API.

Every single object type from the API includes an ID property. When rendering results in SwiftUI, ForEach is our friend, but, the types are not identifiable by default. I have to create a conformance to Identifiable for everything by hand.

Proposed solution

Provide a configuration option to allow a type to add Identifiable conformance in the generated code if it includes an id property with a supported Identifiable type.

This is supported by the CreateAPI tool and would be a good feature to replicate. I want to move to as little modifications as possible.

Alternatives considered

Do things by hand and type this out. I'm only using a subset of the API and I still probably missed types that should conform.

extension Components.Schemas.AgeRatingDeclaration: Identifiable { }

extension Components.Schemas.AlternativeDistributionPackage: Identifiable { }

extension Components.Schemas.AppClipDefaultExperience: Identifiable { }

extension Components.Schemas.AppClip: Identifiable { }

extension Components.Schemas.AppCustomProductPage: Identifiable { }

extension Components.Schemas.AppEncryptionDeclaration: Identifiable { }

extension Components.Schemas.AppEvent: Identifiable { }

extension Components.Schemas.AppInfo: Identifiable { }

extension Components.Schemas.AppPreviewSet: Identifiable { }

extension Components.Schemas.AppScreenshotSet: Identifiable { }

extension Components.Schemas.AppStoreReviewDetail: Identifiable { }

extension Components.Schemas.AppStoreVersionExperimentV2: Identifiable { }

extension Components.Schemas.AppStoreVersionLocalization: Identifiable { }

extension Components.Schemas.AppStoreVersionPhasedRelease: Identifiable { }

extension Components.Schemas.AppStoreVersion: Identifiable { }

extension Components.Schemas.App: Identifiable { }

extension Components.Schemas.BetaAppLocalization: Identifiable { }

extension Components.Schemas.BetaAppReviewDetail: Identifiable { }

extension Components.Schemas.BetaAppReviewSubmission: Identifiable { }

extension Components.Schemas.BetaBuildLocalization: Identifiable { }

extension Components.Schemas.BetaCrashLog: Identifiable { }

extension Components.Schemas.BetaFeedbackCrashSubmission: Identifiable { }

extension Components.Schemas.BetaFeedbackScreenshotSubmission: Identifiable { }

extension Components.Schemas.BetaGroup: Identifiable { }

extension Components.Schemas.BetaLicenseAgreement: Identifiable { }

extension Components.Schemas.BetaTester: Identifiable { }

extension Components.Schemas.BuildBetaDetail: Identifiable { }

extension Components.Schemas.BuildBundle: Identifiable { }

extension Components.Schemas.BuildIcon: Identifiable { }

extension Components.Schemas.Build: Identifiable { }

extension Components.Schemas.BundleId: Identifiable { }

extension Components.Schemas.CiArtifact: Identifiable { }

extension Components.Schemas.CiBuildAction: Identifiable { }

extension Components.Schemas.CiBuildRun: Identifiable { }

extension Components.Schemas.CiMacOsVersion: Identifiable { }

extension Components.Schemas.CiProduct: Identifiable { }

extension Components.Schemas.CiWorkflow: Identifiable { }

extension Components.Schemas.CiXcodeVersion: Identifiable { }

extension Components.Schemas.EndUserLicenseAgreement: Identifiable { }

extension Components.Schemas.GameCenterAppVersion: Identifiable { }

extension Components.Schemas.GameCenterDetail: Identifiable { }

extension Components.Schemas.InAppPurchaseV2: Identifiable { }

extension Components.Schemas.PrereleaseVersion: Identifiable { }

extension Components.Schemas.PromotedPurchase: Identifiable { }

extension Components.Schemas.ReviewSubmission: Identifiable { }

extension Components.Schemas.RoutingAppCoverage: Identifiable { }

extension Components.Schemas.ScmGitReference: Identifiable { }

extension Components.Schemas.ScmPullRequest: Identifiable { }

extension Components.Schemas.SubscriptionGracePeriod: Identifiable { }

extension Components.Schemas.SubscriptionGroup: Identifiable { }

extension Components.Schemas.User: Identifiable { }

Additional information

See CreateAPI and Swift Lee utilizing it in another App Store Connect client codebase:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions