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

Error with enums containing the value 'no' #646

Closed
advance512 opened this issue Jul 29, 2018 · 3 comments
Closed

Error with enums containing the value 'no' #646

advance512 opened this issue Jul 29, 2018 · 3 comments

Comments

@advance512
Copy link

Description

An enum that contains the value 'no' has that value converted to False in the schema validator, causing validation errors.

Expected behaviour

'no' means 'no'.

Actual behaviour

'no' is cast to False.

Steps to reproduce

Just create an enum like this:

Countries:
    type: string
    enum:
      - ad
      - ae
      - af
      - ag
      - ai
      - al
      - am
      - ao
      - aq
      - ar
      - as
      - at
      - au
      - aw
      - ax
      - az
      - ba
      - bb
      - bd
      - be
      - bf
      - bg
      - bh
      - bi
      - bj
      - bl
      - bm
      - bn
      - bo
      - bq
      - br
      - bs
      - bt
      - bv
      - bw
      - by
      - bz
      - ca
      - cc
      - cd
      - cf
      - cg
      - ch
      - ci
      - ck
      - cl
      - cm
      - cn
      - co
      - cr
      - cu
      - cv
      - cw
      - cx
      - cy
      - cz
      - de
      - dj
      - dk
      - dm
      - do
      - dz
      - ec
      - ee
      - eg
      - eh
      - er
      - es
      - et
      - fi
      - fj
      - fk
      - fm
      - fo
      - fr
      - ga
      - gb
      - gd
      - ge
      - gf
      - gg
      - gh
      - gi
      - gl
      - gm
      - gn
      - gp
      - gq
      - gr
      - gs
      - gt
      - gu
      - gw
      - gy
      - hk
      - hm
      - hn
      - hr
      - ht
      - hu
      - id
      - ie
      - il
      - im
      - in
      - io
      - iq
      - ir
      - is
      - it
      - je
      - jm
      - jo
      - jp
      - ke
      - kg
      - kh
      - ki
      - km
      - kn
      - kp
      - kr
      - kw
      - ky
      - kz
      - la
      - lb
      - lc
      - li
      - lk
      - lr
      - ls
      - lt
      - lu
      - lv
      - ly
      - ma
      - mc
      - md
      - me
      - mf
      - mg
      - mh
      - mk
      - ml
      - mm
      - mn
      - mo
      - mp
      - mq
      - mr
      - ms
      - mt
      - mu
      - mv
      - mw
      - mx
      - my
      - mz
      - na
      - nc
      - ne
      - nf
      - ng
      - ni
      - nl
      - no
      - np
      - nr
      - nu
      - nz
      - om
      - pa
      - pe
      - pf
      - pg
      - ph
      - pk
      - pl
      - pm
      - pn
      - pr
      - ps
      - pt
      - pw
      - py
      - qa
      - re
      - ro
      - rs
      - ru
      - rw
      - sa
      - sb
      - sc
      - sd
      - se
      - sg
      - sh
      - si
      - sk
      - sl
      - sm
      - sn
      - so
      - sr
      - ss
      - st
      - sv
      - sx
      - sy
      - sz
      - tc
      - td
      - tf
      - tg
      - th
      - tj
      - tk
      - tl
      - tm
      - tn
      - to
      - tr
      - tt
      - tv
      - tw
      - tz
      - ua
      - ug
      - um
      - us
      - uy
      - uz
      - va
      - vc
      - ve
      - vg
      - vi
      - vn
      - vu
      - wf
      - ws
      - ye
      - yt
      - za
      - zm
      - zw

and send it as a parameter and as a response - you'll see it occur.

Additional info:

Example error from Connexion validator:

2018-07-27 11:56:33,268 [15/#7fc7bc797638] ERROR in validation.validate_schema:131: validation error: 'no' is not one of ['ww', 'eu', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'bq', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cw', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mf', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', False, 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'ss', 'st', 'sv', 'sx', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw']

I am guessing this is caused by some automatic code that casts 'no' to False and 'yes' to True, but I did not have enough time to go deeper into the code.

Output of the commands:

  • python --version
    Python 3.6.3

  • pip show connexion | grep "^Version\:"
    Version: 2016.0.dev1 (yeah, old, but it happens in latest too)

@dtkav
Copy link
Collaborator

dtkav commented Jul 29, 2018 via email

@advance512
Copy link
Author

Yeah, I've figured it out:
https://github.com/yaml/pyyaml/blob/93694d3e42b0cfd460f42beb75910aacacd9b5d2/lib3/yaml/constructor.py#L210

Kinda silly. Alright, will quote and hope it works. Thanks!

@hjacobs
Copy link
Contributor

hjacobs commented Jul 30, 2018

I guess we can close this issue? We/Connexion cannot fix the YAML spec.. 😏

@dtkav dtkav closed this as completed Aug 29, 2018
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

No branches or pull requests

3 participants