-
Notifications
You must be signed in to change notification settings - Fork 10
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
Move Generated Client to separate module #486
Open
andrewdmontgomery
wants to merge
21
commits into
trunk
Choose a base branch
from
andrewdmontgomery/OpenAPI-with-SPM
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+804
−52
Open
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5cd8d77
Reconfigure OpenAPI generation to output a Swift Package, simplify do…
andrewdmontgomery 110ebc2
Setup local package dependency
andrewdmontgomery 68fd36e
Export OpenAPI types
andrewdmontgomery 667a429
Refactor openapi-generator call
andrewdmontgomery 707bd37
Update generated client
andrewdmontgomery 32f8dd8
Rename OpenAPIClient --> GravatarOpenAPIClient
andrewdmontgomery 283a10f
Match iOS deployment targets for all podspecs
andrewdmontgomery 944c5d6
Update Makefile generation of GravatarOpenAPIClient.podspec
andrewdmontgomery 3c19a1e
Revert project.yml version
andrewdmontgomery 024e041
Stop ignoring the `openapi-generator` directory, since we don't need …
andrewdmontgomery 6e3d2a4
Move GravatarOpenAPIClient into module (without third-party dep)
andrewdmontgomery 84eeb1f
Stop tracking some files
andrewdmontgomery 01c459f
Removes unnecessary `install-and-generate` Makefile task
andrewdmontgomery 9c5b7e4
Update GravatarOpenAPIClient.podspec with path to module
andrewdmontgomery 0b6d4dc
Update the validate-pods.sh script to check the new podspec
andrewdmontgomery c6a8e96
Update pipeline to publish the new podspec
andrewdmontgomery d28429d
Update Demo project Package.resolved
andrewdmontgomery 90810ab
Merge branch 'release/3.0.0' into andrewdmontgomery/OpenAPI-with-SPM
andrewdmontgomery e1e7191
Regenerate SetEmailAvatarRequest
andrewdmontgomery 93446f7
Fix typo in `generate` Makefile command
andrewdmontgomery b3b9f4c
Update .openapi-generator-ignore to generate only `Models` dir
andrewdmontgomery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Demo/Gravatar-Demo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'version' | ||
|
||
Pod::Spec.new do |s| | ||
s.name = 'GravatarOpenAPIClient' | ||
s.summary = 'A Gravatar OpenAPI Client' | ||
s.version = Gravatar::VERSION | ||
|
||
s.swift_versions = Gravatar::SWIFT_VERSIONS | ||
|
||
# Match the deployment target of Gravatar in order to satisfy `pod lib lint` | ||
s.ios.deployment_target = Gravatar::IOS_DEPLOYMENT_TARGET | ||
|
||
s.homepage = 'https://gravatar.com' | ||
s.license = { type: 'Mozilla Public License v2', file: 'LICENSE.md' } | ||
s.authors = 'Automattic, Inc.' | ||
s.source = { :git => 'https://github.com/Automattic/Gravatar-SDK-iOS.git', :tag => s.version.to_s } | ||
|
||
s.documentation_url = 'https://automattic.github.io/Gravatar-SDK-iOS/gravatar' | ||
|
||
s.source_files = 'Sources/GravatarOpenAPIClient/**/*.swift' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import GravatarOpenAPIClient | ||
|
||
// MARK: OpenAPI Models: Public | ||
|
||
public typealias CryptoWalletAddress = GravatarOpenAPIClient.CryptoWalletAddress | ||
public typealias GalleryImage = GravatarOpenAPIClient.GalleryImage | ||
public typealias Interest = GravatarOpenAPIClient.Interest | ||
public typealias Language = GravatarOpenAPIClient.Language | ||
public typealias Link = GravatarOpenAPIClient.Link | ||
public typealias Profile = GravatarOpenAPIClient.Profile | ||
public typealias ProfileContactInfo = GravatarOpenAPIClient.ProfileContactInfo | ||
public typealias ProfilePayments = GravatarOpenAPIClient.ProfilePayments | ||
public typealias VerifiedAccount = GravatarOpenAPIClient.VerifiedAccount | ||
|
||
// MARK: - OpenAPI Models: Package | ||
|
||
package typealias Avatar = GravatarOpenAPIClient.Avatar | ||
|
||
// MARK: - OpenAPI Models: Internal | ||
|
||
typealias AssociatedResponse = GravatarOpenAPIClient.AssociatedResponse | ||
typealias ModelError = GravatarOpenAPIClient.ModelError | ||
typealias SetEmailAvatarRequest = GravatarOpenAPIClient.SetEmailAvatarRequest |
25 changes: 0 additions & 25 deletions
25
Sources/Gravatar/OpenApi/Generated/SetEmailAvatarRequest.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import Foundation | ||
|
||
public enum APIHelper { | ||
public static func rejectNil(_ source: [String: Any?]) -> [String: Any]? { | ||
let destination = source.reduce(into: [String: Any]()) { result, item in | ||
if let value = item.value { | ||
result[item.key] = value | ||
} | ||
} | ||
|
||
if destination.isEmpty { | ||
return nil | ||
} | ||
return destination | ||
} | ||
|
||
public static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] { | ||
source.reduce(into: [String: String]()) { result, item in | ||
if let collection = item.value as? [Any?] { | ||
result[item.key] = collection | ||
.compactMap { value in convertAnyToString(value) } | ||
.joined(separator: ",") | ||
} else if let value: Any = item.value { | ||
result[item.key] = convertAnyToString(value) | ||
} | ||
} | ||
} | ||
|
||
public static func convertBoolToString(_ source: [String: Any]?) -> [String: Any]? { | ||
guard let source else { | ||
return nil | ||
} | ||
|
||
return source.reduce(into: [String: Any]()) { result, item in | ||
switch item.value { | ||
case let x as Bool: | ||
result[item.key] = x.description | ||
default: | ||
result[item.key] = item.value | ||
} | ||
} | ||
} | ||
|
||
public static func convertAnyToString(_ value: Any?) -> String? { | ||
guard let value else { return nil } | ||
if let value = value as? any RawRepresentable { | ||
return "\(value.rawValue)" | ||
} else { | ||
return "\(value)" | ||
} | ||
} | ||
|
||
public static func mapValueToPathItem(_ source: Any) -> Any { | ||
if let collection = source as? [Any?] { | ||
return collection | ||
.compactMap { value in convertAnyToString(value) } | ||
.joined(separator: ",") | ||
} | ||
return source | ||
} | ||
|
||
/// maps all values from source to query parameters | ||
/// | ||
/// explode attribute is respected: collection values might be either joined or split up into separate key value pairs | ||
public static func mapValuesToQueryItems(_ source: [String: (wrappedValue: Any?, isExplode: Bool)]) -> [URLQueryItem]? { | ||
let destination = source.filter { $0.value.wrappedValue != nil }.reduce(into: [URLQueryItem]()) { result, item in | ||
if let collection = item.value.wrappedValue as? [Any?] { | ||
let collectionValues: [String] = collection.compactMap { value in convertAnyToString(value) } | ||
|
||
if !item.value.isExplode { | ||
result.append(URLQueryItem(name: item.key, value: collectionValues.joined(separator: ","))) | ||
} else { | ||
for value in collectionValues { | ||
result.append(URLQueryItem(name: item.key, value: value)) | ||
} | ||
} | ||
|
||
} else if let value = item.value.wrappedValue { | ||
result.append(URLQueryItem(name: item.key, value: convertAnyToString(value))) | ||
} | ||
} | ||
|
||
if destination.isEmpty { | ||
return nil | ||
} | ||
return destination.sorted { $0.name < $1.name } | ||
} | ||
|
||
/// maps all values from source to query parameters | ||
/// | ||
/// collection values are always exploded | ||
public static func mapValuesToQueryItems(_ source: [String: Any?]) -> [URLQueryItem]? { | ||
let destination = source.filter { $0.value != nil }.reduce(into: [URLQueryItem]()) { result, item in | ||
if let collection = item.value as? [Any?] { | ||
collection | ||
.compactMap { value in convertAnyToString(value) } | ||
.forEach { value in | ||
result.append(URLQueryItem(name: item.key, value: value)) | ||
} | ||
|
||
} else if let value = item.value { | ||
result.append(URLQueryItem(name: item.key, value: convertAnyToString(value))) | ||
} | ||
} | ||
|
||
if destination.isEmpty { | ||
return nil | ||
} | ||
return destination.sorted { $0.name < $1.name } | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU, GravatarOpenAPIClient's version is Gravatar's version. This makes me wonder what happens when the specs change and we re-generate GravatarOpenAPIClient. When I use the new models in Gravatar what should i set here so that cocoapods also builds fine in CI...