swagger-api/swagger-codegen

Bad error message on accidentally nested schema.

Open

#2,313 opened on Mar 4, 2016

View on GitHub
 (2 comments) (0 reactions) (0 assignees)HTML (12,701 stars) (5,474 forks)batch import
Enhancement: GeneralGeneral: Suggestionhelp wanted

Description

When I build a spec (here: https://gist.github.com/nicksloan/0ec7e74af30ac9540ccf) with a schema nested within a schema (see line #647) I am shown a less than helpful error message:

[main] WARN io.swagger.util.PropertyDeserializer - no property from null, null, {ENUM=null, TITLE=null, DESCRIPTION=Unexpected error, DEFAULT=null, PATTERN=null, DESCRIMINATOR=null, MIN_ITEMS=null, MAX_ITEMS=null, MIN_PROPERTIES=null, MAX_PROPERTIES=null, MIN_LENGTH=null, MAX_LENGTH=null, MINIMUM=null, MAXIMUM=null, EXCLUSIVE_MINIMUM=null, EXCLUSIVE_MAXIMUM=null, UNIQUE_ITEMS=null, EXAMPLE=null, TYPE=null, FORMAT=null, READ_ONLY=null, VENDOR_EXTENSIONS={}}

Using the online validator in debug mode is much more helpful in identifying the actual issue:

{"schemaValidationMessages":[{"level":"error","domain":"validation","keyword":"oneOf","message":"instance failed to match exactly one schema (matched 0 out of 2)","schema":{"loadingURI":"http://swagger.io/v2/schema.json#","pointer":"/definitions/responseValue"},"instance":{"pointer":"/paths/~1infomous-graph/get/responses/default"}}]}

The codegen version is 2.1.5 from Homebrew.

Contributor guide