OpenAPITools / OpenAPITools/openapi-generator
[BUG] [SPRING] not able to get example value in @ApiParam when it is defined in spec
Open
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
I am not able to get an example value in @ApiParam when I tried to generate spring code.
OpenAPI declaration file content
openapi: 3.0.1
info:
title: Swagger Petstore
version: 1.0.0
tags:
- name: pet
description: Everything about your Pets
paths:
'/pet/{petId}/{petId2}':
get:
tags:
- pet
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
schema:
type: integer
format: int64
example: 12
- name: petId2
in: path
description: petId2
required: true
schema:
type: string
example: ashim
responses:
'200':
description: successful operation
content: {}
Command line used for generation
docker run --rm \
-v $PWD:/local openapitools/openapi-generator-cli generate \
-i /local/petstore.yaml \
-g spring \
-o /local/out/spring
Steps to reproduce
After the code generation, there is no example in PetApi for petId and petId2.
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 supplied petstore.yaml and the Spring generator output, especially PetApi, and compare the schema examples for petId and petId2 with the generated parameter annotations. Reproduce the issue with the documented Docker command; done means the generated PetApi exposes the example values for both parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100