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

Json is represented as "type": "object" #303

Closed
capaj opened this issue Jan 25, 2022 · 8 comments · Fixed by #304
Closed

Json is represented as "type": "object" #303

capaj opened this issue Jan 25, 2022 · 8 comments · Fixed by #304
Labels

Comments

@capaj
Copy link

capaj commented Jan 25, 2022

It should be generated as

{         
  "anyOf": [
        { "type": "object" },
        {
          "type": "array"
        }
      ]
}

it is generated as

{"type": "object"}
valentinpalkovic pushed a commit that referenced this issue Jan 25, 2022
The produced JSON Schema didn't allow arrays as an input for a JSON type.

fixes #303
valentinpalkovic pushed a commit that referenced this issue Jan 25, 2022
### [1.6.1](v1.6.0...v1.6.1) (2022-01-25)

### Bug Fixes

* Generated JSON type allows arrays ([7ae084a](7ae084a)), closes [#303](#303)

### Dependencies and Other Build Updates

* fix semantic release ([27cab5c](27cab5c))
* Fix semantic release ([4c46e26](4c46e26))
* fix semantic-version release ([e7ae2b2](e7ae2b2))
* **deps-dev:** Add missing conventionalcommits dependency ([fe9c86b](fe9c86b))
* Automatically build release for dependency updates ([163befb](163befb))
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 1.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@valentinpalkovic
Copy link
Owner

valentinpalkovic commented Jan 25, 2022

@capaj Thank you for reporting this! The Issue is resolved and should be fixed now :)

@capaj
Copy link
Author

capaj commented Jan 25, 2022

@valentinpalkovic oh thank you for being able to jump on this so fast.

I just wish I had realized sooner, that a valid JSON is also scalar values like string, null or a number, so the generated type here should really be:

 "type": ["number", "string", "boolean", "object", "array", "null"]

sorry for that. I mostly use graphql these days, so I forgot how to properly do any type in json schema.

@valentinpalkovic
Copy link
Owner

valentinpalkovic commented Jan 25, 2022

@capaj No problem! :)

I just wanted to discuss with you, whether it makes sense to define the type without null for the case, that the JSON field is required!

Required case:

"type": ["number", "string", "boolean", "object", "array"]

Not required:

"type": ["number", "string", "boolean", "object", "array", "null"]

I know, that per definition the JSON type is allowed to also be null, but I would adjust this to conform to the user's expectation! If the user defines a JSON field as required, then null shouldn't be a valid value.

What do you think?

(See #305)

valentinpalkovic pushed a commit that referenced this issue Jan 25, 2022
@capaj
Copy link
Author

capaj commented Jan 25, 2022

yes, I do think null is to be expected.
I mainly use postgre as my DB and postgre will happily accept null and indeed we do use nulls in our Json fields in our production DB. So the generated schema should accept it too.

@valentinpalkovic
Copy link
Owner

Alright! I will adjust my MR tomorrow and I will release a new version afterwards! I will let you know.

valentinpalkovic pushed a commit that referenced this issue Jan 26, 2022
### [1.6.2](v1.6.1...v1.6.2) (2022-01-26)

### Bug Fixes

* Add more valid types for JSON type ([3ead22c](3ead22c)), closes [#303](#303)
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 1.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@capaj
Copy link
Author

capaj commented Jan 26, 2022

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

Successfully merging a pull request may close this issue.

2 participants