Skip to content

Golang Library fails to generate #118

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

Open
madpah opened this issue Apr 17, 2025 · 2 comments
Open

Golang Library fails to generate #118

madpah opened this issue Apr 17, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@madpah
Copy link
Collaborator

madpah commented Apr 17, 2025

See https://github.com/CycloneDX/transparency-exchange-api/actions/runs/14516836198/job/40727807660

Run go get github.com/stretchr/testify/assert
go: downloading github.com/stretchr/testify v1.10.0
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: added github.com/davecgh/go-spew v1.1.1
go: added github.com/pmezard/go-difflib v1.0.0
go: added github.com/stretchr/testify v1.10.0
go: added gopkg.in/yaml.v3 v3.0.1
# github.com/CycloneDX/transparency-exchange-api-go/test [github.com/CycloneDX/transparency-exchange-api-go/test.test]
Error: test/api_tea_product_test.go:2[9](https://github.com/CycloneDX/transparency-exchange-api/actions/runs/14516836198/job/40727807660#step:5:10):29: undefined: TypeProductIdentifierType
FAIL	github.com/CycloneDX/transparency-exchange-api-go/test [build failed]
FAIL
Error: Process completed with exit code 1.
@madpah madpah added the bug Something isn't working label Apr 17, 2025
@madpah
Copy link
Collaborator Author

madpah commented Apr 17, 2025

This appears to be a bug in OpenAPI Generator v7.12.0 and prior versions, where generated tests don't properly respect non-primitive types passed in the PATH.

Snippet of bad generated code:

func Test_tea_client_TEAProductAPIService(t *testing.T) {

	configuration := tea_client.NewConfiguration()
	apiClient := tea_client.NewAPIClient(configuration)

	t.Run("Test TEAProductAPIService GetTeaProductByIdentifier", func(t *testing.T) {

		t.Skip("skip test")  // remove to run test

		var productIdentifierType TypeProductIdentifierType

		resp, httpRes, err := apiClient.TEAProductAPI.GetTeaProductByIdentifier(context.Background(), productIdentifierType).Execute()

		require.Nil(t, err)
		require.NotNil(t, resp)
		assert.Equal(t, 200, httpRes.StatusCode)

	})

var productIdentifierType TypeProductIdentifierType should be var productIdentifierType tea_client.TypeProductIdentifierType

@madpah
Copy link
Collaborator Author

madpah commented Apr 17, 2025

OpenAPITools/openapi-generator#21107 has been opened against OpenAPI Generator to resolve the pending Go issue.

FYI @oej @vpetersson @ppkarwasz

@madpah madpah self-assigned this Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant