Skip to content

Commit

Permalink
gnostic-summary: fix plugin to write output in the same directory as …
Browse files Browse the repository at this point in the history
…its input file. (#178)

* gnostic-summary writes output in the same directory as its input file.

Modify the file name generation so that "summary.txt" gets written
in the same directory as the input spec. This is typically only relevant
when gnostic is run on an input file with a hierarchical path, e.g.

  gnostic xkcd.com/1.0.0/openapi.yaml --errors_out=.

* Update plugin test data.
  • Loading branch information
timburks authored Jun 4, 2020
1 parent 0a63761 commit 966d1db
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion discovery/discovery.pb.go

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

2 changes: 1 addition & 1 deletion extensions/extension.pb.go

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

2 changes: 1 addition & 1 deletion metrics/vocabulary.pb.go

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

2 changes: 1 addition & 1 deletion openapiv2/OpenAPIv2.pb.go

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

2 changes: 1 addition & 1 deletion openapiv3/OpenAPIv3.pb.go

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

8 changes: 7 additions & 1 deletion plugins/gnostic-summary/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
package main

import (
"log"
"path/filepath"

"github.com/golang/protobuf/proto"
openapiv2 "github.com/googleapis/gnostic/openapiv2"
openapiv3 "github.com/googleapis/gnostic/openapiv3"
Expand Down Expand Up @@ -110,8 +113,11 @@ func main() {
}
}
}
outputName := filepath.Join(
filepath.Dir(env.Request.SourceName), "summary.txt")
log.Printf("generating %+v", outputName)
f := &plugins.File{
Name: "summary.txt",
Name: outputName,
Data: []byte(code.String()),
}
env.Response.Files = append(env.Response.Files, f)
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin.pb.go

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

2 changes: 1 addition & 1 deletion surface/surface.pb.go

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

2 changes: 1 addition & 1 deletion testdata/v2.0/yaml/sample-petstore.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


summary.txt --------------------
../examples/v2.0/yaml/summary.txt --------------------
Swagger: 2.0
Host: petstore.swagger.io
BasePath: /v1
Expand Down

0 comments on commit 966d1db

Please sign in to comment.