feat(api): Implement API generator with stratoscale for go swagger
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -5,12 +5,16 @@ package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"git.dev.m-and-m.ovh/mderasse/gouick/helpers/api_types"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// apiCmd represents the api command.
|
||||
var apiCmd = &cobra.Command{
|
||||
Use: "api",
|
||||
Short: "Generate Go-Swagger Files and Controllers",
|
||||
Short: "Generate API Files and Controllers",
|
||||
Run: runGenerateAPI,
|
||||
}
|
||||
|
||||
@ -20,4 +24,25 @@ func init() {
|
||||
|
||||
// runGenerateAPI will generate api files such as controllers, server, unit test, ... for the current project.
|
||||
func runGenerateAPI(cmd *cobra.Command, args []string) {
|
||||
|
||||
log.Debugf("Starting command GenerateAPI")
|
||||
|
||||
currentPath, config, err := loadProjectAndConfig()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
apiType, err := api_types.GetAPIType(config.ProjectType)
|
||||
if err != nil {
|
||||
log.Error("Impossible to load that API Type generator")
|
||||
return
|
||||
}
|
||||
|
||||
// Generate Dockerfile
|
||||
log.Info("Generating API")
|
||||
err = apiType.GenerateAPI(currentPath, config)
|
||||
if err != nil {
|
||||
log.Errorf("Fail to generate API Files. The following error happen: %s", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user