From 9f1a88f4af258529e66370ab32f3fd69a589c405 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 15 Jan 2026 09:33:30 +0100 Subject: [PATCH 1/3] feat(cosmosgen): add openapi excludes --- ignite/cmd/generate_openapi.go | 7 ++++- ignite/config/chain/base/config.go | 3 ++- ignite/pkg/cosmosgen/cosmosgen.go | 12 +++++---- ignite/pkg/cosmosgen/generate_openapi.go | 27 ++++++++++--------- ignite/pkg/cosmosgen/generate_openapi_test.go | 2 +- ignite/services/chain/generate.go | 8 +++--- ignite/services/scaffolder/scaffolder.go | 2 +- 7 files changed, 37 insertions(+), 24 deletions(-) diff --git a/ignite/cmd/generate_openapi.go b/ignite/cmd/generate_openapi.go index a5f6f2ef97..74940bc966 100644 --- a/ignite/cmd/generate_openapi.go +++ b/ignite/cmd/generate_openapi.go @@ -8,6 +8,8 @@ import ( "github.com/ignite/cli/v29/ignite/services/chain" ) +var excludeFlag = "exclude" + func NewGenerateOpenAPI() *cobra.Command { c := &cobra.Command{ Use: "openapi", @@ -16,6 +18,7 @@ func NewGenerateOpenAPI() *cobra.Command { } c.Flags().AddFlagSet(flagSetYes()) + c.Flags().StringSlice(excludeFlag, []string{}, "List of proto files or directories to exclude from the OpenAPI spec generation") return c } @@ -47,7 +50,9 @@ func generateOpenAPIHandler(cmd *cobra.Command, _ []string) error { opts = append(opts, chain.GenerateProtoVendor()) } - err = c.Generate(cmd.Context(), cacheStorage, chain.GenerateOpenAPI(), opts...) + excludeList, _ := cmd.Flags().GetStringArray(excludeFlag) + + err = c.Generate(cmd.Context(), cacheStorage, chain.GenerateOpenAPI(excludeList), opts...) if err != nil { return err } diff --git a/ignite/config/chain/base/config.go b/ignite/config/chain/base/config.go index 5b1cfdce4f..85b2557223 100644 --- a/ignite/config/chain/base/config.go +++ b/ignite/config/chain/base/config.go @@ -59,7 +59,8 @@ type Composables struct { // OpenAPI configures OpenAPI spec generation for API. type OpenAPI struct { - Path string `yaml:"path" doc:"Relative path where the application's OpenAPI files are located."` + Path string `yaml:"path" doc:"Relative path where the application's OpenAPI files are located."` + ExcludeList []string `yaml:"exclude_list" doc:"List of proto paths to exclude OpenAPI from generation (supports wildcards)."` } // Faucet configuration. diff --git a/ignite/pkg/cosmosgen/cosmosgen.go b/ignite/pkg/cosmosgen/cosmosgen.go index 88f1c536f1..4b615d3610 100644 --- a/ignite/pkg/cosmosgen/cosmosgen.go +++ b/ignite/pkg/cosmosgen/cosmosgen.go @@ -29,7 +29,8 @@ type generateOptions struct { composablesOut func(module.Module) string composablesRootPath string - specOut string + openAPISpecOut string + openAPIExcludeList []string } // ModulePathFunc defines a function type that returns a path based on a Cosmos SDK module. @@ -63,9 +64,10 @@ func WithGoGeneration() Option { } // WithOpenAPIGeneration adds OpenAPI spec generation. -func WithOpenAPIGeneration(out string) Option { +func WithOpenAPIGeneration(out string, excludeList []string) Option { return func(o *generateOptions) { - o.specOut = out + o.openAPISpecOut = out + o.openAPIExcludeList = excludeList } } @@ -167,8 +169,8 @@ func Generate(ctx context.Context, cacheStorage cache.Storage, appPath, protoDir } } - if g.opts.specOut != "" { - if err := g.generateOpenAPISpec(ctx); err != nil { + if g.opts.openAPISpecOut != "" { + if err := g.generateOpenAPISpec(ctx, g.opts.openAPIExcludeList...); err != nil { return err } } diff --git a/ignite/pkg/cosmosgen/generate_openapi.go b/ignite/pkg/cosmosgen/generate_openapi.go index 364e78578b..6e2de22b0f 100644 --- a/ignite/pkg/cosmosgen/generate_openapi.go +++ b/ignite/pkg/cosmosgen/generate_openapi.go @@ -28,7 +28,7 @@ func (g *generator) openAPITemplate() string { return filepath.Join(g.appPath, g.protoDir, "buf.gen.swagger.yaml") } -func (g *generator) generateOpenAPISpec(ctx context.Context) error { +func (g *generator) generateOpenAPISpec(ctx context.Context, excludeList ...string) error { var ( specDirs = make([]string, 0) conf = swaggercombine.New("HTTP API Console", g.goModPath) @@ -98,16 +98,19 @@ func (g *generator) generateOpenAPISpec(ctx context.Context) error { dir, g.openAPITemplate(), cosmosbuf.ExcludeFiles( - "*/osmosis-labs/fee-abstraction/*", - "*/module.proto", - "*/testutil/*", - "*/testdata/*", - "*/cosmos/orm/*", - "*/cosmos/reflection/*", - "*/cosmos/app/v1alpha1/*", - "*/cosmos/tx/config/v1/config.proto", - "*/cosmos/msg/textual/v1/textual.proto", - "*/cosmos/vesting/v1beta1/vesting.proto", + append(excludeList, []string{ + "*/strangelove_ventures/poa/*", + "*/osmosis-labs/fee-abstraction/*", + "*/module.proto", + "*/testutil/*", + "*/testdata/*", + "*/cosmos/orm/*", + "*/cosmos/reflection/*", + "*/cosmos/app/v1alpha1/*", + "*/cosmos/tx/config/v1/config.proto", + "*/cosmos/msg/textual/v1/textual.proto", + "*/cosmos/vesting/v1beta1/vesting.proto", + }...)..., ), cosmosbuf.FileByFile(), ); err != nil { @@ -165,7 +168,7 @@ func (g *generator) generateOpenAPISpec(ctx context.Context) error { } } - out := g.opts.specOut + out := g.opts.openAPISpecOut if !hasAnySpecChanged { // In case the generated output has been changed diff --git a/ignite/pkg/cosmosgen/generate_openapi_test.go b/ignite/pkg/cosmosgen/generate_openapi_test.go index 3b14eb0e73..baa2eddc7a 100644 --- a/ignite/pkg/cosmosgen/generate_openapi_test.go +++ b/ignite/pkg/cosmosgen/generate_openapi_test.go @@ -89,7 +89,7 @@ func TestGenerateOpenAPI(t *testing.T) { buf: buf, appModules: m, opts: &generateOptions{ - specOut: openAPIFile, + openAPISpecOut: openAPIFile, }, } diff --git a/ignite/services/chain/generate.go b/ignite/services/chain/generate.go index 5b32c31c4e..421f886a8f 100644 --- a/ignite/services/chain/generate.go +++ b/ignite/services/chain/generate.go @@ -22,6 +22,7 @@ type generateOptions struct { isTSClientEnabled bool isComposablesEnabled bool isOpenAPIEnabled bool + openAPIExcludeList []string tsClientPath string composablesPath string } @@ -57,9 +58,10 @@ func GenerateComposables(path string) GenerateTarget { } // GenerateOpenAPI enables generating OpenAPI spec for your chain. -func GenerateOpenAPI() GenerateTarget { +func GenerateOpenAPI(excludeList []string) GenerateTarget { return func(o *generateOptions) { o.isOpenAPIEnabled = true + o.openAPIExcludeList = excludeList } } @@ -86,7 +88,7 @@ func (c *Chain) generateFromConfig(ctx context.Context, cacheStorage cache.Stora var targets []GenerateTarget if conf.Client.OpenAPI.Path != "" { - targets = append(targets, GenerateOpenAPI()) + targets = append(targets, GenerateOpenAPI(conf.Client.OpenAPI.ExcludeList)) } if generateClients { @@ -149,7 +151,7 @@ func (c *Chain) Generate( openAPIPath = filepath.Join(c.app.Path, openAPIPath) } - options = append(options, cosmosgen.WithOpenAPIGeneration(openAPIPath)) + options = append(options, cosmosgen.WithOpenAPIGeneration(openAPIPath, targetOptions.openAPIExcludeList)) } if targetOptions.isTSClientEnabled { diff --git a/ignite/services/scaffolder/scaffolder.go b/ignite/services/scaffolder/scaffolder.go index 723a77b6bc..20a7fc831d 100644 --- a/ignite/services/scaffolder/scaffolder.go +++ b/ignite/services/scaffolder/scaffolder.go @@ -173,7 +173,7 @@ func protoc(ctx context.Context, cacheStorage cache.Storage, projectPath, protoD openAPIPath = filepath.Join(projectPath, openAPIPath) } - options = append(options, cosmosgen.WithOpenAPIGeneration(openAPIPath)) + options = append(options, cosmosgen.WithOpenAPIGeneration(openAPIPath, conf.Client.OpenAPI.ExcludeList)) } if err := cosmosgen.Generate( From 5bd69f22fd424e5d30557d7f90ee880f9a34095e Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 15 Jan 2026 09:34:54 +0100 Subject: [PATCH 2/3] test: fix test --- changelog.md | 1 + ignite/config/chain/parse_test.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/changelog.md b/changelog.md index 208142df8e..619a55d031 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ ## Changes +- []() Implement openapi excludes. - [#4850](https://github.com/ignite/cli/pull/4850) Add default GitHub Actions for linting and testing. - [#4849](https://github.com/ignite/cli/pull/4849) Bump `cosmos-sdk` version to `v0.53.5` and minimum Go version to `1.25`. diff --git a/ignite/config/chain/parse_test.go b/ignite/config/chain/parse_test.go index e5b58698f0..f1fa184f28 100644 --- a/ignite/config/chain/parse_test.go +++ b/ignite/config/chain/parse_test.go @@ -154,6 +154,7 @@ client: path: override-1 openapi: path: docs/static/include1.yml + exclude_list: [] validators: - name: alice bonded: 100000000stake`, @@ -200,6 +201,7 @@ client: path: override-2 openapi: path: docs/static/include2.yml + exclude_list: [] validators: - name: alice bonded: 100000000stake @@ -259,6 +261,7 @@ client: path: override-1 openapi: path: docs/static/include1.yml + exclude_list: [] validators: - name: alice bonded: 100stake`, @@ -302,6 +305,7 @@ client: path: override-2 openapi: path: docs/static/include2.yml + exclude_list: [] validators: - name: alice bonded: 100000000stake @@ -368,6 +372,7 @@ client: path: override-2 openapi: path: docs/static/include2.yml + exclude_list: [] validators: - name: alice bonded: 100stake @@ -436,6 +441,7 @@ client: path: override-2 openapi: path: docs/static/include2.yml + exclude_list: [] validators: - name: alice bonded: 100stake From aff10d198cfeb45317c8a47acd251a5b5fc0a97a Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 15 Jan 2026 09:35:11 +0100 Subject: [PATCH 3/3] cl --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 619a55d031..0bd23ec8a3 100644 --- a/changelog.md +++ b/changelog.md @@ -4,7 +4,7 @@ ## Changes -- []() Implement openapi excludes. +- [#4855](https://github.com/ignite/cli/pull/4855) Implement openapi excludes. - [#4850](https://github.com/ignite/cli/pull/4850) Add default GitHub Actions for linting and testing. - [#4849](https://github.com/ignite/cli/pull/4849) Bump `cosmos-sdk` version to `v0.53.5` and minimum Go version to `1.25`.