Overhauled the library with several new features #5

Merged
javier merged 15 commits from library/api-update into main 2026-10-25 17:52:41 +00:00
7 changed files with 1012376 additions and 20 deletions
Showing only changes of commit a303150963 - Show all commits

No files matched your search

+3
View File
@@ -26,6 +26,9 @@ OAS_DOWNLOAD_FILE=$(OAS_DOWNLOAD_FOLDER)/openapi.oas.json
OAS_DOWNLOAD_INPUT=$(OAS_DOWNLOAD_FOLDER)/asconnect-openapi-specification.zip
OAS_DOWNLOAD_OUTPUT=Sources/$(SPM_LIBRARY_TARGET)/openapi.json
OAS_DOWNLOAD_URL=https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip
OAS_GENERATE_CONFIG=Sources/$(SPM_LIBRARY_TARGET)/openapi-generator-config.yaml
OAS_GENERATE_OUTPUT=Sources/$(SPM_LIBRARY_TARGET)/Sources/Public/Generated
OAS_GENERATE_TOOLS=./Tools
# -- SWIFT PACKAGE MANAGER ---
+14 -3
View File
@@ -62,7 +62,7 @@ pkg-update: ## Updates the SPM package dependencies
doc-generate: doc-generate-archive doc-generate-github ## Generates the library documentation for both Github and Xcode
doc-generate-archive: ## Generates the library documentation archive for Xcode
@swift package \
@ENABLE_DOCC_PLUGIN=1 swift package \
--allow-writing-to-directory $(DOCC_ARCHIVE_OUTPUT) \
generate-documentation \
--target $(SPM_LIBRARY_TARGET) \
@@ -71,7 +71,7 @@ doc-generate-archive: ## Generates the library documentation archive for Xcode
--output-path $(DOCC_ARCHIVE_OUTPUT)
doc-generate-github: ## Generates the library documentation for Github
@swift package \
@ENABLE_DOCC_PLUGIN=1 swift package \
--allow-writing-to-directory $(DOCC_GITHUB_OUTPUT) \
generate-documentation \
--target $(SPM_LIBRARY_TARGET) \
@@ -84,7 +84,7 @@ doc-generate-github: ## Generates the library documentation for Github
doc-preview: ## Previews the library documentation in Safari
@open -a safari $(DOCC_PREVIEW_URL)
@swift package \
@ENABLE_DOCC_PLUGIN=1 swift package \
--disable-sandbox \
preview-documentation \
--target $(SPM_LIBRARY_TARGET) \
@@ -102,11 +102,22 @@ oas-download: ## Downloads the latest App Store Connect OpenAPI specification do
@mv "$(OAS_DOWNLOAD_FILE)" "$(OAS_DOWNLOAD_OUTPUT)"
@rm -rf "$(OAS_DOWNLOAD_FOLDER)"
@$(MAKE) --no-print-directory oas-patch
@$(MAKE) --no-print-directory oas-generate
oas-patch: # Patches the OpenAPI specification document with the patches in Scripts/patch-oas.jq
@jq --from-file Scripts/patch-oas.jq "$(OAS_DOWNLOAD_OUTPUT)" > "$(OAS_DOWNLOAD_OUTPUT).tmp"
@mv "$(OAS_DOWNLOAD_OUTPUT).tmp" "$(OAS_DOWNLOAD_OUTPUT)"
oas-generate: ## Generates the library source code from the OpenAPI specification document
@mkdir -p "$(OAS_GENERATE_OUTPUT)"
@swift run \
--configuration release \
--package-path "$(OAS_GENERATE_TOOLS)" \
swift-openapi-generator generate \
--config "$(OAS_GENERATE_CONFIG)" \
--output-directory "$(OAS_GENERATE_OUTPUT)" \
"$(OAS_DOWNLOAD_OUTPUT)"
# IDE
ide-xcode: ## Opens this package with Xcode
+14 -6
View File
@@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===
import class Foundation.ProcessInfo
import PackageDescription
let package = Package(
@@ -30,10 +31,9 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator.git", exact: "1.11.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.5.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.2"),
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.1.0")
// Must be at least the runtime version required by the generator in `Tools`.
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.11.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.2")
],
targets: [
.target(
@@ -43,8 +43,9 @@ let package = Package(
.product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession")
],
path: "Sources/ASConnectService",
plugins: [
.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")
exclude: [
"openapi.json",
"openapi-generator-config.yaml"
]
),
.testTarget(
@@ -57,6 +58,13 @@ let package = Package(
]
)
// Only added by the documentation targets, so consumers don't resolve it.
if ProcessInfo.processInfo.environment["ENABLE_DOCC_PLUGIN"] != nil {
package.dependencies.append(
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.1.0")
)
}
// MARK: - Constants
enum AppStoreConnectService {
+18 -11
View File
@@ -4,9 +4,7 @@ A Swift client library for the App Store Connect API, generated from the officia
## Overview
`ASConnectService` provides a type-safe, Swift-native interface to Apple's App Store Connect API. This package enables developers to programmatically interact with App Store Connect services for managing apps, builds, reviews, sales reports, and more.
The library is automatically generated from the official App Store Connect API OpenAPI specification using Apple's [swift-openapi-generator](https://github.com/apple/swift-openapi-generator), ensuring complete API coverage and type safety.
`ASConnectService` exposes every endpoint of Apple's App Store Connect API as a Swift method with typed requests and responses. It's generated from the official OpenAPI specification with [Swift OpenAPI Generator](https://github.com/apple/swift-openapi-generator).
## Installation
@@ -33,13 +31,7 @@ Then add it to your target dependencies:
### Creating a Client
Create a `Client` instance by providing a server URL and transport. Use `BearerAuthMiddleware` to authenticate requests with a JSON Web Token (JWT).
The App Store Connect API requires authentication using API keys. You'll need to:
1. Create an API key in App Store Connect
2. Generate a signed JWT token using your key ID, issuer ID, and private key
3. Pass the token to the built-in `BearerAuthMiddleware` when creating the client
Create a `Client` with a server URL, a transport, and a `BearerAuthMiddleware` that authenticates each request with a JSON Web Token (JWT). To get a token, create an API key in App Store Connect and sign a JWT with its key ID, issuer ID, and private key:
```swift
import ASConnectService
@@ -123,11 +115,26 @@ make doc-generate-github
make doc-preview
```
### Updating the API
The generated code is committed in `Sources/ASConnectService/Sources/Public/Generated`, so consumers don't run the generator.
```bash
# Update to the latest specification
make oas-download
# Regenerate the code only
make oas-generate
```
## Dependencies
- [swift-openapi-generator](https://github.com/apple/swift-openapi-generator)
- [swift-openapi-runtime](https://github.com/apple/swift-openapi-runtime)
- [swift-openapi-urlsession](https://github.com/apple/swift-openapi-urlsession)
Development only:
- [swift-openapi-generator](https://github.com/apple/swift-openapi-generator), in `Tools`
- [swift-docc-plugin](https://github.com/swiftlang/swift-docc-plugin)
## License
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+28
View File
@@ -0,0 +1,28 @@
// swift-tools-version: 5.10
// ===----------------------------------------------------------------------===
//
// This source file is part of the ASConnectService open source project
//
// Copyright (c) 2026 Röck+Cöde VoF. and the ASConnectService project authors
// Licensed under Apache license v2.0
//
// See LICENSE for license information
// See CONTRIBUTORS for the list of ASConnectService project authors
//
// SPDX-License-Identifier: Apache-2.0
//
// ===----------------------------------------------------------------------===
import PackageDescription
// Development tools, kept out of the main package so consumers don't resolve them.
let package = Package(
name: "asconnect-service-tools",
platforms: [
.macOS(.v10_15)
],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator.git", exact: "1.11.0")
]
)