OpenAPITools / OpenAPITools/openapi-generator
[BUG][JavaSpring][SpringBoot] Missing example-Argument within @Parameter
Nobody has claimed this yet.
- 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?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I want to use example-Value in the .yaml-File.
I expect it will be generated at the interface-Method - but it is missing.
openapi-generator version
7.17.0
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Example
version: 0.0.1
paths:
/api/Example:
get:
responses:
"200":
description: OK
parameters:
- name: exampleStr
schema:
type: string
example: _param_example_
in: query
Generation Details
I use the org.openapitools.generator.gradle.plugin.tasks.GenerateTask within a gradle-Script with following settings:
generatorName = "spring"
library = "spring-boot"
configOptions = [
useJakarteEe: "true",
interfaceOnly: "true",
useSpringBoot3: "true"
]
Steps to reproduce
Just run the Task
Related issues/PRs
Suggest a fix
I think JavaSpring/paramDoc.mustache should use the example-Field.
I tried this out but has some trouble with datatypes which are auto-detected.
Using {{{example}}} causes an Compile-Error if it is not a String.
It works fine, if it is a String (because " is included)
If there is a Enum, it contains SomeType.fromValue("examplevalue")
I couldn't solve the enum-Problem.
Generated Code
default ResponseEntity<Void> apiExampleGet(
@Parameter(name = "exampleStr", description = "", in = ParameterIn.QUERY) @Valid @RequestParam(value = "exampleStr", required = false) @Nullable String exampleStr
) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
Expected Code
default ResponseEntity<Void> apiExampleGet(
@Parameter(name = "exampleStr", example = "_param_example_", description = "", in = ParameterIn.QUERY) @Valid @RequestParam(value = "exampleStr", required = false) @Nullable String exampleStr
) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the JavaSpring/paramDoc.mustache template and reproduce the issue using the provided OpenAPI YAML and Gradle GenerateTask settings. Check how string, non-string, and enum parameter examples are represented, then verify that generated @Parameter annotations include the example without causing Java compilation errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100