Skip to content

A property of type of "array" e.g. one with ArraySchema can not be marked as required #2848

@kostya-lnk-ms

Description

@kostya-lnk-ms

I'm using core v3 2.0.2
The following is repro (in Kotlin)

@path("/")
class Api {
@get
fun getter() : Town = Town(listOf())
}

data class Town(
@get:[ ArraySchema( arraySchema = Schema(required = true), schema = Schema(required = true), minItems = 1,uniqueItems = true ) ]
val streets: List
)

@Test
fun tst() {
    val api = Reader().read(Api::class.java)
    val json = ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL)
                .writerWithDefaultPrettyPrinter().writeValueAsString(api)
    json.contains("required")
}

I expect that there should a way of saying that the "streets" property is required
That yields the following json model:

{ "openapi" : "3.0.1", "paths" : { "/" : { "get" : { "operationId" : "getter", "responses" : { "default" : { "description" : "default response", "content" : { "*/*" : { "schema" : { "$ref" : "#/components/schemas/Town" } } } } } } } }, "components" : { "schemas" : { "Town" : { "type" : "object", "properties" : { "streets" : { "minItems" : 1, "uniqueItems" : true, "type" : "array", "items" : { "type" : "string" } } } } } } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions