I have the below api for which I need to have two parameters of content type application/x-www-form-urlencoded
and therefore am using @RequestBody
instead of @Parameter
@Operation(summary = "Revoke given permissions", description = "Allows admin to revoke permissions to users")
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public void revokePermission(
@RequestBody(description = "the permission id", content = @Content(mediaType = "application/x-www-form-urlencoded",
schema = { @Schema(type = "String", name = "permission_id",
description = "id of the permission to be revoked", required = true)},
{ @Schema(type = "String", name = "permission_type",
description = "the permission type")}))
String permission_id, String permissionType) {
do_something();
}
I need the swagger.json to be like below example, but I do not know how to generate it using springdoc .I tried @ArraySchema also , but I am not getting the output I need. I am making some mistakes in the syntax and not able to find examples online.
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"properties": {
"permission_id": {
"description": "id of the permission to be revoked",
"type": "string"
},
"permission_type": {
"description": "the permission type",
"type": "string"
}
},
"required": ["permission_id"]
}
}
}
}
Any help is highly appreciated. TIA