cancel
Showing results for 
Search instead for 
Did you mean: 

Array null values

SOLVED
Highlighted
Member

Array null values

Hello,

 

Is it possible to define an array that can not contain null? 

I'm compiling it to Java with Open API 3.0

 

f.e for this example

A:
type: array
minItems: 1
items:
$ref: "#/components/schemas/B"
B:
type: string
pattern: ^[a-z]+$

 I consider [null] or ["abc",null] invalid

 

Thanks in advance

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Array null values

Hi @radekoziol,

 

Your example is correct. In OpenAPI 3.0, null values are only allowed if the schema has the nullable: true attribute. Since the B schema is not marked as nullable, it only allows string values but not nulls.


Helen Kosova
SmartBear Documentation Team Lead
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

1 REPLY 1
Highlighted
Moderator

Re: Array null values

Hi @radekoziol,

 

Your example is correct. In OpenAPI 3.0, null values are only allowed if the schema has the nullable: true attribute. Since the B schema is not marked as nullable, it only allows string values but not nulls.


Helen Kosova
SmartBear Documentation Team Lead
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors
Top Kudoed Posts