Skip to content

Commit

Permalink
generate a main method for the api
Browse files Browse the repository at this point in the history
  • Loading branch information
casualjim committed Mar 1, 2015
1 parent 6fbcb10 commit 39293d6
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 62 deletions.
28 changes: 16 additions & 12 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion cmd/swagger/commands/generate/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type All struct {
SkipModels bool `long:"skip-models" description:"no models will be generated when this flag is specified"`
SkipOperations bool `long:"skip-operations" description:"no operations will be generated when this flag is specified"`
SkipSupport bool `long:"skip-support" description:"no supporting files will be generated when this flag is specified"`
IncludeMain bool `long:"include-main" description:"generates a main package for the server"`
IncludeUI bool `long:"include-ui" description:"when generating a main package it uses a middleware that also serves a swagger-ui for the swagger json"`
}

// Execute runs this command
Expand All @@ -39,7 +41,7 @@ func (a *All) Execute(args []string) error {
}

if !a.SkipSupport {
if err := generator.GenerateSupport(a.Name, a.Models, a.Operations, opts); err != nil {
if err := generator.GenerateSupport(a.Name, a.Models, a.Operations, a.IncludeMain, a.IncludeUI, opts); err != nil {
return err
}
}
Expand Down
10 changes: 7 additions & 3 deletions cmd/swagger/commands/generate/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ type Support struct {
Name string `json:"name" short:"A" description:"the name of the application" default:"swagger"`
Operations []string `long:"operation" short:"O" description:"specify an operation to include, repeat for multiple"`
// Tags []string `long:"tags" description:"the tags to include, if not specified defaults to all"`
Principal string `long:"principal" description:"the model to use for the security principal"`
Models []string `long:"model" short:"M" description:"specify a model to include, repeat for multiple"`
DumpData bool `long:"dump-data" description:"when present dumps the json for the template generator instead of generating files"`
Principal string `long:"principal" description:"the model to use for the security principal"`
Models []string `long:"model" short:"M" description:"specify a model to include, repeat for multiple"`
DumpData bool `long:"dump-data" description:"when present dumps the json for the template generator instead of generating files"`
IncludeMain bool `long:"include-main" description:"generates a main package for the server"`
IncludeUI bool `long:"include-ui" description:"when generating a main package it uses a middleware that also serves a swagger-ui for the swagger json"`
}

// Execute generates the supporting files file
Expand All @@ -19,6 +21,8 @@ func (s *Support) Execute(args []string) error {
s.Name,
nil,
nil,
s.IncludeMain,
s.IncludeUI,
generator.GenOpts{
Spec: string(s.Spec),
Target: string(s.Target),
Expand Down
2 changes: 1 addition & 1 deletion cmd/swagger/commands/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (d *ui) Execute(args []string) error {
return err
}
if fi.IsDir() {
return fmt.Errorf("expected")
return fmt.Errorf("%s is a directory, expected a file", fileName)
}

orig := fileName
Expand Down
Loading

0 comments on commit 39293d6

Please sign in to comment.