OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.77k stars 6.57k forks source link

[REQ] Please consider providing options disable the Go Generator generates client test code and go.mod file #15023

Open tony95271 opened 1 year ago

tony95271 commented 1 year ago

Is your feature request related to a problem? Please describe.

We found several problems when using the Go generator version 6.2.1 to generate client code inside our Go project,

  1. The sub package name of the test code it generates is wrong;
    expected path/to/gen/test/api_xxx.test.go
package xxx_test

import (
    "context"
    "testing"

    openapiclient "path/to/our/go/project/gen/xxx/openapi"
    // ...     
)

got

package xxx_test

import (
    "context"
    "testing"

    openapiclient "../openapi"
    // ...     
)

the xxx is packageName option pass to Go generator tool via configuration file.

BTW: the option isGoSubmodule does not help no matter set it true or false.

  1. the Go generator generates client code as a Go sub-package breaks our main Go project dependency and auto-building

We have to remove go.mod go.sum from client source code folder to fix it by manual every time we update client code.

Describe the solution you'd like

Please consider providing two options noTest one for disable generating test code, and another noGoMod for diable go.mod go.sum, thanks.

https://openapi-generator.tech/docs/generators/go/#config-options

Describe alternatives you've considered

Additional context

stephichau commented 12 months ago

+1 please 😭