Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Entity type ID shorthand #2

Merged
merged 8 commits into from
Mar 19, 2024
Merged

Feature: Entity type ID shorthand #2

merged 8 commits into from
Mar 19, 2024

Conversation

aaronsky
Copy link
Owner

This PR uses an experimental version of CreateAPI based on CreateAPI/CreateAPI#170 that enhances support around default values. Notably, the App Store Connect API schema doesn't use defaults at all, but there are several cases across the API where a required property is given a variant type with exactly one variant (such as type IDs). In this situation, there is an implied default value that can be provided, which subtly cleans up the call site in common situations.

For example, here is a code snippet before this PR:

_ = try await client.send(
    Resources.v1.betaTesterInvitations.post(
        .init(
            data: .init(
                type: .betaTesterInvitations,
                relationships: .init(
                    betaTester: .init(
                        data: .init(
                            type: .betaTesters,
                            id: tester.id
                        )
                    ),
                    app: .init(
                        data: .init(
                            type: .apps,
                            id: app.id
                        )
                    )
                )
            )
        )
    )
)

And here it is after the change:

_ = try await client.send(
    Resources.v1.betaTesterInvitations.post(
        .init(
            data: .init(
                relationships: .init(
                    betaTester: .init(data: .init(id: tester.id)),
                    app: .init(data: .init(id: app.id))
                )
            )
        )
    )
)

@aaronsky aaronsky merged commit 637a2bc into main Mar 19, 2024
4 checks passed
@aaronsky aaronsky deleted the type-id-shorthand branch March 19, 2024 11:40
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.

Offer default values provided by the spec in the generated code
1 participant