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

Default value of @ArraySchema violates OAS 3.0

Open tkalmar opened this issue 4 years ago • 1 comments

I can specify the default value for an @ArraySchema with f.e.

@ArraySchema(arraySchema = @Schema(defaultValue =  "123"))

The OAS3.0 states default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if type is string, then default can be "foo" but cannot be 1.

So a default value of type String is wrong for any schema which is not of type string (array, int ...) I can not specify an array of default values for the array schema To make it worse, if i read the spec correctly if the items in the array are of type int i should specify an array of ints, when the item type is array i should specify an array of arrays ... This has an impact on real life projects, as can be seen on: https://github.com/springdoc/springdoc-openapi/issues/1010

tkalmar avatar Jan 20 '21 17:01 tkalmar

Any news here? I'd also be interested in a solution.

christopher-cudennec avatar Oct 12 '23 05:10 christopher-cudennec