Skip to content

Commit

Permalink
fix(openapi): description should drop openapi annotate
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Dec 13, 2024
1 parent 482b2e7 commit 29c057b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ go 1.23.3
require (
github.com/davecgh/go-spew v1.1.1
github.com/go-courier/logr v0.3.1
github.com/go-json-experiment/json v0.0.0-20240815175050-ebd3a8989ca1
github.com/go-json-experiment/json v0.0.0-20241209202007-cef7d841f55f
github.com/juju/ansiterm v1.0.0
github.com/octohelm/gengo v0.0.0-20241023040556-a66fecda6cd6
github.com/octohelm/x v0.0.0-20241115085849-6402f8916ad3
github.com/onsi/gomega v1.35.1
golang.org/x/net v0.31.0
golang.org/x/sync v0.9.0
golang.org/x/tools v0.27.0
github.com/octohelm/gengo v0.0.0-20241115071734-9f4b1461bafa
github.com/octohelm/x v0.0.0-20241125035954-3d4eebd9779d
github.com/onsi/gomega v1.36.1
golang.org/x/net v0.32.0
golang.org/x/sync v0.10.0
golang.org/x/tools v0.28.0
)

require (
Expand All @@ -21,7 +21,7 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
18 changes: 18 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/go-courier/logr v0.3.1 h1:RcHM7qpO8OpuV+zFvJMXtJEspTnnYmT6uGiAomwb8X8
github.com/go-courier/logr v0.3.1/go.mod h1:NQWi+TSv0rS1RfyWHv7MNEI5cNy9NR6k1n8R24uHgdY=
github.com/go-json-experiment/json v0.0.0-20240815175050-ebd3a8989ca1 h1:xcuWappghOVI8iNWoF2OKahVejd1LSVi/v4JED44Amo=
github.com/go-json-experiment/json v0.0.0-20240815175050-ebd3a8989ca1/go.mod h1:BWmvoE1Xia34f3l/ibJweyhrT+aROb/FQ6d+37F0e2s=
github.com/go-json-experiment/json v0.0.0-20241209202007-cef7d841f55f h1:SX37BGMFGLP95fmXRM7/2PmFBi58SPmL0HnZiaJSy/s=
github.com/go-json-experiment/json v0.0.0-20241209202007-cef7d841f55f/go.mod h1:BWmvoE1Xia34f3l/ibJweyhrT+aROb/FQ6d+37F0e2s=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
Expand Down Expand Up @@ -31,29 +33,45 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/octohelm/gengo v0.0.0-20241023040556-a66fecda6cd6 h1:xsDe0CBcK1CW+dcQdH5mQuVBBScQ1vDbh+cYpVDI7AQ=
github.com/octohelm/gengo v0.0.0-20241023040556-a66fecda6cd6/go.mod h1:aviWG2Mi3alkrLA0G/UtypdM05btKHuLTabGkEmzjWI=
github.com/octohelm/gengo v0.0.0-20241115071734-9f4b1461bafa h1:Qez9GuFhfQpzIMBHTykCvaaKR1m2ERTGl7ibw+PQ9jk=
github.com/octohelm/gengo v0.0.0-20241115071734-9f4b1461bafa/go.mod h1:nEqtfNURVc62wke+9WrK+ojgzujzjrcrjhOg415Hghw=
github.com/octohelm/x v0.0.0-20241115085849-6402f8916ad3 h1:43P4uBxFSDtw3yhQPzUvTrkgobIrXiAw9llSvibnBTc=
github.com/octohelm/x v0.0.0-20241115085849-6402f8916ad3/go.mod h1:R/YWc3OdwyIs2SlMy30dd+bqmkiSl9GeuAAtxDKW0Lc=
github.com/octohelm/x v0.0.0-20241125035954-3d4eebd9779d h1:wFLxsKyv4Vl91zGj7h3LvbdbTegk1dzoNNnOOe+fTFA=
github.com/octohelm/x v0.0.0-20241125035954-3d4eebd9779d/go.mod h1:G5Bf8Ac4ZvdQiZ0wu2URwAFs5fviULjHHbB058iyzAg=
github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo=
github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
18 changes: 17 additions & 1 deletion pkg/openapi/jsonschema/extractors/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package extractors

import (
"github.com/octohelm/courier/pkg/openapi/jsonschema"
"iter"
"slices"
"strings"
)

Expand All @@ -14,7 +16,21 @@ func SetTitleOrDescription(metadata *jsonschema.Metadata, lines []string) {
metadata.Title = strings.TrimSpace(lines[0])

if len(lines) > 1 {
metadata.Description = strings.TrimSpace(strings.Join(lines[1:], "\n"))
metadata.Description = strings.TrimSpace(strings.Join(slices.Collect(filterLine(slices.Values(lines[1:]))), "\n"))
}
}
}

func filterLine(seq iter.Seq[string]) iter.Seq[string] {
return func(yield func(string) bool) {
for l := range seq {
if strings.HasPrefix(l, "openapi:") {
continue
}

if !yield(l) {
return
}
}
}
}

0 comments on commit 29c057b

Please sign in to comment.