swagger-api / swagger-api/swagger-codegen

get specific result node on json

Open
#3,206 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: JavaScript/Node.js General: Question
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Hello,
i want to know if there is a option to set a specif node to get the result of the json ?

All endpoint of our api return same schema response ApiResult[T],
for exemple when i get user with findById, on the node result i get the User ApiResult[User]

{
  "error": {
  },
  "result": { 
      "email": "",
       ...
  },
  "debug": {
  },
  "meta": {
  }
}

the user is on node result

the problem is, on swagger spec we define as return the model User, on error we describes Error ect ...

in the spec swagger we can't template this and its not a good idea of write model ApiResultUser, ApiResultAddress, ApiResultEnterprise, ... the number of class is huge

i hope there is a workaround, a way to change the method ApiInvoked.deserialize ?

otherwise the code generate is not usable, that fail on the validation of json

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 by examining the generated client's ApiInvoked.deserialize behavior and the Swagger response schema described in the issue. Reproduce the JSON validation failure for an ApiResult[T] response where the model is nested under result. Done should be defined as a supported way for generated code to deserialize that response without requiring separate ApiResult model classes.

Written by the indexing model from the issue text.

Assessment

Tech stack
json, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.