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

Enum string value "YES" becomes "true" #1394

Closed
piebur opened this issue Sep 24, 2019 · 4 comments
Closed

Enum string value "YES" becomes "true" #1394

piebur opened this issue Sep 24, 2019 · 4 comments

Comments

@piebur
Copy link

piebur commented Sep 24, 2019

Version

  • vert.x core:3.7.0
  • vert.x web:3.7.0

Context

I encountered an exception which looks suspicious while utilizing the enum property with the value "YES"

Do you have a reproducer?

  • Link to github project/gist

Steps to reproduce

  1. Clone the OpenAPI sample https://github.com/vertx-howtos/web-and-openapi-howto
  2. Add the following property into components:schemas:Pet:properties:
isMale:
  type: string
  enum:
  - YES
  - MAYBE
  - NEVER
  1. Start the server and execute curl commands:
curl -X POST -H "Content-type: application/json" --data "{\"id\":4,\"name\":\"Steve\",\"isMale\":\"YES\"}" http://localhost:8080/pets

-> {"code":400,"message":"$.isMale: does not have a value in the enumeration [true, MAYBE, NEVER]"}

Extra

Work around: Add " around the enum value "YES", see below

isMale:
  type: string
  enum:
  - "YES"
  - MAYBE
  - NEVER
curl -X POST -H "Content-type: application/json" --data "{\"id\":4,\"name\":\"Steve\",\"isMale\":\"YES\"}" http://localhost:8080/pets

-> OK

curl -X POST -H "Content-type: application/json" --data "{\"id\":4,\"name\":\"Steve\",\"isMale\":\"true\"}" http://localhost:8080/pets

-> {"code":400,"message":"$.isMale: does not have a value in the enumeration [YES, MAYBE, NEVER]"}

@slinkydeveloper
Copy link
Member

This sounds strange, can you open an issue here please? https://github.com/networknt/json-schema-validator

@piebur
Copy link
Author

piebur commented Sep 25, 2019

Why, the problem is connected to the conversion from yaml to the json schema within io.swagger.v3.parser.OpenAPIV3Parser. I will instead create a bug in [https://github.com/swagger-api/swagger-parser/issues]swagger-api/swagger-parser#1205

@slinkydeveloper
Copy link
Member

Thank you, I wasn't aware of this :)

@slinkydeveloper
Copy link
Member

This is solved in vertx-web-openapi, because we don't use swagger-parser anymore. I'm going to close it, reopen if you need it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants