Skip to content

Commit

Permalink
Merge pull request #249 from nickasd/openapi-0.2.0
Browse files Browse the repository at this point in the history
Update CreateApi to 0.2.0
  • Loading branch information
AvdLee authored Dec 2, 2023
2 parents d1039cc + caa1ca1 commit d345a2b
Show file tree
Hide file tree
Showing 1,578 changed files with 29,880 additions and 20,423 deletions.
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.3_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.json

# Runs the CreateAPI generator to update generated source code
.PHONY: generate
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ let package = Package(
name: "AppStoreConnect-Swift-SDK",
dependencies: targetDependencies,
path: "Sources",
exclude: ["OpenAPI/app_store_connect_api_2.3_openapi.json"]
exclude: ["OpenAPI/app_store_connect_api.json"]
),
.binaryTarget(
name: "create-api", // Find the URL and checksum at https://github.com/createapi/createapi/releases/latest
url: "https://github.com/CreateAPI/CreateAPI/releases/download/0.0.5/create-api.artifactbundle.zip",
checksum: "89c75ec3b2938d08b961b94e70e6dd6fa0ff52a90037304d41718cd5fb58bd24" // Find at https://github.com/createapi/createapi/releases/latest
url: "https://github.com/CreateAPI/CreateAPI/releases/download/0.2.0/create-api.artifactbundle.zip",
checksum: "6f8a3ce099f07eb2655ccaf6f66d8c9a09b74bb2307781c4adec36609ddac009"
),
.plugin(
name: "CreateAPI",
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.3_openapi.json"])
exclude: ["OpenAPI/app_store_connect_api.json"])
]
)
6 changes: 2 additions & 4 deletions Plugins/CreateAPI/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ struct Plugin: CommandPlugin {
process.executableURL = URL(fileURLWithPath: createAPI.path.string)
process.arguments = [
"generate",
"app_store_connect_api_2.3_openapi.json",
"--module", "AppStoreConnect_Swift_SDK",
"app_store_connect_api.json",
"--output", "Generated",
"--config", ".create-api.yml",
"--split",
"--config", "create-api.yml",
"--clean"
]

Expand Down
54 changes: 4 additions & 50 deletions Sources/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,67 +32,21 @@ public struct Request<Response> {
public var headers: [String: String]?
public var id: String?

public init(method: String, path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) {
public init(path: String, method: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil, id: String) {
self.method = method
self.path = path
self.query = query
self.headers = headers
self.id = id
}

public init<U: Encodable>(method: String, path: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil) {
public init<U: Encodable>(path: String, method: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil, id: String) {
self.method = method
self.path = path
self.query = query
self.body = body.map(AnyEncodable.init)
self.headers = headers
}

public static func get(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request {
Request(method: "GET", path: path, query: query, headers: headers)
}

public static func post(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request {
Request(method: "POST", path: path, query: query, headers: headers)
}

public static func post<U: Encodable>(_ path: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil) -> Request {
Request(method: "POST", path: path, query: query, body: body, headers: headers)
}

public static func put(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request {
Request(method: "PUT", path: path, query: query, headers: headers)
}

public static func put<U: Encodable>(_ path: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil) -> Request {
Request(method: "PUT", path: path, query: query, body: body, headers: headers)
}

public static func patch(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request {
Request(method: "PATCH", path: path, query: query, headers: headers)
}

public static func patch<U: Encodable>(_ path: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil) -> Request {
Request(method: "PATCH", path: path, query: query, body: body, headers: headers)
}

public static func delete(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request {
Request(method: "DELETE", path: path, query: query, headers: headers)
}

public static func delete<U: Encodable>(_ path: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil) -> Request {
Request(method: "DELETE", path: path, query: query, body: body, headers: headers)
}

public static func options(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request {
Request(method: "OPTIONS", path: path, query: query, headers: headers)
}

public static func head(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request {
Request(method: "HEAD", path: path, query: query, headers: headers)
}

public static func trace(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request {
Request(method: "TRACE", path: path, query: query, headers: headers)
self.id = id
}
}

Expand Down
52 changes: 0 additions & 52 deletions Sources/OpenAPI/.create-api.yml

This file was deleted.

2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/Actor.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/ActorResponse.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/ActorsResponse.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/AgeRatingDeclaration.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

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

import Foundation

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

import Foundation

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

import Foundation

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/App.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

Expand Down
3 changes: 1 addition & 2 deletions Sources/OpenAPI/Generated/Entities/AppAvailability.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

@available(*, deprecated, message: "Deprecated")
public struct AppAvailability: Codable, Identifiable {
public var type: `Type`
public var id: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

@available(*, deprecated, message: "Deprecated")
public struct AppAvailabilityCreateRequest: Codable {
public var data: Data

Expand Down
10 changes: 7 additions & 3 deletions Sources/OpenAPI/Generated/Entities/AppAvailabilityResponse.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

@available(*, deprecated, message: "Deprecated")
public struct AppAvailabilityResponse: Codable {
/// AppAvailability
///
/// - warning: Deprecated.
public var data: AppAvailability
public var included: [IncludedItem]?
public var links: DocumentLinks
Expand All @@ -22,7 +23,10 @@ public struct AppAvailabilityResponse: Codable {
} else if let value = try? container.decode(Territory.self) {
self = .territory(value)
} else {
throw DecodingError.dataCorruptedError(in: container, debugDescription: "Failed to intialize `oneOf`")
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "Data could not be decoded as any of the expected types (App, Territory)."
)
}
}

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/AppAvailabilityV2.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

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

import Foundation

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

import Foundation

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

import Foundation

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

import Foundation

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

import Foundation

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/AppCategory.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/AppCategoryResponse.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

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

import Foundation

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/AppClip.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenAPI/Generated/Entities/AppClipAction.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

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

import Foundation

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

import Foundation

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

import Foundation

Expand Down
Loading

0 comments on commit d345a2b

Please sign in to comment.