-
Notifications
You must be signed in to change notification settings - Fork 43
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 support for type string with format binary #231
Merged
cjbooms
merged 3 commits into
cjbooms:master
from
ascheja:string-with-format-binary-falls-back-to-string
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
openapi: 3.0.1 | ||
info: | ||
description: Testing binary body and binary response | ||
title: Test | ||
version: '0.0' | ||
paths: | ||
/binary-data: | ||
post: | ||
operationId: postBinaryData | ||
requestBody: | ||
required: true | ||
content: | ||
application/octet-stream: | ||
schema: | ||
type: string | ||
format: binary | ||
responses: | ||
200: | ||
description: Success | ||
content: | ||
application/octet-stream: | ||
schema: | ||
type: string | ||
format: binary |
26 changes: 26 additions & 0 deletions
26
src/test/resources/examples/binary/controllers/micronaut/Controllers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ie.zalando.controllers | ||
|
||
import io.micronaut.http.HttpResponse | ||
import io.micronaut.http.annotation.Body | ||
import io.micronaut.http.annotation.Consumes | ||
import io.micronaut.http.annotation.Controller | ||
import io.micronaut.http.annotation.Post | ||
import io.micronaut.http.annotation.Produces | ||
import javax.validation.Valid | ||
import kotlin.ByteArray | ||
|
||
@Controller | ||
interface BinaryDataController { | ||
/** | ||
* | ||
* | ||
* @param applicationOctetStream | ||
*/ | ||
@Post(uri = "/binary-data") | ||
@Consumes(value = ["application/octet-stream"]) | ||
@Produces(value = ["application/octet-stream"]) | ||
fun postBinaryData( | ||
@Body @Valid | ||
applicationOctetStream: ByteArray | ||
): HttpResponse<ByteArray> | ||
} |
32 changes: 32 additions & 0 deletions
32
src/test/resources/examples/binary/controllers/spring/Controllers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ie.zalando.controllers | ||
|
||
import org.springframework.http.ResponseEntity | ||
import org.springframework.stereotype.Controller | ||
import org.springframework.validation.annotation.Validated | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestMethod | ||
import javax.validation.Valid | ||
import kotlin.ByteArray | ||
|
||
@Controller | ||
@Validated | ||
@RequestMapping("") | ||
interface BinaryDataController { | ||
/** | ||
* | ||
* | ||
* @param applicationOctetStream | ||
*/ | ||
@RequestMapping( | ||
value = ["/binary-data"], | ||
produces = ["application/octet-stream"], | ||
method = [RequestMethod.POST], | ||
consumes = ["application/octet-stream"] | ||
) | ||
fun postBinaryData( | ||
@RequestBody @Valid | ||
applicationOctetStream: ByteArray | ||
): | ||
ResponseEntity<ByteArray> | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we tack this example on to an existing test case rather than creating a new example?
By just adding an additional
format binary
property to one single test caseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, which one do you want it added to? From what I can see there are 5 files that currently generate controller code for both spring and micronaut:
Based on that I don't think it really fits anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will merge as-is