From 74ec4e071c2b9f2ca6add94fb2601feb9e7791ad Mon Sep 17 00:00:00 2001 From: Sam Eiderman Date: Tue, 27 Dec 2022 20:41:41 +0200 Subject: [PATCH] Support field extensions with use_allof_for_refs --- protoc-gen-openapiv2/internal/genopenapi/template.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protoc-gen-openapiv2/internal/genopenapi/template.go b/protoc-gen-openapiv2/internal/genopenapi/template.go index ce69c34bd67..85323279872 100644 --- a/protoc-gen-openapiv2/internal/genopenapi/template.go +++ b/protoc-gen-openapiv2/internal/genopenapi/template.go @@ -520,11 +520,12 @@ func renderMessageAsDefinition(msg *descriptor.Message, reg *descriptor.Registry // Per the JSON Reference syntax: Any members other than "$ref" in a JSON Reference object SHALL be ignored. // https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#section-3 // However, use allOf to specify Title/Description/readOnly fields. - if fieldSchema.Title != "" || fieldSchema.Description != "" || fieldSchema.ReadOnly { + if fieldSchema.Title != "" || fieldSchema.Description != "" || fieldSchema.ReadOnly || len(fieldSchema.extensions) > 0 { fieldSchema = openapiSchemaObject{ Title: fieldSchema.Title, Description: fieldSchema.Description, ReadOnly: fieldSchema.ReadOnly, + extensions: fieldSchema.extensions, AllOf: []allOfEntry{{Ref: fieldSchema.Ref}}, } } else {