From e49d1bfdd54f5fc7d45a68d945b3d9eb928da4eb Mon Sep 17 00:00:00 2001 From: Viktor Oreshkin Date: Fri, 18 Sep 2026 22:22:32 +0300 Subject: [PATCH] chore: make generated openapi a normal importable submodule --- go.mod | 7 +-- main.go | 2 +- openapi/.openapi-generator/FILES | 4 +- openapi/README.md | 2 +- openapi/docs/DefaultApi.md | 28 ++++++------ openapi/git_push.sh | 4 +- openapi/go.mod | 6 --- openapi/go.sum | 11 ----- openapi/test/api_default_test.go | 76 +++++++++++++++++++++++++++++++- 9 files changed, 99 insertions(+), 41 deletions(-) delete mode 100644 openapi/go.mod delete mode 100644 openapi/go.sum diff --git a/go.mod b/go.mod index 7b4fb3da..190bf3f3 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,13 @@ module github.com/ViRb3/wgcf/v2 go 1.26.0 require ( - github.com/ViRb3/wgcf/v2/openapi v0.0.0-00010101000000-000000000000 github.com/cockroachdb/errors v1.14.0 github.com/dustin/go-humanize v1.1.0 github.com/manifoldco/promptui v0.9.0 github.com/refraction-networking/utls v1.8.2 github.com/spf13/cobra v1.10.2 github.com/spf13/viper v1.21.0 + github.com/stretchr/testify v1.11.1 golang.org/x/crypto v0.57.0 ) @@ -18,6 +18,7 @@ require ( github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/getsentry/sentry-go v0.46.0 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect @@ -28,6 +29,7 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/sagikazarmark/locafero v0.11.0 // indirect github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect @@ -38,6 +40,5 @@ require ( go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/sys v0.48.0 // indirect golang.org/x/text v0.42.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/ViRb3/wgcf/v2/openapi => ./openapi diff --git a/main.go b/main.go index b723a097..d125fd01 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -//go:generate openapi-generator generate -i openapi-spec.yml -g go -o openapi --additional-properties=disallowAdditionalPropertiesIfNotPresent=false +//go:generate openapi-generator generate -i openapi-spec.yml -g go -o openapi --git-user-id ViRb3 --git-repo-id wgcf/v2 --additional-properties=disallowAdditionalPropertiesIfNotPresent=false,withGoMod=false,isGoSubmodule=true package main diff --git a/openapi/.openapi-generator/FILES b/openapi/.openapi-generator/FILES index 74d25d45..a119ad1d 100644 --- a/openapi/.openapi-generator/FILES +++ b/openapi/.openapi-generator/FILES @@ -1,4 +1,5 @@ .gitignore +.openapi-generator-ignore .travis.yml README.md api/openapi.yaml @@ -49,8 +50,6 @@ docs/UpdateAccountRequest.md docs/UpdateBoundDeviceRequest.md docs/UpdateSourceDeviceRequest.md git_push.sh -go.mod -go.sum model_account.go model_alternate_network.go model_app_mode.go @@ -94,4 +93,5 @@ model_update_account_request.go model_update_bound_device_request.go model_update_source_device_request.go response.go +test/api_default_test.go utils.go diff --git a/openapi/README.md b/openapi/README.md index d87e32bb..2718dcb5 100644 --- a/openapi/README.md +++ b/openapi/README.md @@ -22,7 +22,7 @@ go get golang.org/x/net/context Put the package under your project folder and add the following in import: ```go -import openapi "github.com/GIT_USER_ID/GIT_REPO_ID" +import openapi "github.com/ViRb3/wgcf/v2/openapi" ``` To use a proxy, set the environment variable `HTTP_PROXY`: diff --git a/openapi/docs/DefaultApi.md b/openapi/docs/DefaultApi.md index a66f6472..497f1d7b 100644 --- a/openapi/docs/DefaultApi.md +++ b/openapi/docs/DefaultApi.md @@ -36,7 +36,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -107,7 +107,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -181,7 +181,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -250,7 +250,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -321,7 +321,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -392,7 +392,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -460,7 +460,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -534,7 +534,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -607,7 +607,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -679,7 +679,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -750,7 +750,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -823,7 +823,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -899,7 +899,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { @@ -970,7 +970,7 @@ import ( "context" "fmt" "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func main() { diff --git a/openapi/git_push.sh b/openapi/git_push.sh index f53a75d4..db6b20aa 100644 --- a/openapi/git_push.sh +++ b/openapi/git_push.sh @@ -14,12 +14,12 @@ if [ "$git_host" = "" ]; then fi if [ "$git_user_id" = "" ]; then - git_user_id="GIT_USER_ID" + git_user_id="ViRb3" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="GIT_REPO_ID" + git_repo_id="wgcf/v2" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/openapi/go.mod b/openapi/go.mod deleted file mode 100644 index a7b52a2d..00000000 --- a/openapi/go.mod +++ /dev/null @@ -1,6 +0,0 @@ -module github.com/GIT_USER_ID/GIT_REPO_ID - -go 1.23 - -require ( -) diff --git a/openapi/go.sum b/openapi/go.sum deleted file mode 100644 index c966c8dd..00000000 --- a/openapi/go.sum +++ /dev/null @@ -1,11 +0,0 @@ -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/openapi/test/api_default_test.go b/openapi/test/api_default_test.go index 3c3d8f72..432ad02c 100644 --- a/openapi/test/api_default_test.go +++ b/openapi/test/api_default_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" + openapiclient "github.com/ViRb3/wgcf/v2/openapi" ) func Test_openapi_DefaultAPIService(t *testing.T) { @@ -22,6 +22,50 @@ func Test_openapi_DefaultAPIService(t *testing.T) { configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) + t.Run("Test DefaultAPIService AcknowledgeNotification", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var accountId string + var sourceDeviceId string + + httpRes, err := apiClient.DefaultAPI.AcknowledgeNotification(context.Background(), accountId, sourceDeviceId).Execute() + + require.Nil(t, err) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + + t.Run("Test DefaultAPIService DeleteBoundDevice", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var sourceDeviceId string + var apiVersion string + var boundDeviceId string + + resp, httpRes, err := apiClient.DefaultAPI.DeleteBoundDevice(context.Background(), sourceDeviceId, apiVersion, boundDeviceId).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + + t.Run("Test DefaultAPIService DeleteSourceDevice", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var apiVersion string + var sourceDeviceId string + + httpRes, err := apiClient.DefaultAPI.DeleteSourceDevice(context.Background(), apiVersion, sourceDeviceId).Execute() + + require.Nil(t, err) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + t.Run("Test DefaultAPIService GetAccount", func(t *testing.T) { t.Skip("skip test") // remove to run test @@ -66,6 +110,22 @@ func Test_openapi_DefaultAPIService(t *testing.T) { }) + t.Run("Test DefaultAPIService GetGatewayAuth", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var apiVersion string + var accountId string + var sourceDeviceId string + + resp, httpRes, err := apiClient.DefaultAPI.GetGatewayAuth(context.Background(), apiVersion, accountId, sourceDeviceId).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + t.Run("Test DefaultAPIService GetSourceDevice", func(t *testing.T) { t.Skip("skip test") // remove to run test @@ -141,6 +201,20 @@ func Test_openapi_DefaultAPIService(t *testing.T) { }) + t.Run("Test DefaultAPIService UpdateReceiptToken", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var sourceDeviceId string + var apiVersion string + + httpRes, err := apiClient.DefaultAPI.UpdateReceiptToken(context.Background(), sourceDeviceId, apiVersion).Execute() + + require.Nil(t, err) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + t.Run("Test DefaultAPIService UpdateSourceDevice", func(t *testing.T) { t.Skip("skip test") // remove to run test