-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Swift5 Vapor 4 client library #9583
Conversation
15e82ec
to
f8c9ec0
Compare
91e1b3f
to
c76132c
Compare
@4brunu CI is passing, Travis is failing cause of Docker. |
|
||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class {{projectName}}API { | ||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class {{projectName}} { |
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.
@aymanbagabas this is a breaking change that affects a lot of file, and what I remember from the other PR is that this change was only related to naming, so I suggest to revert it please.
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.
Yes, it's only related to naming. However, it doesn't make sense to forcefully append "API" to the project name. The user should have a choice of having that in the name. Simply when desired, the user can append "API" to the project name and it would give the old behavior back.
I'll make a separate PR for that one. Should I base it on top of the 5.2.x branch?
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.
Honestly I don't think this is an option worth to create.
It will add extra complexity and we won't add nothing new or extra functionality to the project.
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.
Aesthetics matter, having this suffix in the name is extra complexity. By merging it to the 5.2.x branch, we will introduce a breaking change with fallback and we don't have to introduce any flags or options since the fallback is to have API
in the project name.
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.
But that would break every project that uses OpenAPI Swift Generator with compilation errors.
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.
Right, but for a generated library, I would rather have the project name matches the library class name since there is only one class. This also matches the SPM file structure for example the PlayingCard
library
example-package-playingcard
├── Sources
│ └── PlayingCard
│ ├── PlayingCard.swift
│ ├── Rank.swift
│ └── Suit.swift
└── Package.swift
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.
I see your point.
My main issue here is creating an extra burden on the user side.
To try to make this transition as smooth as possible, we could do something like this.
@available(*, deprecated, renamed: "PlayingCard")
public typealias PlayingCardAPI = PlayingCard
open class PlayingCard {
...
}
This way the old name PlayingCardAPI would still work, and the user could migrate when he wanted it.
Plus the IDE would presente a warning in a quick fix.
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.
Is that a yes? Should I create a PR for this?
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.
You last comment made sense to me, so for me it's a yes.
Could you please open a PR?
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.
@4brunu I'm also thinking about doing a similar thing for Configuration.mustache
and model.mustache
when using the swiftUseApiNamespace
option. I believe when users enable swiftUseApiNamespace
, the Configuration class and models should also be under the API namespace like what api.mustache
has. Because it doesn't make sense to do so for the API classes and not for the other classes. For example:
@available(*, deprecated, renamed: "PlayingCard.Configuration")
public typealias Configuration = PlayingCard.Configuration
extension PlayingCard {
open class Configuration {
...
}
}
and
@available(*, deprecated, renamed: "PlayingCard.Rank")
public typealias Rank = PlayingCard.Rank
extension PlayingCard {
enum Rank: Int {}
}
@aymanbagabas I left a comment on an issue that is a breaking change and creates a lot of noise. |
Opened in favor of #8515
TODOs:
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
,5.1.x
,6.0.x