-
Notifications
You must be signed in to change notification settings - Fork 12
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
Update kin openapi from 0.97.0 to 0.127.0 #99
Conversation
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.
Limited set of local testing worked for me. LGTM. Thank you.
One note: I found that while working on this PR, one of the tests failed with the following error. It may be a macOS-specific issue, as described in golang/go#57905.
‣ make test-generated
Testing generated source ...
go test ./soracom/generated/cmd
2024/09/18 18:17:43 [001] INFO: Got request /v1/subscribers example.com GET http://example.com/v1/subscribers
2024/09/18 18:17:43 [001] INFO: Sending request GET http://example.com/v1/subscribers
2024/09/18 18:17:43 [001] INFO: Received response 404 Not Found
2024/09/18 18:17:43 [001] INFO: Copying response to client 404 Not Found [404]
2024/09/18 18:17:43 [001] INFO: Copied 1256 bytes to client error=<nil>
2024/09/18 18:17:43 [002] INFO: Running 1 CONNECT handlers
2024/09/18 18:17:43 [002] INFO: on 0th handler: &{1 <nil> 0x10098da90} api.soracom.io:443
--- FAIL: TestDetermineActualPathOf (0.00s)
self_update_test.go:205:
Error Trace: /Users/.../soracom-cli/soracom/generated/cmd/self_update_test.go:205
Error: Not equal:
expected: "/var/folders/n3/6zd4mt6n70ldwbhy03s3jt940000gn/T/2336598677"
actual : "/private/var/folders/n3/6zd4mt6n70ldwbhy03s3jt940000gn/T/2336598677"
Diff:
--- Expected
+++ Actual
@@ -1 +1 @@
-/var/folders/n3/6zd4mt6n70ldwbhy03s3jt940000gn/T/2336598677
+/private/var/folders/n3/6zd4mt6n70ldwbhy03s3jt940000gn/T/2336598677
Test: TestDetermineActualPathOf
FAIL
FAIL github.com/soracom/soracom-cli/soracom/generated/cmd 1.607s
FAIL
make: *** [test-generated] Error 1
Tested with Go 1.20 and 1.22, and the results are consistent. I believe the failure wasn't introduced by this PR, so I approved it.
‣ go version
go version go1.20 darwin/arm64
‣ sw_vers
ProductName: macOS
ProductVersion: 15.0
BuildVersion: 24A335
In macOS, /var
and /private/var
point to the same location, so the self-update
worked as expected.
‣ ./soracom/dist/0.0.0/soracom_0.0.0_darwin_arm64 self-update
There is a newer soracom-cli version 'v1.2.0'.
Release Note: https://github.com/soracom/soracom-cli/releases/tag/v1.2.0
If you installed soracom-cli using a package manager, please use that to update this:
brew upgrade soracom-cli
or
dpkg -i soracom_1.2.0_arm64.deb
Do you want to continue updating? (y/N) y
It updated successfully.
What do you think of this quick and dirty fix?
diff --git a/soracom/generated/cmd/self_update_test.go b/soracom/generated/cmd/self_update_test.go
index 64ee15c..e066ba5 100644
--- a/soracom/generated/cmd/self_update_test.go
+++ b/soracom/generated/cmd/self_update_test.go
@@ -3,6 +3,7 @@ package cmd
import (
"os"
"runtime"
+ "strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -202,5 +203,5 @@ func TestDetermineActualPathOf(t *testing.T) {
actualPath, err = determineActualPathOf(tempSymlinkPath)
assert.NoError(t, err)
- assert.Equal(t, tempFilePath, actualPath)
+ assert.True(t, strings.Contains(actualPath, tempFilePath))
}
@0x6b Thank you for the suggestion! I'd like to take it in. |
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.
LGTM, thank you!
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.
知識が無くて判断できませんでしたw
進めていただいていいと思います~。
依存関係の1つ、github.com/getkin/kin-openapi を最新のバージョンに更新しようとしたところ、いくつか破壊的変更があったためそれらに対応しました。
具体的には以下の通りです。
openapi3.Paths
型が生の map ではなく map を wrap したものになったため、.Map()
を呼んで内部の map を取り出すようにしましたopenapi3.Schema
の.Type
フィールドの型がstring
からopenapi.Types
型になり、複数の型を含有できるようになった関係で、"string"
などと直接比較できなくなったので.Slice()
を呼んで内部のスライスを取り出してその先頭要素を利用するようにしました。(現時点で複数の型を指定しているところは存在していないはずなのでそれで良いと判断しました)openapi3.Operation
の.ExtensionProps.Extensions
が廃止され.Extensions
に直接 extension (OpenAPI 標準でないプロパティ) が入るようになりました。また、その型も json.RawMessage からより具体的な型 ([]any
やmap[string]any
やstring
など) になったので、いったん json として Marshal した後 Unmarshal することで目的の型を取り出すようにしました。openapi3.Operation
の.Responses
フィールドがopenapi3.Responses
型から*openapi3.Responses
型に変わったため、hasArrayResponse()
関数の引数の型をそれに合わせました。生成されるファイル (soracom/generated 以下) に変化がないのでこの PR によって成果物に表面的には変化はないはずです(思わぬ副作用はあるかもしれません)