英文:
How do you specify the module path when using go for openapi generator?
问题
生成go模块时,使用以下命令:
openapi-generator-cli generate \
--input-spec ../spec/myapi.yml \
--generator-name go \
--output ./generated/go \
--package-name myapi \
--global-property models,supportingFiles
生成的go.mod
文件将指定模块为:
module github.com/GIT_USER_ID/GIT_REPO_ID
go 1.18
require (
)
如何将github.com/GIT_USER_ID/GIT_REPO_ID
覆盖为github.com/myrepo/somedir/myapi
?
我已经查看了OpenAPI Generator文档和Go Generator文档,但似乎都没有说明如何实现。
有人有任何想法吗?
英文:
When generating a go module with
openapi-generator-cli generate \
--input-spec ../spec/myapi.yml \
--generator-name go \
--output ./generated/go \
--package-name myapi \
--global-property models,supportingFiles
the genrated go.mod
file specifies the module as
module github.com/GIT_USER_ID/GIT_REPO_ID
go 1.18
require (
)
How does one override the github.com/GIT_USER_ID/GIT_REPO_ID
to be something like: github.com/myrepo/somedir/myapi
?
I've checked the OpenAPI Generator docs and the Go Generator docs and neither seem to indicate how to do so.
Does anyone have any ideas?
答案1
得分: 3
当然,我发帖后立即进行了一次搜索,并在这里找到了答案,其中提到可以使用--git-user-id
和--git-repo-id
标志。
openapi-generator-cli generate \
--input-spec ../spec/myapi.yml \
--generator-name go \
--output ./generated/go \
--package-name myapi \
--git-user-id myuser \
--git-repo-id myrepo/somedir/myapi/generated/go \
--global-property models,supportingFiles
这将生成一个mod.go
文件,内容如下:
module github.com/myuser/myrepo/somedir/myapi/generated/go
go 1.18
require (
)
英文:
Of course as soon as I post I do one more search and find the answer here stating one can use the flags --git-user-id
and --git-repo-id
.
openapi-generator-cli generate \
--input-spec ../spec/myapi.yml \
--generator-name go \
--output ./generated/go \
--package-name myapi \
--git-user-id myuser \
--git-repo-id myrepo/somedir/myapi/generated/go \
--global-property models,supportingFiles
which results in a mod.go
file of:
module github.com/myuser/myrepo/somedir/myapi/generated/go
go 1.18
require (
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论