How to specify in OpenAPI components/schemas, that named String property is not-nullable/required?

Viewed 56

In my project, there is an OpenAPI 3.0.1 spec. One of the schema components has property of type array.

components:
  schemas:
    cardKey:
      description: ...
      format: base64
      type: string
    
    newRequest:
      description: ...
      properties:
        cardKeyList:
          description: ...
          items:
            $ref: '#/components/schemas/cardKey'
          minItems: 1
          type: array
      required:
      - cards

The issue is, that in Java it translates to:

@Valid
private List<String> cardKeyList = new ArrayList<>();

but I can't seem to find a way, to specify, that cardKey, that is present in that ArrayList can't be null as in minLength, must be at least 1.

As an additional info the project is written in Java 17 and is based on Spring Boot. OpenAPI spec is used with SpringDoc.

0 Answers
Related