Home  >  Article  >  Backend Development  >  Update go-client using OpenAPI generator

Update go-client using OpenAPI generator

WBOY
WBOYforward
2024-02-11 23:54:11985browse

使用 OpenAPI 生成器更新 go-client

php editor Youzi would like to introduce an important update to you: the update of the OpenAPI generator, especially the update of go-client. The OpenAPI Generator is a tool that automatically generates client code based on API definition files. This update mainly targets go-client and brings some important improvements and new features. By using this update, developers can more easily generate high-quality Go language client code, improving development efficiency and code quality. Next, we'll detail the improvements and benefits this update brings.

Question content

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

I updated the generator version in the makefile to 6.2.1 but ended up getting this error message:

...
...
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 is as follows:

/*
hivelocity api

testing accountapiservice

*/

// code generated by openapi generator (https://openapi-generator.tech);

package client

import (
    openapiclient "./openapi"

No openapi directory or package.

how to solve this problem?

This is my branch: https://github.com/guettli/hivelocity-client-go

The only thing I changed was the makefile:

-GENERATOR_VERSION=4.3.1
+GENERATOR_VERSION=6.2.1

The above error occurs if I run make.

Solution

The above error has been solved in this pr

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

The above is the detailed content of Update go-client using OpenAPI generator. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete