OpenAPITools / OpenAPITools/openapi-generator

Spring generator does not pick up examples from the specs

Open
#3,142 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: Spring
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Spring generator does not pick up examples given in the OAS specs. It returns null instead

openapi-generator version

4.0.0

OpenAPI declaration file content or url

https://gist.github.com/RitwikChatterjee/0790b7611fcb1d723e0ebae18903ddbf

Command line used for generation

openapi-generator generate -i user.oas3.yaml -o ./source -g spring

Steps to reproduce

Calling the API results in null string being returned. I noticed in the generated code that it ignored the example mentioned in the specification file

Related issues/PRs

None

Suggest a fix

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 OpenAPI declaration in the linked gist and run the reported openapi-generator command with the Spring generator. Compare the generated output with the examples declared in the specification; the work is done when those examples are reflected instead of producing null values.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.