Skip to content

Commit

Permalink
Add patch for GENERATE_INDIVIDUAL_KEYS on UserRole (#165)
Browse files Browse the repository at this point in the history
Co-authored-by: Morten Bjerg Gregersen <[email protected]>
  • Loading branch information
MortenGregersen and MortenGregersen authored Feb 15, 2024
1 parent 8a528d2 commit d96af2a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ The OpenAPI Spec provided by Apple do not always align with the data received fr

In the OpenAPI spec for the App Store Connect API the "BundleIdPlatform" schema is said to only be "IOS" or "MAC_OS". This is not right as universal apps (iOS and macOS) has a "UNIVERSAL" platform.

#### **FB12292035**: ErrorResponse.Errors has required optional "detail" and no "associatedErrors" in "meta"

* Submitted: June 9th 2023.

In Apple's OpenAPI spec the `detail` property on `ErrorResponse.Errors` is marked as `required`.
On 12/1/23 some errors (with status code 409) has been observed, with no `detail`.

In Apple's OpenAPI spec and documentation the `associatedErrors` is not mentioned in `meta` property (last checked 12/1/23).
But it is observed when creating a `ReviewSubmissionItem` with an `AppStoreVersion` fails.

#### **FB13540097**: Almost all of the schemas ending in “WithoutIncludesResponse” has wrong "data" type

* Submitted: January 14th 2024.
Expand All @@ -169,15 +179,11 @@ Almost all of the schemas ending in “WithoutIncludesResponse” has a wrong sc

As an example, the data property of “BetaTestersWithoutIncludesResponse” refer to the schema “Build”, but when I do a request to the “/v1/betaGroups/{id}/betaTesters” endpoint, all of the items in the “data” of the JSON is of type “BetaTester”. The docs says the same: https://developer.apple.com/documentation/appstoreconnectapi/BetaTestersWithoutIncludesResponse

#### **FB12292035**: ErrorResponse.Errors has required optional "detail" and no "associatedErrors" in "meta"

* Submitted: June 9th 2023.
#### **FB13621277**: App Store Connect API Spec is missing "GENERATE_INDIVIDUAL_KEYS" type for the User Role schema

In Apple's OpenAPI spec the `detail` property on `ErrorResponse.Errors` is marked as `required`.
On 12/1/23 some errors (with status code 409) has been observed, with no `detail`.
* Submitted: February 15th 2024.

In Apple's OpenAPI spec and documentation the `associatedErrors` is not mentioned in `meta` property (last checked 12/1/23).
But it is observed when creating a `ReviewSubmissionItem` with an `AppStoreVersion` fails.
In the OpenAPI spec for the App Store Connect API the “UserRole” schema is said to not include "GENERATE_INDIVIDUAL_KEYS”. This is not right as “Users” endpoints can have a “GENERATE_INDIVIDUAL_KEYS” type.
### Closed feedback (removed patches)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public extension UserRole {
case .cloudManagedDeveloperId: "Cloud Managed Developer ID"
case .cloudManagedAppDistribution: "Cloud Managed App Distribution"
case .imageManager: "Image Manager"
case .generateIndividualKeys: "Generate Individual Keys"
}
}
}
1 change: 1 addition & 0 deletions Sources/Bagbutik-Models/Users/UserRole.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum UserRole: String, ParameterValue, Codable, CaseIterable {
case developer = "DEVELOPER"
/// Role that manages financial information, including reports and tax forms. A user that has this role can view all apps in Payments and Financial Reports, Sales and Trends, and App Analytics.
case finance = "FINANCE"
case generateIndividualKeys = "GENERATE_INDIVIDUAL_KEYS"
case imageManager = "IMAGE_MANAGER"
/// Role that manages marketing materials and promotional artwork. If an app is in consideration to be featured on the App Store, Apple contacts the user with this role.
case marketing = "MARKETING"
Expand Down
10 changes: 10 additions & 0 deletions Sources/BagbutikSpecDecoder/Spec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ public struct Spec: Decodable {
patchedSchemas.append(.object(deviceSchema))
}

// Add the case `GENERATE_INDIVIDUAL_KEYS` to UserRole
// Apple's OpenAPI spec doesn't include the role for generating individual keys. Reported to Apple 17/1/24 as FB13546172.
if case .enum(var userRoleSchema) = components.schemas["UserRole"] {
if !userRoleSchema.cases.contains(where: { $0.value == "GENERATE_INDIVIDUAL_KEYS" }) {
userRoleSchema.cases.append(EnumCase(id: "generateIndividualKeys", value: "GENERATE_INDIVIDUAL_KEYS"))
}
components.schemas["UserRole"] = .enum(userRoleSchema)
patchedSchemas.append(.enum(userRoleSchema))
}

// Change the shcema ref of the `data` property on *WithoutIncludesResponse
// Apple's OpenAPI spec and docs almost all the respones have wrong schema ref. Reported to Apple 14/1/24 as FB13540097.
components.schemas.keys
Expand Down
15 changes: 13 additions & 2 deletions Tests/BagbutikSpecDecoderTests/SpecTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,10 @@ final class SpecTests: XCTestCase {
}
},
"required" : [ "data", "links" ]
},
"UserRole" : {
"type" : "string",
"enum" : [ "ADMIN", "FINANCE", "ACCOUNT_HOLDER" ]
}
}
}
Expand All @@ -1017,18 +1021,25 @@ final class SpecTests: XCTestCase {
XCTFail(); return
}
XCTAssertEqual(responseSchemaDataRef, "App")

guard case .object(let responseSchema) = spec.components.schemas["AppCategoriesWithoutIncludesResponse"],
case .arrayOfSchemaRef(let responseSchemaDataRef) = responseSchema.properties["data"]?.type else {
XCTFail(); return
}
XCTAssertEqual(responseSchemaDataRef, "AppCategory")

guard case .object(let responseSchema) = spec.components.schemas["PreReleaseVersionsWithoutIncludesResponse"],
case .arrayOfSchemaRef(let responseSchemaDataRef) = responseSchema.properties["data"]?.type else {
XCTFail(); return
}
XCTAssertEqual(responseSchemaDataRef, "PrereleaseVersion")

guard case .enum(let userRoleSchema) = spec.components.schemas["UserRole"] else {
XCTFail(); return
}
let userRoleCaseValues = userRoleSchema.cases.map(\.value)
XCTAssertEqual(userRoleCaseValues.count, 4)
XCTAssertTrue(userRoleCaseValues.contains("GENERATE_INDIVIDUAL_KEYS"))
}

func testApplyManualPatches_Error() throws {
Expand Down

0 comments on commit d96af2a

Please sign in to comment.