Skip to content

Conversation

@sloretz
Copy link

@sloretz sloretz commented Sep 26, 2025

Does this look like a change you'd accept?

I'd like to override the content-type annotation of a streaming API to text/event-stream for use with server-sent events. However, when I add an openapi.v3.operation annotation and generate an OpenAPI spec I get a schema that lists two response types for "200".

I'm assuming the problem is the proto file lists fields as repeated with Named... message types rather than map, and this proto.Merge appends those messages as if they were a list no matter what.

// Merge any `Operation` annotations with the current
extOperation := proto.GetExtension(method.Desc.Options(), v3.E_Operation)
if extOperation != nil {
proto.Merge(op, extOperation.(*v3.Operation))
}

I think the fix would be to write a custom merge function that resolves conflicts. My preference would be to keep the last annotation. For now I've only updated the tests to show the behavior I want to change. How does it look to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant