更新go-client与OpenAPI生成器

huangapple go评论77阅读模式
英文:

Update go-client with OpenAPI generator

问题

我尝试更新 https://github.com/hivelocity/hivelocity-client-go

我在 Makefile 中将生成器版本更新为 6.2.1,但是在最后我得到了以下错误信息:

...
...
go build github.com/hivelocity/hivelocity-client-go/client
go test ./...
# github.com/hivelocity/hivelocity-client-go/client/test
client/test/api_account_test.go:13:2: 非本地包中的本地导入“./openapi”
FAIL    github.com/hivelocity/hivelocity-client-go/client/test [设置失败]
?       github.com/hivelocity/hivelocity-client-go/client       [没有测试文件]
FAIL
make: *** [Makefile:17: client] 错误 1

生成的代码如下所示:

/*
Hivelocity API

Testing AccountApiService

*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech);

package client

import (
	openapiclient "./openapi"

没有 openapi 目录或包。

如何修复这个问题?

这是我的 fork:https://github.com/guettli/hivelocity-client-go

我唯一改变的是 Makefile 中的内容:

-GENERATOR_VERSION=4.3.1
+GENERATOR_VERSION=6.2.1

如果我运行 make,上述错误就会发生。

英文:

I try to update https://github.com/hivelocity/hivelocity-client-go

I updated the generator version in the Makefile to 6.2.1, but I get this error message at the end:

...
...
go build github.com/hivelocity/hivelocity-client-go/client
go test ./...
# github.com/hivelocity/hivelocity-client-go/client/test
client/test/api_account_test.go:13:2: local import "./openapi" in non-local package
FAIL    github.com/hivelocity/hivelocity-client-go/client/test [setup failed]
?       github.com/hivelocity/hivelocity-client-go/client       [no test files]
FAIL
make: *** [Makefile:17: client] Error 1

The generated code looks like this:

/*
Hivelocity API

Testing AccountApiService

*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech);

package client

import (
	openapiclient "./openapi"

There is no openapi directory or package.

How could this get fixed?

Here is my fork: https://github.com/guettli/hivelocity-client-go

The only thing I changed was in the Makefile:

-GENERATOR_VERSION=4.3.1
+GENERATOR_VERSION=6.2.1

If I run make above error happens.

答案1

得分: 0

上述错误在这个PR中得到解决。

-    {{goImportAlias}} "./openapi"
+    {{goImportAlias}} "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}"
英文:

Above error is solved in this PR

-    {{goImportAlias}} "./openapi"
+    {{goImportAlias}} "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}"

huangapple
  • 本文由 发表于 2023年1月3日 17:56:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/74991679.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定