swagger-api / swagger-api/swagger-codegen

Bug: Examples are not generated with OpenAPI 3.0 in nodejs server generation

Open
#9,200 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

When OpenAPI 3.0 is used, the nodejs code generation (and as far as I can tell, other servers as well) does not generate example code. For example, you can see the difference in the examples here:

https://github.com/swagger-api/swagger-codegen/blob/v3.0.5/samples/server/petstore/nodejs/service/PetService.js
https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore/nodejs/service/PetService.js
In the second master version of the file, there's a examples[application/json] = that's missing from the 3.0.5 version. I've noticed this on all of my local code as well.

Swagger-codegen version

3.0.5 And I don't think it's a regression.

Swagger declaration file content or url

None attached

Command line used for generation
Steps to reproduce

Generating a nodejs server with the online tool, and the docker 3.0.5 cli tool (Only 2 I have tried).

Related issues/PRs

I haven't seen anything

Suggest a fix/enhancement

I've tried digging through the code but I'm at a loss. Even a pointing in the right direction would be helpful.

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

Compare samples/server/petstore/nodejs/service/PetService.js in the v3.0.5 and master versions, focusing on the missing examples[application/json] output. Reproduce generation with the online tool or Docker 3.0.5 CLI, then trace the server-generation templates or entry points responsible for examples and verify that generated Node.js services include them.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs
Domain
backend
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.