Skip to content

Commit

Permalink
Merge pull request #422 from lsdch/content-media-type
Browse files Browse the repository at this point in the history
Add contentMediaType field to generated schema when format is binary
  • Loading branch information
danielgtaylor committed Apr 29, 2024
2 parents eb7d476 + a1757e6 commit 3abb70d
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 3abb70d

Please sign in to comment.