swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

No documentation for how to get AdditionalProperties to show up with @Schema

Open darrenheadrick opened this issue 5 years ago • 3 comments

So, Im trying to generate swagger for a Map.

the Scala Map class has a property on it for Empty, which is showing up by default, so Im trying to find a way to annotate the field to ignore that.

@Schema(`type` = "object", implementation = classOf[Map[String, Any]])

Generates:

"attributes": {
"required": [
"empty"
],
"type": "object",
"properties": {
"empty": {
"type": "boolean"
},
"traversableAgain": {
"type": "boolean"
}
},
"additionalProperties": {
"type": "object"
}
},

I can use:

@Schema(`type` = "object", implementation = classOf[Object]) 

which generates:

"attributes": {
"type": "object"
},

However, there doesnt seem to be a way to set additionalProperties = true on the just the object?

darrenheadrick avatar Apr 03 '19 22:04 darrenheadrick

Have anyone found the way? (We are having the same problem.)

zmumi avatar Oct 04 '19 17:10 zmumi

However, there doesnt seem to be a way to set additionalProperties = true on the just the object?

FYI, additionalProperties: true is the default value for objects. That is,

type: object

is equivalent to

type: object
additionalProperties: true

hkosova avatar Sep 23 '21 12:09 hkosova

@hkosova Although it's equivalent, some generators need additionalProperties to generate nicely typed models. I thought @Schema(additionalProperties = Schema.AdditionalPropertiesValue.TRUE) would generated additionalProperties: true but that doesn't seem to be the case. Is there a workaround here?

mpokryva avatar Sep 09 '22 15:09 mpokryva