Skip to content

Commit

Permalink
encoding/openapi: simplify looping over CUE fields
Browse files Browse the repository at this point in the history
Including definitions in the iterator, only to then skip over them,
seems unnecessary.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I0e660ef63394026f4e1781cf5dfbd88556955a7b
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1204946
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
mvdan committed Nov 29, 2024
1 parent 671ce60 commit afafedb
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions encoding/openapi/openapi.go
Original file line number Diff line number Diff line change
@@ -145,10 +145,7 @@ func (c *Config) compose(inst cue.InstanceOrValue, schemas *ast.StructLit) (x *a
var title, version string
var info *ast.StructLit

for i, _ := val.Fields(cue.Definitions(true)); i.Next(); {
if i.Selector().IsDefinition() {
continue
}
for i, _ := val.Fields(); i.Next(); {
label := i.Selector().Unquoted()
attr := i.Value().Attribute("openapi")
if s, _ := attr.String(0); s != "" {

0 comments on commit afafedb

Please sign in to comment.