Open adamkaplan opened 4 years ago
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
I'm experiencing this issue too. Will there fix for this soon?
I'm not sure if it's relevant but I'm not facing this issue when generating through the OpenAPI Generator maven plugin. Hopefully that can be a workaround for some people.
I'm experiencing this on both npm and mvn clean package
with NPM
openapi-generator-cli generate -g swift5 --additional-properties=projectName=OpenApiClient,podVersion=1.4.1,responseAs=Combine \
--library alamofire -o ./outDir \
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml
with mvn clean package
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g swift5 \
--additional-properties=projectName=OpenApiClient,podVersion=1.4.1,responseAs=Combine --library alamofire \
-o ./outDir -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml`
Pod::Spec.new do |s|
s.name = 'CloudHospitalClient'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.11'
s.tvos.deployment_target = '9.0'
s.watchos.deployment_target = '3.0'
s.version = '1.4.1'
s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1' }
s.authors = 'OpenAPI Generator'
s.license = 'Proprietary'
s.homepage = 'https://github.com/OpenAPITools/openapi-generator'
s.summary = 'CloudHospitalClient Swift SDK'
s.source_files = 'CloudHospitalClient/Classes/**/*.swift'
s.dependency 'Alamofire', '~> 4.9.1'
end
both generates same podspec as above where :tag => 'v1.0,0' fixed which I believe it is generated by below source code
Podspec.mustache line 9
s.source = {{#podSource}}{{& podSource}}{{/podSource}}{{^podSource}}{ :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v{{#apiInfo}}{{version}}{{/apiInfo}}{{^apiInfo}}}0.0.1{{/apiInfo}}' }{{/podSource}}
When the comma between :git and :tag removed:
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g swift5 --additional-properties=projectName=OpenApiClient,podVersion=1.4.1,responseAs=Combine --library alamofire -o ./outDir -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -p "podSource={ :git => 'git@github.com:adamkaplan/myclient.git' :tag => 'v1.4.0' }"
and it generates properly but without comma separation
Pod::Spec.new do |s| s.name = 'OpenApiClient' s.ios.deployment_target = '9.0' s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.watchos.deployment_target = '3.0' s.version = '1.4.1' s.source = { :git => 'git@github.com:adamkaplan/myclient.git' :tag => 'v1.4.0' } s.authors = 'OpenAPI Generator' s.license = 'Proprietary' s.homepage = 'https://github.com/OpenAPITools/openapi-generator' s.summary = 'OpenApiClient Swift SDK' s.source_files = 'OpenApiClient/Classes/*/.swift' s.dependency 'Alamofire', '~> 4.9.1' end
Bug Report Checklist
Description
This issue impacts the Podspec template for the following generators:
Clients are unable to set the podspec source. This renders the generated Pod unusable by any Cocoapod consumers for two reasons:
This issue is caused by issue #3874. I am opening a new bug report because this particular version of the issue can be remedied without fixing #3874 (which can be very complicated to address, and would impact all users).
openapi-generator version
Impacts v4 and the v5 branch
OpenAPI declaration file content or url
This issue can occur with any OpenAPI declaration file.
Command line used for generation
java -jar openapi-generator-cli.jar generate -g swift4 -i empty.json -p "podSource={ :git => 'git@github.com:adamkaplan/myclient.git', :tag => 'v0' }"
Steps to reproduce
Using the command above, the generated output in
OpenAPIClient.podspec
is:In particular, the issue is on the source line:
Observed:
s.source = { :git => 'git@github.com:adamkaplan/myclient.git'
Expected:s.source = { :git => 'git@github.com:adamkaplan/myclient.git', : tag => 'v0' }
The observed Podspec file is not parsable.
Related issues/PRs
The underlying problem is caused by Issue #3874
Suggest a fix
Fixing issue 3874 would suffice. However that issue is complicated. In practice, it is rare to need to override the entire
podSource
. Most Podspecs out there use a common syntax which varies only in the git repository URL:s.source = { :git => 'git@github.com:MyOrg/MyProj.git', :tag => s.version.to_s }
The tag is typically set to
s.version.to_s
which is Ruby for "use the tag that matches the Pod version". Therefore, I suggest adding a template option namedpodSourceRepo
which is a git-compatible specified like the one shown above. This would avoid the comma parsing issue and actually make using the Swift generators a bit easier for the majority of people.