Skip to content

Commit

Permalink
Handle simple configs with output flag properly
Browse files Browse the repository at this point in the history
It turns out that a very simple command invocation, specifying only
the spec and `-o` flag to generate an output filename ignores the
output filename option.
  • Loading branch information
marcinromaszewicz committed Oct 28, 2022
1 parent cf23455 commit 8175447
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/oapi-codegen/oapi-codegen.go
Expand Up @@ -21,9 +21,10 @@ import (
"runtime/debug"
"strings"

"gopkg.in/yaml.v2"

"github.com/deepmap/oapi-codegen/pkg/codegen"
"github.com/deepmap/oapi-codegen/pkg/util"
"gopkg.in/yaml.v2"
)

func errExit(format string, args ...interface{}) {
Expand Down Expand Up @@ -334,6 +335,10 @@ func updateConfigFromFlags(cfg configuration) (configuration, error) {
strings.Join(unsupportedFlags, ", "))
}

if cfg.OutputFile == "" {
cfg.OutputFile = flagOutputFile
}

return cfg, nil
}

Expand Down

0 comments on commit 8175447

Please sign in to comment.