Skip to content
Open
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
12 changes: 12 additions & 0 deletions cmd/protoc-gen-openapi/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ func (g *OpenAPIv3Generator) buildOperationV3(
// Create the operation.
op := &v3.Operation{
Tags: []string{tagName},
Summary: extractSummary(description),
Description: description,
OperationId: operationID,
Parameters: parameters,
Expand Down Expand Up @@ -668,6 +669,17 @@ func (g *OpenAPIv3Generator) buildOperationV3(
return op, path
}

func extractSummary(comment string) string {
lines := strings.Split(comment, "\n")
for _, line := range lines {
trimmed := strings.TrimSpace(line)
if trimmed != "" {
return trimmed
}
}
return ""
}

// addOperationToDocumentV3 adds an operation to the specified path/method.
func (g *OpenAPIv3Generator) addOperationToDocumentV3(d *v3.Document, op *v3.Operation, path string, methodName string) {
var selectedPathItem *v3.NamedPathItem
Expand Down