swagger-api / swagger-api/swagger-codegen

Codegen doesn't use "example" for response body

Open
#2,387 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Not sure if this is by design or bug.
I have example for every object under definitions section. When I use codegen to generate a nodejs server, I am hoping at least the response body for GET should use the example data, but it doesn't.

Example data shows up under "Response Class", but when I click "Try it out!", in stead of example data, I get generic json object generated by Codegen using the schema. Like {"userName": "aeiou"}

Do I miss anything? Thanks

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

Reproduce this with an API definition containing examples under definitions, then read the Node.js server codegen path and the response-body handling used by “Try it out!”. Compare the generated response with the example shown in “Response Class”; done means the intended example behavior is established and the generated response or documented behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, openapi
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.