Update kin openapi from 0.97.0 to 0.127.0#99
Merged
Conversation
0x6b
approved these changes
Sep 18, 2024
Contributor
0x6b
left a comment
There was a problem hiding this comment.
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: 24A335In 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))
}
Collaborator
Author
|
@0x6b Thank you for the suggestion! I'd like to take it in. |
Contributor
makoto-soracom
left a comment
There was a problem hiding this comment.
知識が無くて判断できませんでしたw
進めていただいていいと思います~。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
依存関係の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 によって成果物に表面的には変化はないはずです(思わぬ副作用はあるかもしれません)