-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): add swagger UI configuration
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package swagger | ||
|
||
import "github.com/cosmos/cosmos-sdk/server/v2/config" | ||
|
||
// Config represents Swagger configuration options | ||
type Config struct { | ||
// Enable enables the Swagger UI endpoint | ||
Enable bool `mapstructure:"enable"` | ||
// Path is the URL path where Swagger UI will be served | ||
Path string `mapstructure:"path"` | ||
} | ||
|
||
// DefaultConfig returns default configuration for Swagger | ||
func DefaultConfig() Config { | ||
return Config{ | ||
Enable: false, | ||
Path: "/swagger", | ||
} | ||
} | ||
|
||
// Validate validates the configuration | ||
func (c Config) Validate() error { | ||
if c.Path == "" { | ||
return fmt.Errorf("swagger path cannot be empty") | ||
} | ||
return nil | ||
} |