我有下面的对象与趾高气扬的描述:
/**
* Response about request failure
*/
@Schema(description = "Response about request failure")
data class ErrorDtoRs(
@field:Schema(description = "Error type", maxLength = 64)
val type: String? = null,
@field:Schema(description = "Error message", maxLength = 255)
val message: String?)
此对象的Swagger json:
"components": {
"schemas": {
"ErrorDtoRs": {
"type": "object",
"properties": {
"type": {
"maxLength": 64,
"type": "string",
"description": "Error type"
},
"message": {
"maxLength": 255,
"type": "string",
"description": "Error message"
}
},
"description": "Response about request failure"
},
如何为对象生成additionalProperties为false的swagger json,如下所示:
"components": {
"schemas": {
"ErrorDtoRs": {
"type": "object",
"additionalProperties": "false",
"properties": {
"type": {
"maxLength": 64,
"type": "string",
"description": "Error type"
},
"message": {
"maxLength": 255,
"type": "string",
"description": "Error message"
}
},
"description": "Response about request failure"
},
Swagger :2.1.4开放API:3.0.1
1条答案
按热度按时间o4tp2gmn1#
如果您使用的是
sprindoc-openapi
,您可以使用GroupedOpenApi
添加一个OpenApiCustomier
,并将其他属性设置为FALSE,如下所示:这还将阻止安全问题ID:
v3-schema-request-object-additionalproperties-true