Closed mkreis closed 3 months ago
Depending on the order of alternative types including :nil, the Swagger JSON can become invalid.
With :nil at the end, it is fine: [:days-paid-leave-sick-child {:optional true} [:or [:int {:min 0 :max 30}] :nil]] becomes
[:days-paid-leave-sick-child {:optional true} [:or [:int {:min 0 :max 30}] :nil]]
days-paid-leave-sick-child: type: integer format: int64 minimum: 0 maximum: 30 x-anyOf: - type: integer format: int64 minimum: 0 maximum: 30 - type: 'null'
which is valid, but with :nil as first item, it is invalid: [:days-until-sick-leave-notice {:optional true} [:or :nil [:int {:min 1 :max 4}]]] becomes
[:days-until-sick-leave-notice {:optional true} [:or :nil [:int {:min 1 :max 4}]]]
days-until-sick-leave-notice: type: 'null' x-anyOf: - type: 'null' - type: integer format: int64 minimum: 1 maximum: 4
which is invalid:
type should be equal to one of the allowed values allowedValues: array, boolean, integer, number, object, string
Ok, this is a bug. :or should select first non-null as the base-type with JSON Schema. PR welcome on this.
:or
Depending on the order of alternative types including :nil, the Swagger JSON can become invalid.
With :nil at the end, it is fine:
[:days-paid-leave-sick-child {:optional true} [:or [:int {:min 0 :max 30}] :nil]]
becomeswhich is valid, but with :nil as first item, it is invalid:
[:days-until-sick-leave-notice {:optional true} [:or :nil [:int {:min 1 :max 4}]]]
becomeswhich is invalid: