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

Invalid Swagger JSON with [:or :nil] alternatives #1006

Closed
mkreis opened this issue Feb 1, 2024 · 1 comment · Fixed by #1023
Closed

Invalid Swagger JSON with [:or :nil] alternatives #1006

mkreis opened this issue Feb 1, 2024 · 1 comment · Fixed by #1023
Labels
bug Something isn't working help wanted Help most welcome

Comments

@mkreis
Copy link

mkreis commented Feb 1, 2024

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:
            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:
            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
@ikitommi ikitommi added bug Something isn't working help wanted Help most welcome labels Feb 4, 2024
@ikitommi
Copy link
Member

ikitommi commented Feb 4, 2024

Ok, this is a bug. :or should select first non-null as the base-type with JSON Schema. PR welcome on this.

ikitommi added a commit that referenced this issue Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Help most welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants