-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
5cd8d77
110ebc2
68fd36e
667a429
707bd37
32f8dd8
283a10f
944c5d6
3c19a1e
024e041
6e3d2a4
84eeb1f
01c459f
9c5b7e4
0b6d4dc
c6a8e96
d28429d
90810ab
e1e7191
93446f7
b3b9f4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,28 +2,28 @@ import Foundation | |
|
||
/// An avatar that the user has already uploaded to their Gravatar account. | ||
/// | ||
package struct Avatar: Codable, Hashable, Sendable { | ||
package enum Rating: String, Codable, CaseIterable, Sendable { | ||
public struct Avatar: Codable, Hashable, Sendable { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there maybe a way to keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is a good question. My understanding of Swift Packages (which turned out to be incomplete) was that only modules that are exposed as libraries (via And since this would not expose the generated client as a But as it turns out, it isn't quite that simple. It's true that by not listing it as a But since As a result, you are right. If we could retain those
For one, as we discussed separately, as it currently stands, the versioning of this OpenAPIClient will need to be independent of the version of the SDK. This is because:
I think there are two directions we can take this:
Both options will require some effort, and will introduce some complexity. But I think option 2 probably serves the needs of the SDK more directly:
|
||
public enum Rating: String, Codable, CaseIterable, Sendable { | ||
case g = "G" | ||
case pg = "PG" | ||
case r = "R" | ||
case x = "X" | ||
} | ||
|
||
/// Unique identifier for the image. | ||
package private(set) var imageId: String | ||
public private(set) var imageId: String | ||
/// Image URL | ||
package private(set) var imageUrl: String | ||
public private(set) var imageUrl: String | ||
/// Rating associated with the image. | ||
package private(set) var rating: Rating | ||
public private(set) var rating: Rating | ||
/// Date and time when the image was last updated. | ||
package private(set) var updatedDate: Date | ||
public private(set) var updatedDate: Date | ||
/// Alternative text description of the image. | ||
package private(set) var altText: String | ||
public private(set) var altText: String | ||
/// Whether the image is currently selected as the provided selected email's avatar. | ||
package private(set) var selected: Bool? | ||
public private(set) var selected: Bool? | ||
|
||
package init(imageId: String, imageUrl: String, rating: Rating, updatedDate: Date, altText: String, selected: Bool? = nil) { | ||
init(imageId: String, imageUrl: String, rating: Rating, updatedDate: Date, altText: String, selected: Bool? = nil) { | ||
self.imageId = imageId | ||
self.imageUrl = imageUrl | ||
self.rating = rating | ||
|
@@ -43,7 +43,7 @@ package struct Avatar: Codable, Hashable, Sendable { | |
|
||
// Encodable protocol methods | ||
|
||
package func encode(to encoder: Encoder) throws { | ||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(imageId, forKey: .imageId) | ||
try container.encode(imageUrl, forKey: .imageUrl) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md | ||
|
||
.gitignore | ||
.swiftformat | ||
Cartfile | ||
git_push.sh | ||
Sources/GravatarOpenAPIClient/ | ||
!Sources/GravatarOpenAPIClient/Models/ |
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...