Skip to content

Commit

Permalink
Fix checking of error from jsonwriter.Marshal (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvwells authored Oct 9, 2020
1 parent 8e72155 commit 48b4738
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/gnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ func (g *Gnostic) writeTextOutput(message proto.Message) {
func (g *Gnostic) writeJSONYAMLOutput(message proto.Message) {
// Convert the OpenAPI document into an exportable MapSlice.
var rawInfo *yaml.Node
var err error
if g.sourceFormat == SourceFormatOpenAPI2 {
document := message.(*openapi_v2.Document)
rawInfo = document.ToRawInfo()
Expand All @@ -533,9 +532,8 @@ func (g *Gnostic) writeJSONYAMLOutput(message proto.Message) {
}
// Optionally write description in yaml format.
if g.yamlOutputPath != "" {
var bytes []byte
if rawInfo != nil {
bytes, err = yaml.Marshal(rawInfo)
bytes, err := yaml.Marshal(rawInfo)
if err != nil {
fmt.Fprintf(os.Stderr, "Error generating yaml output %s\n", err.Error())
fmt.Fprintf(os.Stderr, "info %+v", rawInfo)
Expand All @@ -547,13 +545,12 @@ func (g *Gnostic) writeJSONYAMLOutput(message proto.Message) {
}
// Optionally write description in json format.
if g.jsonOutputPath != "" {
var bytes []byte
if rawInfo != nil {
rawInfo := &yaml.Node{
Kind: yaml.DocumentNode,
Content: []*yaml.Node{rawInfo},
}
bytes, _ = jsonwriter.Marshal(rawInfo)
bytes, err := jsonwriter.Marshal(rawInfo)
if err != nil {
fmt.Fprintf(os.Stderr, "Error generating json output %s\n", err.Error())
}
Expand Down

0 comments on commit 48b4738

Please sign in to comment.