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:
13
helpers/api_types/base/generate_api.go
Normal file
13
helpers/api_types/base/generate_api.go
Normal file
@ -0,0 +1,13 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"github.com/juju/errors"
|
||||
|
||||
"git.dev.m-and-m.ovh/mderasse/gouick/helpers"
|
||||
"git.dev.m-and-m.ovh/mderasse/gouick/models"
|
||||
)
|
||||
|
||||
// GenerateAPI will generate api files such as server, controllers, test, ....
|
||||
func (a APIType) GenerateAPI(path string, config *models.Config) error {
|
||||
return errors.NotImplementedf("%s not implemented for %s", helpers.GetCurrentFuncName(), a.GetName())
|
||||
}
|
31
helpers/api_types/go_swagger/generate_api.go
Normal file
31
helpers/api_types/go_swagger/generate_api.go
Normal file
@ -0,0 +1,31 @@
|
||||
package go_swagger
|
||||
|
||||
import (
|
||||
"github.com/juju/errors"
|
||||
|
||||
"git.dev.m-and-m.ovh/mderasse/gouick/helpers"
|
||||
"git.dev.m-and-m.ovh/mderasse/gouick/models"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// GenerateAPI will generate api files such as server, controllers, test, ....
|
||||
func (a APIType) GenerateAPI(path string, config *models.Config) error {
|
||||
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
||||
|
||||
// Launch Go Swagger
|
||||
err := a.executeGoSwagger(path)
|
||||
if err != nil {
|
||||
log.Error("Fail to Execute Go Swagger")
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
// Delete api yaml temporary file
|
||||
err = a.deleteTempApiYaml(path)
|
||||
if err != nil {
|
||||
log.Error("Fail to delete api yaml temporary file")
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -95,6 +95,7 @@ func (a APIType) goSwaggerGenerate(path string) error {
|
||||
generateCmd.Server.Models.ModelPackage = "models"
|
||||
generateCmd.Server.Operations.APIPackage = "operations"
|
||||
generateCmd.Server.Shared.StrictResponders = true
|
||||
generateCmd.Server.Shared.Template = "stratoscale"
|
||||
|
||||
return generateCmd.Server.Execute(nil)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import "git.dev.m-and-m.ovh/mderasse/gouick/models"
|
||||
type APITypeInterface interface {
|
||||
CheckInitialize() error
|
||||
CreateProjectSkeleton(path string, config *models.Config) error
|
||||
GenerateAPI(path string, config *models.Config) error
|
||||
GenerateDockerfile(path string, config *models.Config) error
|
||||
GenerateLauncher(path string, config *models.Config) error
|
||||
GenerateMakefile(path string, config *models.Config) error
|
||||
|
Reference in New Issue
Block a user