Skip to content

:? vs :sequential in JSON Schema transformers #793

Open
@NoahTheDuke

Description

@NoahTheDuke

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions