restdocs-api-spec
restdocs-api-spec copied to clipboard
Feature: Support Request Parts
Related Isssue: #105 , #205
I am not good at English. If there's anything you don't understand, please leave a comment.
I know swagger and postman support file type.
- Swagger
- Postman
So I wrote the code to implement to support request with file.
RequestModel
private data class RequestModel(
....
val requestParts: List<OperationRequestPart>,
)
Add requestParts for multipart request.
FileSchema, FormData
class FileSchema(
builder: BinarySchemaBuilder
) : StringSchema(builder) {
...
val format: String
}
@JsonPropertyOrder({
"key",
"type",
"src",
"description",
})
public class FormData {
....
}
Make FileSchema/FormData for OpenApiGenerator/PostmanGenerator to handle spec for file type.
In Generator they are added to RequestModel and Body
data class RequestModel(
...
// FileSchema -> RequestPartFieldDescriptor
val requestParts: List<RequestPartFieldDescriptor>,
)
@JsonPropertyOrder({
"mode",
"raw",
"urlencoded",
"formdata"
})
public class Body { ... }