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

:? vs :sequential in JSON Schema transformers #793

Open
NoahTheDuke opened this issue Dec 6, 2022 · 0 comments · May be fixed by #795
Open

:? vs :sequential in JSON Schema transformers #793

NoahTheDuke opened this issue Dec 6, 2022 · 0 comments · May be fixed by #795
Labels
enhancement New feature or request

Comments

@NoahTheDuke
Copy link
Contributor

NoahTheDuke commented Dec 6, 2022

Hey friends, I've found a small difference between [:sequential {:max 1} schema] and [:? schema] when transformed with malli.json-schema:

(m.js/transform
  (m/schema
    [:map {:closed true}
     [:data [:?
             [:map {:closed true}
              [:id :int]
              [:description [:maybe :string]]
              [:name :string]]]]]))
; {:type "object",
;  :properties {:data {}},
;  :required [:data],
;  :additionalProperties false}
(m.js/transform
  (m/schema
    [:map {:closed true}
     [:data [:sequential {:max 1}
             [:map {:closed true}
              [:id :int]
              [:description [:maybe :string]]
              [:name :string]]]]]))
; {:type "object",
;  :properties
;  {:data
;   {:type "array",
;    :items
;    {:type "object",
;     :properties
;     {:id {:type "integer"},
;      :description {:oneOf [{:type "string"} {:type "null"}]},
;      :name {:type "string"}},
;     :required [:id :description :name],
;     :additionalProperties false},
;    :maxItems 1}},
;  :required [:data],
;  :additionalProperties false}

Is this intentional? If not, I can dig in to try to fix it.

@NoahTheDuke NoahTheDuke linked a pull request Dec 6, 2022 that will close this issue
@ikitommi ikitommi added the enhancement New feature or request label Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants