Skip to content

Commit

Permalink
feat: prune unused components by default (#154)
Browse files Browse the repository at this point in the history
* feat: prune unused components by default

* chore: rename commented code to use walkHeaderRef

* refactor: remove comment for issue in kin-openapi

* chore: add missing parameter name

Co-authored-by: John Stableford <[email protected]>
Co-authored-by: John Stableford <[email protected]>
  • Loading branch information
3 people committed Apr 2, 2020
1 parent 88bfbcf commit 140ccfe
Show file tree
Hide file tree
Showing 16 changed files with 1,672 additions and 125 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[Makefile]
indent_size = 8
indent_style = tab

[{go.mod,go.sum,*.go}]
indent_size = 4
indent_style = tab

[{*.yml,*.yaml}]
indent_size = 2
indent_style = space
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ you can specify any combination of those.
- `spec`: embed the OpenAPI spec into the generated code as a gzipped blob. This
- `skip-fmt`: skip running `go fmt` on the generated code. This is useful for debugging
the generated file in case the spec contains weird strings.
- `skip-prune`: skip pruning unused components from the spec prior to generating
the code.

So, for example, if you would like to produce only the server code, you could
run `oapi-generate -generate types,server`. You could generate `types` and
Expand Down
4 changes: 3 additions & 1 deletion cmd/oapi-codegen/oapi-codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func main() {
)
flag.StringVar(&packageName, "package", "", "The package name for generated code")
flag.StringVar(&generate, "generate", "types,client,server,spec",
`Comma-separated list of code to generate; valid options: "types", "client", "chi-server", "server", "skip-fmt", "spec"`)
`Comma-separated list of code to generate; valid options: "types", "client", "chi-server", "server", "spec", "skip-fmt", "skip-prune"`)
flag.StringVar(&outputFile, "o", "", "Where to output generated code, stdout is default")
flag.StringVar(&includeTags, "include-tags", "", "Only include operations with the given tags. Comma-separated list of tags.")
flag.StringVar(&excludeTags, "exclude-tags", "", "Exclude operations that are tagged with the given tags. Comma-separated list of tags.")
Expand Down Expand Up @@ -79,6 +79,8 @@ func main() {
opts.EmbedSpec = true
case "skip-fmt":
opts.SkipFmt = true
case "skip-prune":
opts.SkipPrune = true
default:
fmt.Printf("unknown generate option %s\n", g)
flag.PrintDefaults()
Expand Down
238 changes: 221 additions & 17 deletions internal/test/components/components.gen.go

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

Loading

0 comments on commit 140ccfe

Please sign in to comment.