Skip to content

Commit

Permalink
Update CreateApi to 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Kick committed Oct 9, 2023
1 parent d54bdbf commit 7860541
Show file tree
Hide file tree
Showing 1,502 changed files with 79,838 additions and 38,665 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.

10 changes: 4 additions & 6 deletions Sources/OpenAPI/Generated/Entities/Actor.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

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

public enum `Type`: String, Codable, CaseIterable {
case actors
Expand Down Expand Up @@ -56,7 +54,7 @@ public struct Actor: Codable, Identifiable {
}
}

public init(type: `Type`, id: String, attributes: Attributes? = nil, links: ResourceLinks) {
public init(type: `Type`, id: String, attributes: Attributes? = nil, links: ResourceLinks? = nil) {
self.type = type
self.id = id
self.attributes = attributes
Expand All @@ -68,14 +66,14 @@ public struct Actor: Codable, Identifiable {
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")
self.links = try values.decodeIfPresent(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")
try values.encodeIfPresent(links, forKey: "links")
}
}
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
10 changes: 4 additions & 6 deletions Sources/OpenAPI/Generated/Entities/AgeRatingDeclaration.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI
//
// swiftlint:disable all

import Foundation

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

public enum `Type`: String, Codable, CaseIterable {
case ageRatingDeclarations
Expand Down Expand Up @@ -170,7 +168,7 @@ public struct AgeRatingDeclaration: Codable, Identifiable {
}
}

public init(type: `Type`, id: String, attributes: Attributes? = nil, links: ResourceLinks) {
public init(type: `Type`, id: String, attributes: Attributes? = nil, links: ResourceLinks? = nil) {
self.type = type
self.id = id
self.attributes = attributes
Expand All @@ -182,14 +180,14 @@ public struct AgeRatingDeclaration: Codable, Identifiable {
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")
self.links = try values.decodeIfPresent(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")
try values.encodeIfPresent(links, forKey: "links")
}
}
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
@@ -0,0 +1,27 @@
// Generated by Create API
// https://github.com/CreateAPI/CreateAPI

import Foundation

public struct AgeRatingDeclarationWithoutIncludesResponse: Codable {
/// AppStoreVersion
public var data: AppStoreVersion
public var links: DocumentLinks

public init(data: AppStoreVersion, links: DocumentLinks) {
self.data = data
self.links = links
}

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

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

0 comments on commit 7860541

Please sign in to comment.