Documentation ¶
Index ¶
- func AddActionViaAST(data ControllerData, routerFilePath string, destDir string)
- func Application() *cobra.Command
- func Copy(src, dst string) error
- func CreateFileFromLocalTemplate(data interface{}, templateDir, destPath string)
- func CreateFileFromString(filepath string, contents string) error
- func CreateRouter(data RouteData, relativeTemplatePath, destDir string)
- func CreateSeedCommand(dest string) error
- func CreateSeederWithName(structName string, destDir string) error
- func CreateSeedersFromModels(dir string, dest string) error
- func CreateStructFromParameterObject(o *ParameterObject) (string, error)
- func CreateStructFromResponseObject(m *ResponseModel) (string, error)
- func CreateStructFromSchemaObject(o *SchemaObject) (string, error)
- func G() *cobra.Command
- func GenerateFromOA(oa3 *openapi3.T, dest, templateDir, configDir string)
- func GenerateFromUserTemplate(name string, templateType string) error
- func GetGoPrimitiveType(t string) string
- func GetGoType(name string, p *Property) string
- func GetLastPathPart(path string) string
- func GetPackageName() string
- func LoadSwaggerV2AsV3(specPath string) *openapi3.T
- func LoadWithKin(specPath string) *openapi3.T
- func Model() *cobra.Command
- func NewControllerStatement(resource string) *dst.AssignStmt
- func NewRouteRegistrationStatement(action Action) *dst.ExprStmt
- func OA() *cobra.Command
- func PrintJSON(v interface{})
- func Resource() *cobra.Command
- func Root() *cobra.Command
- func RunGoFmt(appDir string)
- func RunGoImports(appDir string)
- func Seed() *cobra.Command
- func Swagger() *cobra.Command
- func Title(s string) string
- type Action
- type AdditionalProperties
- type ControllerData
- type File
- type Generator
- type GoMVCConfig
- type Item
- type ParameterObject
- type ParameterSchema
- type Property
- type Response
- type ResponseModel
- type ResponseObject
- type RouteData
- type Schema
- type SchemaObject
- type SchemaType
- type TemplateHelper
- type TestPath
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddActionViaAST ¶
func AddActionViaAST(data ControllerData, routerFilePath string, destDir string)
func Application ¶
Application is the cli command that creates new application.
func Copy ¶
Copy the src file to dst. Any existing file will be overwritten and will not copy file attributes. https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang
func CreateFileFromLocalTemplate ¶
func CreateFileFromLocalTemplate(data interface{}, templateDir, destPath string)
func CreateFileFromString ¶
CreateFileFromString takes a filepath as the destination of the file to be created as well as the contents to be written to this file.
func CreateRouter ¶
CreateRouter creates a router.go file to be used in the controllers directory
func CreateSeedCommand ¶
CreateSeedCommand creates a single cmd that inserts records for all models
func CreateSeederWithName ¶
CreateSeederWithName creates a file with a single function. This function connects to the DB and inserts records for each model using each the model factories.
func CreateSeedersFromModels ¶
CreateSeedersFromModels iterates through the given directory finds models the creates seed files in the given destination
func CreateStructFromParameterObject ¶
func CreateStructFromParameterObject(o *ParameterObject) (string, error)
func CreateStructFromResponseObject ¶
func CreateStructFromResponseObject(m *ResponseModel) (string, error)
func CreateStructFromSchemaObject ¶
func CreateStructFromSchemaObject(o *SchemaObject) (string, error)
func GenerateFromOA ¶
GenerateFromOA is the primary logic for the oa command, creating controllers
func GetGoPrimitiveType ¶
func GetLastPathPart ¶
func GetPackageName ¶
func GetPackageName() string
func LoadSwaggerV2AsV3 ¶
LoadSwaggerV2AsV3 takes the file path of a v2 Swagger file and returns a V3 representation
func LoadWithKin ¶
LoadWithKin loads an OpenAPI spec into memory using the kin-openapi library
func NewControllerStatement ¶
func NewControllerStatement(resource string) *dst.AssignStmt
func RunGoImports ¶
func RunGoImports(appDir string)
func Seed ¶
Seed is the cli command that creates new seeders based on structs in your application's "models" directory
Types ¶
type Action ¶
type Action struct { SingularResource string // Resource is loosely related with what the Controller is and has many actions Resource string // Name is the function name bound to the Controller Name string // Method is the HTTP verb Method string `json:"method,omitempty"` // Path is the associated url path Path string `json:"path,omitempty"` // Handler is the generic resource action name e.g. Index, Create Handler string `json:"handler,omitempty"` }
func NewCRUDActions ¶
type AdditionalProperties ¶
type ControllerData ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator wraps functionality for reading and manipulating a single OpenAPI spec
func NewGenerator ¶
NewGenerator is a constructor for Generator
type GoMVCConfig ¶
type GoMVCConfig struct { Denylist []string // contains filtered or unexported fields }
func NewGoMVCConfig ¶
func NewGoMVCConfig(configDir string) GoMVCConfig
NewGoMVCConfig is a constructor for a gomvc configuration read into memory
func (*GoMVCConfig) IsDenylisted ¶
func (c *GoMVCConfig) IsDenylisted(path string) bool
type ParameterObject ¶
type ParameterObject struct { Description string `json:"description,omitempty"` In string `json:"in,omitempty"` Name string `json:"name,omitempty"` Required bool `json:"required,omitempty"` Schema Property `json:"schema,omitempty"` }
func LoadParameterObject ¶
func LoadParameterObject(name string, r *openapi3.ParameterRef) ParameterObject
type ParameterSchema ¶
type Property ¶
type Property struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Type string `json:"type,omitempty"` Items Item `json:"items,omitempty"` Format string `json:"format,omitempty"` Required bool `json:"required,omitempty"` GoType string `json:"go_type,omitempty"` Ref string `json:"$ref,omitempty"` AdditionalProperties AdditionalProperties `json:"additionalProperties,omitempty"` }
type Response ¶
func NewResponse ¶
func NewResponse(statusCode string, resRef *openapi3.ResponseRef) Response
NewResponse is a constructor for the custom Response object
func NewResponses ¶
func NewResponses(specResponses map[string]*openapi3.ResponseRef) []Response
NewResponses creates a list of responses from an OA3 response ref
type ResponseModel ¶
func LoadResponseObject ¶
func LoadResponseObject(name string, r *openapi3.Response) ResponseModel
type ResponseObject ¶
type ResponseObject struct { Content map[string]SchemaType `json:"content,omitempty"` Description string `json:"description,omitempty"` }
type RouteData ¶
type RouteData struct {
Controllers []ControllerData `json:"controllers,omitempty"`
}
type SchemaObject ¶
type SchemaObject struct { Name string Description string `json:"description,omitempty"` Properties map[string]Property `json:"properties,omitempty"` Required []string `json:"required,omitempty"` Type string `json:"type,omitempty"` Title string `json:"title,omitempty"` GoType string Items Item }
func LoadSchemaObject ¶
func LoadSchemaObject(name string, r *openapi3.SchemaRef) SchemaObject
todo: collect enums
type SchemaType ¶
type SchemaType struct {
Schema Schema `json:"schema,omitempty"`
}