swagger-api / swagger-api/swagger-codegen

Bad error message on accidentally nested schema.

Open
#2,313 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: General General: Suggestion help wanted
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the nested schema at line 647 of the linked gist and compare the CLI output with the online validator's debug response. Trace the warning from io.swagger.util.PropertyDeserializer and identify the validation path that produces it. Done means the malformed schema receives a more useful diagnostic than the current generic warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.