Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add octet-stream mimetype #127

Merged
merged 1 commit into from
May 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ func (operation *Operation) ParseAcceptComment(commentLine string) error {
operation.Consumes = append(operation.Consumes, "application/vnd.api+json")
case "json-stream", "application/x-json-stream":
operation.Consumes = append(operation.Consumes, "application/x-json-stream")
case "octet-stream", "application/octet-stream":
operation.Consumes = append(operation.Consumes, "application/octet-stream")
default:
return fmt.Errorf("%v accept type can't accepted", a)
}
Expand Down Expand Up @@ -334,6 +336,8 @@ func (operation *Operation) ParseProduceComment(commentLine string) error {
operation.Produces = append(operation.Produces, "application/vnd.api+json")
case "json-stream", "application/x-json-stream":
operation.Produces = append(operation.Produces, "application/x-json-stream")
case "octet-stream", "application/octet-stream":
operation.Produces = append(operation.Produces, "application/octet-stream")
default:
return fmt.Errorf("%v produce type can't accepted", a)
}
Expand Down
10 changes: 6 additions & 4 deletions operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ func TestParseAcceptComment(t *testing.T) {
"multipart/form-data",
"application/x-www-form-urlencoded",
"application/vnd.api+json",
"application/x-json-stream"
"application/x-json-stream",
"application/octet-stream"
]
}`
comment := `/@Accept json,xml,plain,html,mpfd,x-www-form-urlencoded,json-api,json-stream`
comment := `/@Accept json,xml,plain,html,mpfd,x-www-form-urlencoded,json-api,json-stream,octet-stream`
operation := NewOperation()
err := operation.ParseComment(comment)
assert.NoError(t, err)
Expand All @@ -71,10 +72,11 @@ func TestParseProduceComment(t *testing.T) {
"multipart/form-data",
"application/x-www-form-urlencoded",
"application/vnd.api+json",
"application/x-json-stream"
"application/x-json-stream",
"application/octet-stream"
]
}`
comment := `/@Produce json,xml,plain,html,mpfd,x-www-form-urlencoded,json-api,json-stream`
comment := `/@Produce json,xml,plain,html,mpfd,x-www-form-urlencoded,json-api,json-stream,octet-stream`
operation := new(Operation)
operation.ParseComment(comment)
b, _ := json.MarshalIndent(operation, "", " ")
Expand Down