Skip to content

Commit

Permalink
Add contentMediaType field to generated schema when format is binary
Browse files Browse the repository at this point in the history
  • Loading branch information
lsdch committed Apr 29, 2024
1 parent a93ebe6 commit a1757e6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit a1757e6

Please sign in to comment.