AvdLee / appstoreconnect-swift-sdk

The Swift SDK to work with the App Store Connect API from Apple.
Other
1.48k stars 198 forks source link

Update CreateAPI to 0.1.0 #200

Closed liamnichols closed 1 year ago

liamnichols commented 2 years ago

CreateAPI recently released version 0.1 and in this version, we took the decision to make a series of small breaking changes to the way that the tool is used to better shape it's future.

I wanted to submit a PR with this bump since its can be a little tricky unless you have the context of the changes between 0.0.5 and 0.1.0.

To highlight the key changes that impact this project:

  1. --split is now the default behaviour so I removed the flag
  2. --module is now defined as generate and module in the config file
  3. Generated code now needs the Request type to match that of Get 1.0 and uses the initialiser directly instead of the extensions (this causes a diff in the generated Paths)
    • There is also a slight tweak to how you need to handle body.
  4. Lots of config options were renamed (removing Swifty style boolean properties etc) and some default values changed. I matched the configuration so that it generates a mostly identical output for you, but I'll add some extra notes inline.
SwiftLeeBot commented 2 years ago
Warnings
:warning: Consider to place some `MARK:` lines for Sources/OpenAPI/Generated/Paths/PathsV1AppStoreVersionsWithIDCustomerReviews.swift, which is over 300 lines big.
:warning: Consider to place some `MARK:` lines for Sources/OpenAPI/Generated/Paths/PathsV1CiBuildRunsWithIDBuilds.swift, which is over 300 lines big.
:warning: Consider to place some `MARK:` lines for Sources/OpenAPI/Generated/Paths/PathsV1Builds.swift, which is over 300 lines big.
:warning: Consider to place some `MARK:` lines for Sources/OpenAPI/Generated/Paths/PathsV1AppsWithIDCustomerReviews.swift, which is over 300 lines big.
:warning: Consider to place some `MARK:` lines for Sources/OpenAPI/Generated/Paths/PathsV1Apps.swift, which is over 300 lines big.
:warning: Consider to place some `MARK:` lines for Sources/OpenAPI/Generated/Paths/PathsV1CiProductsWithIDApp.swift, which is over 300 lines big.
:warning: Consider to place some `MARK:` lines for Sources/OpenAPI/Generated/Paths/PathsV1AppsWithID.swift, which is over 300 lines big.
:warning: Consider to place some `MARK:` lines for Sources/OpenAPI/Generated/Paths/PathsV1AppsWithIDAppStoreVersions.swift, which is over 300 lines big.
:warning: 'AppStoreVersionSubmission' is deprecated: Deprecated
:warning: 'AppStoreVersionSubmission' is deprecated: Deprecated
:warning: 'AppStoreVersionSubmission' is deprecated: Deprecated
:warning: 'AppStoreVersionSubmission' is deprecated: Deprecated
:warning: 'AgeRatingDeclaration' is deprecated: Deprecated
:warning: 'AgeRatingDeclaration' is deprecated: Deprecated
:warning: 'AgeRatingDeclaration' is deprecated: Deprecated
:warning: 'AppPricePoint' is deprecated: Deprecated
:warning: 'AppPricePoint' is deprecated: Deprecated
:warning: 'AppPricePoint' is deprecated: Deprecated
:warning: 'AppPricePoint' is deprecated: Deprecated
:warning: 'AppPricePoint' is deprecated: Deprecated
:warning: 'AppPricePoint' is deprecated: Deprecated
:warning: 'PricePoints' is deprecated: Deprecated
:warning: 'PricePoints' is deprecated: Deprecated
:warning: 'PricePoints' is deprecated: Deprecated
:warning: 'InAppPurchases' is deprecated: Deprecated
:warning: 'InAppPurchases' is deprecated: Deprecated
:warning: 'InAppPurchases' is deprecated: Deprecated
Messages
:book: View more details on Bitrise
:book: AppStoreConnect-Swift-SDK-Tests: Executed 9 tests (0 failed, 0 retried, 0 skipped) in 0.033 seconds

Code Coverage Report

Name Coverage

Generated by :no_entry_sign: Danger Swift against 4e088d289dd06c07215cc2f3a2e2f680b6d4a4fe

liamnichols commented 2 years ago

Just to be sure, does this introduce any breaking changes? Since you've removed the REST methods in the Endpoints struct? Note that we're not using Get in this SDK as a dependency

Ah hmm, there are no breaking changes if usage of Request is considered internal, but I didn't pay close attention and looking back at the diff, those methods on Request are public.. So technically, yes there are.

Do you consider the methods, initialiser and properties of Request as public in your API surface or were they just public to make the generator happy?

If we want to, I can revert those changes and add a new initialiser that matches the Get 1.0 initialiser which is required by CreateAPI 0.1 without breaking the public interface I think.

It would mean that your Request would differ a bit from Get's, but it would work šŸ‘

AvdLee commented 2 years ago

@liamnichols sorry for not replying earlier, I was on a holiday!

What's leading here is whether the example project still works. If so, your PR is good to be merged!

AvdLee commented 2 years ago

@liamnichols any updates?

liamnichols commented 2 years ago

I was on a holiday!

Me too šŸ˜…

Screenshot 2022-09-30 at 11 30 29

It was working, but I just rebased from master and the latest schema update throws an error when testing the generator:

Error: Failed to generate get for Operation(tags: Optional(["SubscriptionOfferCodeOneTimeUseCodes"]), summary: nil, description: nil, externalDocs: nil, operationId: Optional("subscriptionOfferCodeOneTimeUseCodes-get_instance"), parameters: [Either(Parameter(name: "fields[subscriptionOfferCodeOneTimeUseCodes]", context: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Parameter.Context.query(required: false, allowEmptyValue: false), description: Optional("the fields to include for returned resources of type subscriptionOfferCodeOneTimeUseCodes"), deprecated: false, schemaOrContent: Either(SchemaContext(style: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Parameter.SchemaContext.Style.form, explode: false, allowReserved: false, schema: Either(JSONSchema(warnings: [], value: OpenAPIKit30.JSONSchema.Schema.array(OpenAPIKit30.JSONSchema.CoreContext<OpenAPIKit30.JSONTypeFormat.ArrayFormat>(format: OpenAPIKit30.JSONTypeFormat.ArrayFormat.generic, required: true, _nullable: nil, _permissions: nil, _deprecated: nil, title: nil, description: nil, externalDocs: nil, discriminator: nil, allowedValues: nil, defaultValue: nil, example: nil), OpenAPIKit30.JSONSchema.ArrayContext(items: Optional(OpenAPIKit30.JSONSchema(warnings: [], value: OpenAPIKit30.JSONSchema.Schema.string(OpenAPIKit30.JSONSchema.CoreContext<OpenAPIKit30.JSONTypeFormat.StringFormat>(format: OpenAPIKit30.JSONTypeFormat.StringFormat.generic, required: true, _nullable: nil, _permissions: nil, _deprecated: nil, title: nil, description: nil, externalDocs: nil, discriminator: nil, allowedValues: Optional([AnyCodable("active"), AnyCodable("createdDate"), AnyCodable("expirationDate"), AnyCodable("numberOfCodes"), AnyCodable("offerCode"), AnyCodable("values")]), defaultValue: nil, example: nil), OpenAPIKit30.JSONSchema.StringContext(maxLength: nil, _minLength: nil, pattern: nil)))), maxItems: nil, _minItems: nil, _uniqueItems: nil)))), example: nil, examples: nil)), vendorExtensions: [:])), Either(Parameter(name: "include", context: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Parameter.Context.query(required: false, allowEmptyValue: false), description: Optional("comma-separated list of relationships to include"), deprecated: false, schemaOrContent: Either(SchemaContext(style: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Parameter.SchemaContext.Style.form, explode: false, allowReserved: false, schema: Either(JSONSchema(warnings: [], value: OpenAPIKit30.JSONSchema.Schema.array(OpenAPIKit30.JSONSchema.CoreContext<OpenAPIKit30.JSONTypeFormat.ArrayFormat>(format: OpenAPIKit30.JSONTypeFormat.ArrayFormat.generic, required: true, _nullable: nil, _permissions: nil, _deprecated: nil, title: nil, description: nil, externalDocs: nil, discriminator: nil, allowedValues: nil, defaultValue: nil, example: nil), OpenAPIKit30.JSONSchema.ArrayContext(items: Optional(OpenAPIKit30.JSONSchema(warnings: [], value: OpenAPIKit30.JSONSchema.Schema.string(OpenAPIKit30.JSONSchema.CoreContext<OpenAPIKit30.JSONTypeFormat.StringFormat>(format: OpenAPIKit30.JSONTypeFormat.StringFormat.generic, required: true, _nullable: nil, _permissions: nil, _deprecated: nil, title: nil, description: nil, externalDocs: nil, discriminator: nil, allowedValues: Optional([AnyCodable("offerCode")]), defaultValue: nil, example: nil), OpenAPIKit30.JSONSchema.StringContext(maxLength: nil, _minLength: nil, pattern: nil)))), maxItems: nil, _minItems: nil, _uniqueItems: nil)))), example: nil, examples: nil)), vendorExtensions: [:])), Either(Parameter(name: "fields[subscriptionOfferCodeOneTimeUseCodeValues]", context: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Parameter.Context.query(required: false, allowEmptyValue: false), description: Optional("the fields to include for returned resources of type subscriptionOfferCodeOneTimeUseCodeValues"), deprecated: false, schemaOrContent: Either(SchemaContext(style: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Parameter.SchemaContext.Style.form, explode: false, allowReserved: false, schema: Either(JSONSchema(warnings: [], value: OpenAPIKit30.JSONSchema.Schema.array(OpenAPIKit30.JSONSchema.CoreContext<OpenAPIKit30.JSONTypeFormat.ArrayFormat>(format: OpenAPIKit30.JSONTypeFormat.ArrayFormat.generic, required: true, _nullable: nil, _permissions: nil, _deprecated: nil, title: nil, description: nil, externalDocs: nil, discriminator: nil, allowedValues: nil, defaultValue: nil, example: nil), OpenAPIKit30.JSONSchema.ArrayContext(items: Optional(OpenAPIKit30.JSONSchema(warnings: [], value: OpenAPIKit30.JSONSchema.Schema.string(OpenAPIKit30.JSONSchema.CoreContext<OpenAPIKit30.JSONTypeFormat.StringFormat>(format: OpenAPIKit30.JSONTypeFormat.StringFormat.generic, required: true, _nullable: nil, _permissions: nil, _deprecated: nil, title: nil, description: nil, externalDocs: nil, discriminator: nil, allowedValues: Optional([]), defaultValue: nil, example: nil), OpenAPIKit30.JSONSchema.StringContext(maxLength: nil, _minLength: nil, pattern: nil)))), maxItems: nil, _minItems: nil, _uniqueItems: nil)))), example: nil, examples: nil)), vendorExtensions: [:]))], requestBody: nil, responses: OpenAPIKitCore.OrderedDictionary<(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode, OpenAPIKitCore.Either<OpenAPIKit30.JSONReference<(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response>, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response>>(orderedKeys: [(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode(warnings: [], value: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode.Code.status(code: 400)), (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode(warnings: [], value: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode.Code.status(code: 403)), (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode(warnings: [], value: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode.Code.status(code: 404)), (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode(warnings: [], value: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode.Code.status(code: 200))], unorderedHash: [(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode(warnings: [], value: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode.Code.status(code: 404)): Either(Response(description: "Not found error", headers: nil, content: OpenAPIKitCore.OrderedDictionary<OpenAPIKitCore.OpenAPI.ContentType, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Content>(orderedKeys: [OpenAPIKitCore.OpenAPI.ContentType(underlyingType: OpenAPIKitCore.OpenAPI.ContentType.Builtin.json, warnings: [], parameters: [:])], unorderedHash: [OpenAPIKitCore.OpenAPI.ContentType(underlyingType: OpenAPIKitCore.OpenAPI.ContentType.Builtin.json, warnings: [], parameters: [:]): (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Content(schema: Optional(Either(internal(#/components/schemas/ErrorResponse))), example: nil, examples: nil, encoding: nil, vendorExtensions: [:])], _warnings: []), links: OpenAPIKitCore.OrderedDictionary<Swift.String, OpenAPIKitCore.Either<OpenAPIKit30.JSONReference<(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Link>, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Link>>(orderedKeys: [], unorderedHash: [:], _warnings: []), vendorExtensions: [:])), (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode(warnings: [], value: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode.Code.status(code: 400)): Either(Response(description: "Parameter error(s)", headers: nil, content: OpenAPIKitCore.OrderedDictionary<OpenAPIKitCore.OpenAPI.ContentType, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Content>(orderedKeys: [OpenAPIKitCore.OpenAPI.ContentType(underlyingType: OpenAPIKitCore.OpenAPI.ContentType.Builtin.json, warnings: [], parameters: [:])], unorderedHash: [OpenAPIKitCore.OpenAPI.ContentType(underlyingType: OpenAPIKitCore.OpenAPI.ContentType.Builtin.json, warnings: [], parameters: [:]): (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Content(schema: Optional(Either(internal(#/components/schemas/ErrorResponse))), example: nil, examples: nil, encoding: nil, vendorExtensions: [:])], _warnings: []), links: OpenAPIKitCore.OrderedDictionary<Swift.String, OpenAPIKitCore.Either<OpenAPIKit30.JSONReference<(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Link>, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Link>>(orderedKeys: [], unorderedHash: [:], _warnings: []), vendorExtensions: [:])), (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode(warnings: [], value: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode.Code.status(code: 200)): Either(Response(description: "Single SubscriptionOfferCodeOneTimeUseCode", headers: nil, content: OpenAPIKitCore.OrderedDictionary<OpenAPIKitCore.OpenAPI.ContentType, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Content>(orderedKeys: [OpenAPIKitCore.OpenAPI.ContentType(underlyingType: OpenAPIKitCore.OpenAPI.ContentType.Builtin.json, warnings: [], parameters: [:])], unorderedHash: [OpenAPIKitCore.OpenAPI.ContentType(underlyingType: OpenAPIKitCore.OpenAPI.ContentType.Builtin.json, warnings: [], parameters: [:]): (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Content(schema: Optional(Either(internal(#/components/schemas/SubscriptionOfferCodeOneTimeUseCodeResponse))), example: nil, examples: nil, encoding: nil, vendorExtensions: [:])], _warnings: []), links: OpenAPIKitCore.OrderedDictionary<Swift.String, OpenAPIKitCore.Either<OpenAPIKit30.JSONReference<(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Link>, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Link>>(orderedKeys: [], unorderedHash: [:], _warnings: []), vendorExtensions: [:])), (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode(warnings: [], value: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Response.StatusCode.Code.status(code: 403)): Either(Response(description: "Forbidden error", headers: nil, content: OpenAPIKitCore.OrderedDictionary<OpenAPIKitCore.OpenAPI.ContentType, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Content>(orderedKeys: [OpenAPIKitCore.OpenAPI.ContentType(underlyingType: OpenAPIKitCore.OpenAPI.ContentType.Builtin.json, warnings: [], parameters: [:])], unorderedHash: [OpenAPIKitCore.OpenAPI.ContentType(underlyingType: OpenAPIKitCore.OpenAPI.ContentType.Builtin.json, warnings: [], parameters: [:]): (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Content(schema: Optional(Either(internal(#/components/schemas/ErrorResponse))), example: nil, examples: nil, encoding: nil, vendorExtensions: [:])], _warnings: []), links: OpenAPIKitCore.OrderedDictionary<Swift.String, OpenAPIKitCore.Either<OpenAPIKit30.JSONReference<(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Link>, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Link>>(orderedKeys: [], unorderedHash: [:], _warnings: []), vendorExtensions: [:]))], _warnings: []), callbacks: OpenAPIKitCore.OrderedDictionary<Swift.String, OpenAPIKitCore.Either<OpenAPIKit30.JSONReference<OpenAPIKitCore.OrderedDictionary<(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.CallbackURL, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.PathItem>>, OpenAPIKitCore.OrderedDictionary<(extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.CallbackURL, (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.PathItem>>>(orderedKeys: [], unorderedHash: [:], _warnings: []), deprecated: false, security: nil, servers: nil, vendorExtensions: [:]). Failed to generate query parameter Parameter(name: "fields[subscriptionOfferCodeOneTimeUseCodeValues]", context: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Parameter.Context.query(required: false, allowEmptyValue: false), description: Optional("the fields to include for returned resources of type subscriptionOfferCodeOneTimeUseCodeValues"), deprecated: false, schemaOrContent: Either(SchemaContext(style: (extension in OpenAPIKit30):OpenAPIKitCore.OpenAPI.Parameter.SchemaContext.Style.form, explode: false, allowReserved: false, schema: Either(JSONSchema(warnings: [], value: OpenAPIKit30.JSONSchema.Schema.array(OpenAPIKit30.JSONSchema.CoreContext<OpenAPIKit30.JSONTypeFormat.ArrayFormat>(format: OpenAPIKit30.JSONTypeFormat.ArrayFormat.generic, required: true, _nullable: nil, _permissions: nil, _deprecated: nil, title: nil, description: nil, externalDocs: nil, discriminator: nil, allowedValues: nil, defaultValue: nil, example: nil), OpenAPIKit30.JSONSchema.ArrayContext(items: Optional(OpenAPIKit30.JSONSchema(warnings: [], value: OpenAPIKit30.JSONSchema.Schema.string(OpenAPIKit30.JSONSchema.CoreContext<OpenAPIKit30.JSONTypeFormat.StringFormat>(format: OpenAPIKit30.JSONTypeFormat.StringFormat.generic, required: true, _nullable: nil, _permissions: nil, _deprecated: nil, title: nil, description: nil, externalDocs: nil, discriminator: nil, allowedValues: Optional([]), defaultValue: nil, example: nil), OpenAPIKit30.JSONSchema.StringContext(maxLength: nil, _minLength: nil, pattern: nil)))), maxItems: nil, _minItems: nil, _uniqueItems: nil)))), example: nil, examples: nil)), vendorExtensions: [:]). Enum "FieldsSubscriptionOfferCodeOneTimeUseCodeValues" has no values

Enum "FieldsSubscriptionOfferCodeOneTimeUseCodeValues" has no values

Running swift package --allow-writing-to-package-directory generate-open-api also fails on master with the same error so it's not related to the changes in this PR. Do you know what changed? Do I need to remove the enum from FieldsSubscriptionOfferCodeOneTimeUseCodeValues again?

AvdLee commented 2 years ago

Hmm, interesting! Could it be related to this: https://github.com/AvdLee/appstoreconnect-swift-sdk/pull/197#issuecomment-1247993297

We've changed the specs using that command and updated the BundleIdPlatform enum šŸ¤” I just pushed another scheme update for the 2.1 version of ASC API, could you try with the latest master?

liamnichols commented 2 years ago

Yeah I'm still seeing the same error on master

Enum "FieldsSubscriptionOfferCodeOneTimeUseCodeValues" has no values

(it's buried between some noisy print message that needs cleaning up, but it's there šŸ˜…)


I guess that jq command in sync_asc_api.yml needs to also delete the enum type? Is that what you did in the past, or did you add a dummy placeholder value? I can fix it on this branch.

liamnichols commented 2 years ago

Ok I figured it out, before doing this, I opened AvdLee/appstoreconnect-swift-sdk#208 to clear things up šŸ™

AvdLee commented 2 years ago

Ok I figured it out, before doing this, I opened https://github.com/AvdLee/appstoreconnect-swift-sdk/pull/208 to clear things up šŸ™

Ah, glad you figured it out! Would be great if you can optimize the feedback from CreateAPI to give better insights into the reason of failure. Might help you save time in the future!

liamnichols commented 2 years ago

BTW I'm going to release CreateAPI 0.2.0 later this week which changes the Request type structure again to work with some API changes that were pushed to Get 2.x šŸ˜… So I'll update this PR again later after doing that

AvdLee commented 2 years ago

BTW I'm going to release CreateAPI 0.2.0 later this week which changes the Request type structure again to work with some API changes that were pushed to Get 2.x šŸ˜… So I'll update this PR again later after doing that

Sounds good. Great to hear you're actively developing CreateAPI! Super happy I'm on board šŸš€

github-actions[bot] commented 2 years ago

This PR is stale because it has been open for 30 days with no activity. Remove the Stale label or comment or this will be closed in 10 days.

liamnichols commented 2 years ago

(Not stale, Iā€™m just waiting on a couple more bug fixes until we release 0.2 and make further changes to this PR)

github-actions[bot] commented 1 year ago

This PR is stale because it has been open for 30 days with no activity. Remove the Stale label or comment or this will be closed in 10 days.

AvdLee commented 1 year ago

@liamnichols are we ready to update? šŸ’Ŗ