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 generation when all attributes of a map are optional,… #385

Conversation

jgrodziski
Copy link
Contributor

… an empty required attribute is forbidden by JSON-Schema Spec

… an empty required attribute is forbidden by JSON-Schema Spec
(let [required (->> children (filter (m/-comp not :optional second)) (mapv first))
object {:type "object"
:properties (apply array-map (mapcat (fn [[k _ s]] [k s]) children))}]
(if (empty? required) object (assoc object :required required))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golf: (cond-> object (seq required) (assoc :required required))

@ikitommi ikitommi merged commit 6fcdc4f into metosin:master Mar 5, 2021
@ikitommi
Copy link
Member

ikitommi commented Mar 5, 2021

thanks!

@jgrodziski
Copy link
Contributor Author

Thanks @ikitommi for your merging speed :)

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.

2 participants