Skip to content

Commit 140ccfe

Browse files
pseudo-sujohnstablefordJohn Stableford
authored
feat: prune unused components by default (#154)
* 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]>
1 parent 88bfbcf commit 140ccfe

File tree

16 files changed

+1672
-125
lines changed

16 files changed

+1672
-125
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[Makefile]
4+
indent_size = 8
5+
indent_style = tab
6+
7+
[{go.mod,go.sum,*.go}]
8+
indent_size = 4
9+
indent_style = tab
10+
11+
[{*.yml,*.yaml}]
12+
indent_size = 2
13+
indent_style = space

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ you can specify any combination of those.
398398
- `spec`: embed the OpenAPI spec into the generated code as a gzipped blob. This
399399
- `skip-fmt`: skip running `go fmt` on the generated code. This is useful for debugging
400400
the generated file in case the spec contains weird strings.
401+
- `skip-prune`: skip pruning unused components from the spec prior to generating
402+
the code.
401403

402404
So, for example, if you would like to produce only the server code, you could
403405
run `oapi-generate -generate types,server`. You could generate `types` and

cmd/oapi-codegen/oapi-codegen.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
)
4343
flag.StringVar(&packageName, "package", "", "The package name for generated code")
4444
flag.StringVar(&generate, "generate", "types,client,server,spec",
45-
`Comma-separated list of code to generate; valid options: "types", "client", "chi-server", "server", "skip-fmt", "spec"`)
45+
`Comma-separated list of code to generate; valid options: "types", "client", "chi-server", "server", "spec", "skip-fmt", "skip-prune"`)
4646
flag.StringVar(&outputFile, "o", "", "Where to output generated code, stdout is default")
4747
flag.StringVar(&includeTags, "include-tags", "", "Only include operations with the given tags. Comma-separated list of tags.")
4848
flag.StringVar(&excludeTags, "exclude-tags", "", "Exclude operations that are tagged with the given tags. Comma-separated list of tags.")
@@ -79,6 +79,8 @@ func main() {
7979
opts.EmbedSpec = true
8080
case "skip-fmt":
8181
opts.SkipFmt = true
82+
case "skip-prune":
83+
opts.SkipPrune = true
8284
default:
8385
fmt.Printf("unknown generate option %s\n", g)
8486
flag.PrintDefaults()

internal/test/components/components.gen.go

Lines changed: 221 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)