OpenAPITools / OpenAPITools/openapi-generator

[REQ] Better error message for debugging

Open
#8,202 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

Here is what the Python client's error message looks like:

`2020-12-16 02:35:08,604 [ERROR] [example.py:350] Exception when calling API: Invalid inputs given to generate an instance of 'OrganizationOrganizationListAllOf'. The input data was invalid for the allOf schema 'OrganizationOrganizationListAllOf' in the composed schema 'OrganizationOrganizationList'. Error=Invalid inputs given to generate an instance of 'MoBaseMo'. The input data was invalid for the allOf schema 'MoBaseMo' in the composed schema 'OrganizationOrganization'. Error=Invalid inputs given to generate an instance of 'MoBaseComplexType'. The input data was invalid for the allOf schema 'MoBaseComplexType' in the composed schema 'MoMoRef'. Error=Invalid value for `object_type` (organization.Organization), must be one of ['adapter.AdapterConfig', 'adapter.DceInterfaceSettings', 'adapter.EthSettings', 'adapter.FcSettings', 'adapter.PortChannelSettings', 'appliance.ApiStatus', 'appliance.KeyValuePair', 'appliance.StatusCheck', 'asset.AddressInformation', '

It would be a LOT easier if the error message includes the JSON path of the property that has a problem.

Describe the solution you'd like

For example, suppose hypothetically we have { "a": { "b": { "c": 123}}} and suppose c must be less than 100, then it would help a lot if the error message starts with a simple "Invalid input data at 'a/b/c'. "

But what happens currently is the error message starts with Exception when calling API: Invalid inputs given to generate an instance of 'OrganizationOrganizationListAllOf'. The problem is that it's hard to know what OrganizationOrganizationListAllOf refers to because it's not an actual JSON property name or python property name.

Describe alternatives you've considered

Additional context

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

The request concerns error messages in the generated Python client, but it names no source file or test. Start by tracing where validation errors are assembled; done means errors identify the invalid JSON path, such as a/b/c, with coverage verifying the new wording.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.