Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions internal/cmd/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ func (g *Gen) collectServices(paths map[string]any) []service {
if len(tags) == 0 {
continue
}
// Skip streaming endpoints: their 200 response is not application/json
// (e.g. application/x-ndjson). The typed do/doGet path reads the whole
// body and JSON-decodes one envelope, which is wrong for a line-delimited
// stream. These get a hand-written method instead (see sessions_export.go).
if isStreamingOp(o) {
continue
}
tag, _ := tags[0].(string)
byTag[tag] = append(byTag[tag], opEntry{p, m, o})
}
Expand Down Expand Up @@ -209,6 +216,21 @@ func (g *Gen) collectServices(paths map[string]any) []service {
return services
}

// isStreamingOp reports whether an operation's 200 response is a non-JSON
// streaming body (its 200 content has no "application/json" key). Such endpoints
// — e.g. session/export returning application/x-ndjson — cannot be modeled by the
// typed do/doGet path (which buffers the body and decodes one JSON envelope) and
// are excluded from generation in favor of a hand-written streaming method.
func isStreamingOp(o map[string]any) bool {
resp := asMap(asMap(o["responses"])["200"])
content := asMap(resp["content"])
if len(content) == 0 {
return false // no body at all is not a streaming response
}
_, hasJSON := content["application/json"]
return !hasJSON
}

// getRequestType synthesizes a request struct from a GET op's query parameters
// and records it for emission. Returns "" when the op has no query parameters.
func (g *Gen) getRequestType(o map[string]any, hint string) string {
Expand Down
244 changes: 244 additions & 0 deletions models_gen.go

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

Loading
Loading