Skip to content

Commit

Permalink
Merge pull request #208 from liamnichols/ln/regenerate-code-for-2-1
Browse files Browse the repository at this point in the history
Regenerated code for App Store Connect API 2.1 changes
  • Loading branch information
AvdLee authored Oct 11, 2022
2 parents 7d88424 + b873729 commit 23d108d
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 28 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/sync_asc_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
# Grab the latest spec and perform some manual coersion to fix errors.
# (see https://github.com/AvdLee/appstoreconnect-swift-sdk/pull/197)
- run: curl -fsSL -o - https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip | bsdtar -xOf - | jq '.components.schemas.BundleIdPlatform.enum |= [ "IOS", "MAC_OS", "UNIVERSAL" ] | del(.["x-important"])' > Sources/OpenAPI/app_store_connect_api_2.0_openapi.json
- run: make download

# If there are any differences, this step will fail
# and issue a notification. The api will then need to be
Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Downloads latest spec and Regenerates source code
.PHONY: update
update: download generate

# Grabs the latest spec and perform some manual coersion to fix errors
# see https://github.com/AvdLee/appstoreconnect-swift-sdk/pull/197
.PHONY: download
download:
curl -fsSL -o - https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip | bsdtar -xOf - | jq '.components.schemas.BundleIdPlatform.enum |= [ "IOS", "MAC_OS", "UNIVERSAL" ] | del(.["x-important"]) | del(.. |."enum"? | select(. != null and length == 0))' > Sources/OpenAPI/app_store_connect_api_2.0_openapi.json

# Runs the CreateAPI generator to update generated source code
.PHONY: generate
generate:
swift package --allow-writing-to-package-directory generate-open-api
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let request = APIEndpoint
fieldsApps: [.appInfos, .name, .bundleID],
limit: 2
))

// Demonstration of AsyncSequence result of APIProvider.paged(_)
var allApps: [App] = []
for try await pagedResult in provider.paged(request) {
Expand All @@ -90,13 +90,13 @@ let firstPageResult = try await provider.request(request)
let firstPageApps = firstPageResult.data
print("The first page of results has \(firstPageApps.count) apps")

if provider.request(request, isPagedResponse: firstPageResult) {
if provider.request(request, isPagedResponse: firstPageResult) {
if let nextPage = try await provider.request(request, pageAfter: firstPageResult) {
let secondPageApps = nextPage.data
print("The second page of results has \(secondPageApps.count) apps")
}
}
```
}
```

### Handling errors
Whenever an error is returned from a request, you can get the details by catching the error as follows:
Expand All @@ -123,7 +123,7 @@ For more info regarding errors, see: [Parsing the Error Response Code](https://d

### Swift Package Manager

The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but this SDK does support its use on supported platforms.
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but this SDK does support its use on supported platforms.

Once you have your Swift package set up, adding the SDK as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.

Expand All @@ -138,7 +138,7 @@ dependencies: [
To help with the development of this repository you need to follow the next steps:

- clone this repository
- download the submodules dependencies
- download the submodules dependencies
```bash
git submodule update --init --recursive
```
Expand All @@ -148,12 +148,17 @@ bundle exec fastlane test
```

### Update OpenAPI generated code
Using [CreateAPI](https://github.com/CreateAPI/CreateAPI), run the following:

Run the following:

```bash
$ swift package --allow-writing-to-package-directory generate-open-api
$ make update
```

This will attempt to download the App Store Connect [OpenAPI specification](https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip) from Apple, and re-run the [CreateAPI](https://github.com/CreateAPI/CreateAPI) generator to produce the updated source code.

Alternatively, you can run `make download` and `make generate` individually.

## Communication

- If you **found a bug**, open an [issue](https://github.com/AvdLee/appstoreconnect-swift-sdk/issues).
Expand Down
1 change: 1 addition & 0 deletions Sources/OpenAPI/Generated/Entities/BundleIDPlatform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ import Foundation
public enum BundleIDPlatform: String, Codable, CaseIterable {
case ios = "IOS"
case macOs = "MAC_OS"
case universal = "UNIVERSAL"
}
4 changes: 2 additions & 2 deletions Sources/OpenAPI/Generated/Entities/PreviewType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import Foundation

public enum PreviewType: String, Codable, CaseIterable {
case iphone67 = "IPHONE_67"
case iphone61 = "IPHONE_61"
case iphone65 = "IPHONE_65"
case iphone58 = "IPHONE_58"
case iphone55 = "IPHONE_55"
Expand All @@ -18,7 +20,5 @@ public enum PreviewType: String, Codable, CaseIterable {
case ipad105 = "IPAD_105"
case ipad97 = "IPAD_97"
case desktop = "DESKTOP"
case watchSeries4 = "WATCH_SERIES_4"
case watchSeries3 = "WATCH_SERIES_3"
case appleTv = "APPLE_TV"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import Foundation

public enum ScreenshotDisplayType: String, Codable, CaseIterable {
case appIphone67 = "APP_IPHONE_67"
case appIphone61 = "APP_IPHONE_61"
case appIphone65 = "APP_IPHONE_65"
case appIphone58 = "APP_IPHONE_58"
case appIphone55 = "APP_IPHONE_55"
Expand All @@ -18,10 +20,13 @@ public enum ScreenshotDisplayType: String, Codable, CaseIterable {
case appIpad105 = "APP_IPAD_105"
case appIpad97 = "APP_IPAD_97"
case appDesktop = "APP_DESKTOP"
case appWatchUltra = "APP_WATCH_ULTRA"
case appWatchSeries7 = "APP_WATCH_SERIES_7"
case appWatchSeries4 = "APP_WATCH_SERIES_4"
case appWatchSeries3 = "APP_WATCH_SERIES_3"
case appAppleTv = "APP_APPLE_TV"
case imessageAppIphone67 = "IMESSAGE_APP_IPHONE_67"
case imessageAppIphone61 = "IMESSAGE_APP_IPHONE_61"
case imessageAppIphone65 = "IMESSAGE_APP_IPHONE_65"
case imessageAppIphone58 = "IMESSAGE_APP_IPHONE_58"
case imessageAppIphone55 = "IMESSAGE_APP_IPHONE_55"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extension APIEndpoint.V1.AppCustomProductPageLocalizations.WithID {
public var include: [Include]?

public enum FilterPreviewType: String, Codable, CaseIterable {
case iphone67 = "IPHONE_67"
case iphone61 = "IPHONE_61"
case iphone65 = "IPHONE_65"
case iphone58 = "IPHONE_58"
case iphone55 = "IPHONE_55"
Expand All @@ -45,8 +47,6 @@ extension APIEndpoint.V1.AppCustomProductPageLocalizations.WithID {
case ipad105 = "IPAD_105"
case ipad97 = "IPAD_97"
case desktop = "DESKTOP"
case watchSeries4 = "WATCH_SERIES_4"
case watchSeries3 = "WATCH_SERIES_3"
case appleTv = "APPLE_TV"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extension APIEndpoint.V1.AppCustomProductPageLocalizations.WithID {
public var include: [Include]?

public enum FilterScreenshotDisplayType: String, Codable, CaseIterable {
case appIphone67 = "APP_IPHONE_67"
case appIphone61 = "APP_IPHONE_61"
case appIphone65 = "APP_IPHONE_65"
case appIphone58 = "APP_IPHONE_58"
case appIphone55 = "APP_IPHONE_55"
Expand All @@ -45,10 +47,13 @@ extension APIEndpoint.V1.AppCustomProductPageLocalizations.WithID {
case appIpad105 = "APP_IPAD_105"
case appIpad97 = "APP_IPAD_97"
case appDesktop = "APP_DESKTOP"
case appWatchUltra = "APP_WATCH_ULTRA"
case appWatchSeries7 = "APP_WATCH_SERIES_7"
case appWatchSeries4 = "APP_WATCH_SERIES_4"
case appWatchSeries3 = "APP_WATCH_SERIES_3"
case appAppleTv = "APP_APPLE_TV"
case imessageAppIphone67 = "IMESSAGE_APP_IPHONE_67"
case imessageAppIphone61 = "IMESSAGE_APP_IPHONE_61"
case imessageAppIphone65 = "IMESSAGE_APP_IPHONE_65"
case imessageAppIphone58 = "IMESSAGE_APP_IPHONE_58"
case imessageAppIphone55 = "IMESSAGE_APP_IPHONE_55"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extension APIEndpoint.V1.AppStoreVersionExperimentTreatmentLocalizations.WithID
public var include: [Include]?

public enum FilterPreviewType: String, Codable, CaseIterable {
case iphone67 = "IPHONE_67"
case iphone61 = "IPHONE_61"
case iphone65 = "IPHONE_65"
case iphone58 = "IPHONE_58"
case iphone55 = "IPHONE_55"
Expand All @@ -45,8 +47,6 @@ extension APIEndpoint.V1.AppStoreVersionExperimentTreatmentLocalizations.WithID
case ipad105 = "IPAD_105"
case ipad97 = "IPAD_97"
case desktop = "DESKTOP"
case watchSeries4 = "WATCH_SERIES_4"
case watchSeries3 = "WATCH_SERIES_3"
case appleTv = "APPLE_TV"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extension APIEndpoint.V1.AppStoreVersionExperimentTreatmentLocalizations.WithID
public var include: [Include]?

public enum FilterScreenshotDisplayType: String, Codable, CaseIterable {
case appIphone67 = "APP_IPHONE_67"
case appIphone61 = "APP_IPHONE_61"
case appIphone65 = "APP_IPHONE_65"
case appIphone58 = "APP_IPHONE_58"
case appIphone55 = "APP_IPHONE_55"
Expand All @@ -45,10 +47,13 @@ extension APIEndpoint.V1.AppStoreVersionExperimentTreatmentLocalizations.WithID
case appIpad105 = "APP_IPAD_105"
case appIpad97 = "APP_IPAD_97"
case appDesktop = "APP_DESKTOP"
case appWatchUltra = "APP_WATCH_ULTRA"
case appWatchSeries7 = "APP_WATCH_SERIES_7"
case appWatchSeries4 = "APP_WATCH_SERIES_4"
case appWatchSeries3 = "APP_WATCH_SERIES_3"
case appAppleTv = "APP_APPLE_TV"
case imessageAppIphone67 = "IMESSAGE_APP_IPHONE_67"
case imessageAppIphone61 = "IMESSAGE_APP_IPHONE_61"
case imessageAppIphone65 = "IMESSAGE_APP_IPHONE_65"
case imessageAppIphone58 = "IMESSAGE_APP_IPHONE_58"
case imessageAppIphone55 = "IMESSAGE_APP_IPHONE_55"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extension APIEndpoint.V1.AppStoreVersionLocalizations.WithID {
public var include: [Include]?

public enum FilterPreviewType: String, Codable, CaseIterable {
case iphone67 = "IPHONE_67"
case iphone61 = "IPHONE_61"
case iphone65 = "IPHONE_65"
case iphone58 = "IPHONE_58"
case iphone55 = "IPHONE_55"
Expand All @@ -45,8 +47,6 @@ extension APIEndpoint.V1.AppStoreVersionLocalizations.WithID {
case ipad105 = "IPAD_105"
case ipad97 = "IPAD_97"
case desktop = "DESKTOP"
case watchSeries4 = "WATCH_SERIES_4"
case watchSeries3 = "WATCH_SERIES_3"
case appleTv = "APPLE_TV"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extension APIEndpoint.V1.AppStoreVersionLocalizations.WithID {
public var include: [Include]?

public enum FilterScreenshotDisplayType: String, Codable, CaseIterable {
case appIphone67 = "APP_IPHONE_67"
case appIphone61 = "APP_IPHONE_61"
case appIphone65 = "APP_IPHONE_65"
case appIphone58 = "APP_IPHONE_58"
case appIphone55 = "APP_IPHONE_55"
Expand All @@ -45,10 +47,13 @@ extension APIEndpoint.V1.AppStoreVersionLocalizations.WithID {
case appIpad105 = "APP_IPAD_105"
case appIpad97 = "APP_IPAD_97"
case appDesktop = "APP_DESKTOP"
case appWatchUltra = "APP_WATCH_ULTRA"
case appWatchSeries7 = "APP_WATCH_SERIES_7"
case appWatchSeries4 = "APP_WATCH_SERIES_4"
case appWatchSeries3 = "APP_WATCH_SERIES_3"
case appAppleTv = "APP_APPLE_TV"
case imessageAppIphone67 = "IMESSAGE_APP_IPHONE_67"
case imessageAppIphone61 = "IMESSAGE_APP_IPHONE_61"
case imessageAppIphone65 = "IMESSAGE_APP_IPHONE_65"
case imessageAppIphone58 = "IMESSAGE_APP_IPHONE_58"
case imessageAppIphone55 = "IMESSAGE_APP_IPHONE_55"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension APIEndpoint.V1.SubscriptionOfferCodeOneTimeUseCodes {
public struct GetParameters {
public var fieldsSubscriptionOfferCodeOneTimeUseCodes: [FieldsSubscriptionOfferCodeOneTimeUseCodes]?
public var include: [Include]?
public var fieldsSubscriptionOfferCodeOneTimeUseCodeValues: [FieldsSubscriptionOfferCodeOneTimeUseCodeValues]?
public var fieldsSubscriptionOfferCodeOneTimeUseCodeValues: [String]?

public enum FieldsSubscriptionOfferCodeOneTimeUseCodes: String, Codable, CaseIterable {
case active
Expand All @@ -37,11 +37,7 @@ extension APIEndpoint.V1.SubscriptionOfferCodeOneTimeUseCodes {
case offerCode
}

public enum FieldsSubscriptionOfferCodeOneTimeUseCodeValues: String, Codable, CaseIterable {
case empty
}

public init(fieldsSubscriptionOfferCodeOneTimeUseCodes: [FieldsSubscriptionOfferCodeOneTimeUseCodes]? = nil, include: [Include]? = nil, fieldsSubscriptionOfferCodeOneTimeUseCodeValues: [FieldsSubscriptionOfferCodeOneTimeUseCodeValues]? = nil) {
public init(fieldsSubscriptionOfferCodeOneTimeUseCodes: [FieldsSubscriptionOfferCodeOneTimeUseCodes]? = nil, include: [Include]? = nil, fieldsSubscriptionOfferCodeOneTimeUseCodeValues: [String]? = nil) {
self.fieldsSubscriptionOfferCodeOneTimeUseCodes = fieldsSubscriptionOfferCodeOneTimeUseCodes
self.include = include
self.fieldsSubscriptionOfferCodeOneTimeUseCodeValues = fieldsSubscriptionOfferCodeOneTimeUseCodeValues
Expand Down
4 changes: 1 addition & 3 deletions Sources/OpenAPI/app_store_connect_api_2.0_openapi.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"openapi": "3.0.1",
"x-important": "IMPORTANT: This OpenAPI Specification is only for use in accordance with the terms of the Apple Developer Program License Agreement and terms for the use of the App Store Connect API. You may not use this OpenAPI Specification unless you have agreed to the Apple Developer Program License Agreement, and You acknowledge and agree that the App Store Connect API (and use of this Specification in connection therewith) is for internal development, testing and reporting purposes within your team and not to provide services to any third parties or for any other use.",
"info": {
"title": "App Store Connect API",
"version": "2.1",
Expand Down Expand Up @@ -29680,8 +29679,7 @@
"schema": {
"type": "array",
"items": {
"type": "string",
"enum": []
"type": "string"
}
},
"style": "form",
Expand Down

0 comments on commit 23d108d

Please sign in to comment.