You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on airr-js, I was getting validation errors for fields with nullable: true and enum when the field value was null. I'm using the ajv package for validation, instead of custom written like our python library. Apparently, there has been various discussions about this as OpenAPI schema and JSON schema aren't 100% equivalent. From what I can gather, the conclusion was that null needs to be added to the enum list. When I do that, as shown below, then validation passes.
sex:
type: string
enum:
- male
- female
- pooled
- hermaphrodite
- intersex
- "not collected"
- "not applicable"
- null
nullable: true
description: Biological sex of subject
title: Sex
example: female
x-airr:
miairr: important
adc-query-support: true
set: 1
subset: subject
name: Sex
format: controlled vocabulary
This really only applies to the OpenAPI V3 spec. This is a simple fix but it might effect UIs that display those enum lists.
The text was updated successfully, but these errors were encountered:
Personally, I think that is dangerous. How do you differentiate that from me defining a field where "null" as a string is one of the allowed enum values. I think this would be a quite common use case. Similar to having "NA" or "None", "null" would be a relatively common string to find in an enum definition.
If you want the string "null" then put quotes around it in the enum like so, the following allows both the null value and the string "null" as acceptable values.
sex:
type: string
enum:
- male
- female
- pooled
- hermaphrodite
- intersex
- "not collected"
- "not applicable"
- "null"
- null
nullable: true
description: Biological sex of subject
title: Sex
example: female
x-airr:
miairr: important
adc-query-support: true
set: 1
subset: subject
name: Sex
format: controlled vocabulary
As OpenAPI is based on JSON schema spec, only null is a special value, stuff like "NA" and "None" are just strings.
While working on airr-js, I was getting validation errors for fields with
nullable: true
andenum
when the field value wasnull
. I'm using the ajv package for validation, instead of custom written like our python library. Apparently, there has been various discussions about this as OpenAPI schema and JSON schema aren't 100% equivalent. From what I can gather, the conclusion was thatnull
needs to be added to theenum
list. When I do that, as shown below, then validation passes.This really only applies to the OpenAPI V3 spec. This is a simple fix but it might effect UIs that display those enum lists.
The text was updated successfully, but these errors were encountered: