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

Regenerated code for App Store Connect API 2.2 changes #220

Merged
merged 7 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ update: download generate
# 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
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.2_openapi.json

# Runs the CreateAPI generator to update generated source code
.PHONY: generate
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let package = Package(
.productItem(name: "Crypto", package: "swift-crypto")
],
path: "Sources",
exclude: ["OpenAPI/app_store_connect_api_2.0_openapi.json"]
exclude: ["OpenAPI/app_store_connect_api_2.2_openapi.json"]
),
.binaryTarget(
name: "create-api", // Find the URL and checksum at https://github.com/createapi/createapi/releases/latest
Expand Down
2 changes: 1 addition & 1 deletion [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ let package = Package(
name: "AppStoreConnect-Swift-SDK",
dependencies: ["URLQueryEncoder"],
path: "Sources",
exclude: ["OpenAPI/app_store_connect_api_2.0_openapi.json"])
exclude: ["OpenAPI/app_store_connect_api_2.2_openapi.json"])
]
)
2 changes: 1 addition & 1 deletion Plugins/CreateAPI/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Plugin: CommandPlugin {
process.executableURL = URL(fileURLWithPath: createAPI.path.string)
process.arguments = [
"generate",
"app_store_connect_api_2.0_openapi.json",
"app_store_connect_api_2.2_openapi.json",
"--module", "AppStoreConnect_Swift_SDK",
"--output", "Generated",
"--config", ".create-api.yml",
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ bundle exec fastlane test

### Update OpenAPI generated code

Install [jq](https://stedolan.github.io/jq/):
```bash
brew install jq
```

Run the following:

```bash
Expand Down
2 changes: 1 addition & 1 deletion Sources/Extensions/ErrorResponseExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension ErrorResponse: CustomStringConvertible {
errorString.append("""
\n\nThe request failed with response code \(error.status) \(error.code)

\(error.title). \(error.detail)
\(error.title). \(error.detail ?? "")
""")
})
return errorString
Expand Down
169 changes: 167 additions & 2 deletions Sources/OpenAPI/Generated/Entities/AppEncryptionDeclaration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,29 @@ public struct AppEncryptionDeclaration: Codable, Identifiable {
}

public struct Attributes: Codable {
public var appDescription: String?
public var createdDate: Date?
/// - warning: Deprecated.
public var usesEncryption: Bool?
public var isExempt: Bool?
public var containsProprietaryCryptography: Bool?
public var containsThirdPartyCryptography: Bool?
public var isAvailableOnFrenchStore: Bool?
public var platform: Platform?
/// - warning: Deprecated.
public var uploadedDate: Date?
/// - warning: Deprecated.
public var documentURL: String?
/// - warning: Deprecated.
public var documentName: String?
/// - warning: Deprecated.
public var documentType: String?
public var appEncryptionDeclarationState: AppEncryptionDeclarationState?
public var codeValue: String?

public init(usesEncryption: Bool? = nil, isExempt: Bool? = nil, containsProprietaryCryptography: Bool? = nil, containsThirdPartyCryptography: Bool? = nil, isAvailableOnFrenchStore: Bool? = nil, platform: Platform? = nil, uploadedDate: Date? = nil, documentURL: String? = nil, documentName: String? = nil, documentType: String? = nil, appEncryptionDeclarationState: AppEncryptionDeclarationState? = nil, codeValue: String? = nil) {
public init(appDescription: String? = nil, createdDate: Date? = nil, usesEncryption: Bool? = nil, isExempt: Bool? = nil, containsProprietaryCryptography: Bool? = nil, containsThirdPartyCryptography: Bool? = nil, isAvailableOnFrenchStore: Bool? = nil, platform: Platform? = nil, uploadedDate: Date? = nil, documentURL: String? = nil, documentName: String? = nil, documentType: String? = nil, appEncryptionDeclarationState: AppEncryptionDeclarationState? = nil, codeValue: String? = nil) {
self.appDescription = appDescription
self.createdDate = createdDate
self.usesEncryption = usesEncryption
self.isExempt = isExempt
self.containsProprietaryCryptography = containsProprietaryCryptography
Expand All @@ -47,6 +56,8 @@ public struct AppEncryptionDeclaration: Codable, Identifiable {

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.appDescription = try values.decodeIfPresent(String.self, forKey: "appDescription")
self.createdDate = try values.decodeIfPresent(Date.self, forKey: "createdDate")
self.usesEncryption = try values.decodeIfPresent(Bool.self, forKey: "usesEncryption")
self.isExempt = try values.decodeIfPresent(Bool.self, forKey: "exempt")
self.containsProprietaryCryptography = try values.decodeIfPresent(Bool.self, forKey: "containsProprietaryCryptography")
Expand All @@ -63,6 +74,8 @@ public struct AppEncryptionDeclaration: Codable, Identifiable {

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encodeIfPresent(appDescription, forKey: "appDescription")
try values.encodeIfPresent(createdDate, forKey: "createdDate")
try values.encodeIfPresent(usesEncryption, forKey: "usesEncryption")
try values.encodeIfPresent(isExempt, forKey: "exempt")
try values.encodeIfPresent(containsProprietaryCryptography, forKey: "containsProprietaryCryptography")
Expand All @@ -80,6 +93,8 @@ public struct AppEncryptionDeclaration: Codable, Identifiable {

public struct Relationships: Codable {
public var app: App?
public var builds: Builds?
public var appEncryptionDeclarationDocument: AppEncryptionDeclarationDocument?

public struct App: Codable {
public var links: Links?
Expand Down Expand Up @@ -151,18 +166,168 @@ public struct AppEncryptionDeclaration: Codable, Identifiable {
}
}

public init(app: App? = nil) {
public struct Builds: Codable {
public var links: Links?
public var meta: PagingInformation?
public var data: [Datum]?

public struct Links: Codable {
public var this: String?
public var related: String?

public init(this: String? = nil, related: String? = nil) {
self.this = this
self.related = related
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.this = try values.decodeIfPresent(String.self, forKey: "self")
self.related = try values.decodeIfPresent(String.self, forKey: "related")
}

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encodeIfPresent(this, forKey: "self")
try values.encodeIfPresent(related, forKey: "related")
}
}

public struct Datum: Codable, Identifiable {
public var type: `Type`
public var id: String

public enum `Type`: String, Codable, CaseIterable {
case builds
}

public init(type: `Type`, id: String) {
self.type = type
self.id = id
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.type = try values.decode(`Type`.self, forKey: "type")
self.id = try values.decode(String.self, forKey: "id")
}

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encode(type, forKey: "type")
try values.encode(id, forKey: "id")
}
}

public init(links: Links? = nil, meta: PagingInformation? = nil, data: [Datum]? = nil) {
self.links = links
self.meta = meta
self.data = data
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.links = try values.decodeIfPresent(Links.self, forKey: "links")
self.meta = try values.decodeIfPresent(PagingInformation.self, forKey: "meta")
self.data = try values.decodeIfPresent([Datum].self, forKey: "data")
}

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encodeIfPresent(links, forKey: "links")
try values.encodeIfPresent(meta, forKey: "meta")
try values.encodeIfPresent(data, forKey: "data")
}
}

public struct AppEncryptionDeclarationDocument: Codable {
public var links: Links?
public var data: Data?

public struct Links: Codable {
public var this: String?
public var related: String?

public init(this: String? = nil, related: String? = nil) {
self.this = this
self.related = related
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.this = try values.decodeIfPresent(String.self, forKey: "self")
self.related = try values.decodeIfPresent(String.self, forKey: "related")
}

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encodeIfPresent(this, forKey: "self")
try values.encodeIfPresent(related, forKey: "related")
}
}

public struct Data: Codable, Identifiable {
public var type: `Type`
public var id: String

public enum `Type`: String, Codable, CaseIterable {
case appEncryptionDeclarationDocuments
}

public init(type: `Type`, id: String) {
self.type = type
self.id = id
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.type = try values.decode(`Type`.self, forKey: "type")
self.id = try values.decode(String.self, forKey: "id")
}

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encode(type, forKey: "type")
try values.encode(id, forKey: "id")
}
}

public init(links: Links? = nil, data: Data? = nil) {
self.links = links
self.data = data
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.links = try values.decodeIfPresent(Links.self, forKey: "links")
self.data = try values.decodeIfPresent(Data.self, forKey: "data")
}

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encodeIfPresent(links, forKey: "links")
try values.encodeIfPresent(data, forKey: "data")
}
}

public init(app: App? = nil, builds: Builds? = nil, appEncryptionDeclarationDocument: AppEncryptionDeclarationDocument? = nil) {
self.app = app
self.builds = builds
self.appEncryptionDeclarationDocument = appEncryptionDeclarationDocument
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.app = try values.decodeIfPresent(App.self, forKey: "app")
self.builds = try values.decodeIfPresent(Builds.self, forKey: "builds")
self.appEncryptionDeclarationDocument = try values.decodeIfPresent(AppEncryptionDeclarationDocument.self, forKey: "appEncryptionDeclarationDocument")
}

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encodeIfPresent(app, forKey: "app")
try values.encodeIfPresent(builds, forKey: "builds")
try values.encodeIfPresent(appEncryptionDeclarationDocument, forKey: "appEncryptionDeclarationDocument")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

public struct AppEncryptionDeclarationDocument: Codable, Identifiable {
public var type: `Type`
public var id: String
public var attributes: Attributes?
public var links: ResourceLinks

public enum `Type`: String, Codable, CaseIterable {
case appEncryptionDeclarationDocuments
}

public struct Attributes: Codable {
public var fileSize: Int?
public var fileName: String?
public var assetToken: String?
public var downloadURL: URL?
public var sourceFileChecksum: String?
public var uploadOperations: [UploadOperation]?
public var assetDeliveryState: AppMediaAssetState?

public init(fileSize: Int? = nil, fileName: String? = nil, assetToken: String? = nil, downloadURL: URL? = nil, sourceFileChecksum: String? = nil, uploadOperations: [UploadOperation]? = nil, assetDeliveryState: AppMediaAssetState? = nil) {
self.fileSize = fileSize
self.fileName = fileName
self.assetToken = assetToken
self.downloadURL = downloadURL
self.sourceFileChecksum = sourceFileChecksum
self.uploadOperations = uploadOperations
self.assetDeliveryState = assetDeliveryState
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.fileSize = try values.decodeIfPresent(Int.self, forKey: "fileSize")
self.fileName = try values.decodeIfPresent(String.self, forKey: "fileName")
self.assetToken = try values.decodeIfPresent(String.self, forKey: "assetToken")
self.downloadURL = try values.decodeIfPresent(URL.self, forKey: "downloadUrl")
self.sourceFileChecksum = try values.decodeIfPresent(String.self, forKey: "sourceFileChecksum")
self.uploadOperations = try values.decodeIfPresent([UploadOperation].self, forKey: "uploadOperations")
self.assetDeliveryState = try values.decodeIfPresent(AppMediaAssetState.self, forKey: "assetDeliveryState")
}

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encodeIfPresent(fileSize, forKey: "fileSize")
try values.encodeIfPresent(fileName, forKey: "fileName")
try values.encodeIfPresent(assetToken, forKey: "assetToken")
try values.encodeIfPresent(downloadURL, forKey: "downloadUrl")
try values.encodeIfPresent(sourceFileChecksum, forKey: "sourceFileChecksum")
try values.encodeIfPresent(uploadOperations, forKey: "uploadOperations")
try values.encodeIfPresent(assetDeliveryState, forKey: "assetDeliveryState")
}
}

public init(type: `Type`, id: String, attributes: Attributes? = nil, links: ResourceLinks) {
self.type = type
self.id = id
self.attributes = attributes
self.links = links
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: StringCodingKey.self)
self.type = try values.decode(`Type`.self, forKey: "type")
self.id = try values.decode(String.self, forKey: "id")
self.attributes = try values.decodeIfPresent(Attributes.self, forKey: "attributes")
self.links = try values.decode(ResourceLinks.self, forKey: "links")
}

public func encode(to encoder: Encoder) throws {
var values = encoder.container(keyedBy: StringCodingKey.self)
try values.encode(type, forKey: "type")
try values.encode(id, forKey: "id")
try values.encodeIfPresent(attributes, forKey: "attributes")
try values.encode(links, forKey: "links")
}
}
Loading