Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix json-schema type of maybe array #463

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomgi
Copy link
Contributor

@tomgi tomgi commented Jun 20, 2023

Make sure to not override an existing type: ["null", "array"] with type: "array" if it's already filled by visit_predicate before visit_set.

For example for the test schema

required(:list).maybe(:array).each do
hash do
required(:name).value(:string)
end
end

the result of the fix is:

{
   "$schema": "http://json-schema.org/draft-06/schema#",
   "type": "object",
   "properties": {
     "list": {
-      "type": "array",
+      "type": [
+        "null",
+        "array"
+      ],
       "items": {
         "type": "object",
         "properties": {
           "name": {
             "type": "string"
           }
         },
         "required": [
           "name"
         ]
       }
     }
   },
   "required": [
     "list"
   ]
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant