From a1757e686de6713a62d31e12feef649294678ba1 Mon Sep 17 00:00:00 2001 From: Louis Duchemin Date: Mon, 29 Apr 2024 09:03:51 +0200 Subject: [PATCH] Add contentMediaType field to generated schema when format is binary --- schema.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/schema.go b/schema.go index d8b93147..8a2b6f5f 100644 --- a/schema.go +++ b/schema.go @@ -154,12 +154,17 @@ func (s *Schema) MarshalJSON() ([]byte, error) { if s.Nullable { typ = []string{s.Type, "null"} } + var contentMediaType string + if s.Format == "binary" { + contentMediaType = "application/octet-stream" + } return marshalJSON([]jsonFieldInfo{ {"type", typ, omitEmpty}, {"title", s.Title, omitEmpty}, {"description", s.Description, omitEmpty}, {"$ref", s.Ref, omitEmpty}, {"format", s.Format, omitEmpty}, + {"contentMediaType", contentMediaType, omitEmpty}, {"contentEncoding", s.ContentEncoding, omitEmpty}, {"default", s.Default, omitNil}, {"examples", s.Examples, omitEmpty},