OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] [spring] Examples are not being generated correctly - MIME type example not yet supported
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 (example)?
- 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 have a schema called Passenger as a part of my RequestBody, which has following example:
Passenger:
type: object
additionalProperties: false
description: |
Minimal specification of a passenger.
required:
- externalRef
- passengerType
properties:
externalRef:
description: |
A stable reference to a passenger from the caller system.
When received in the request, it must be returned in the response.
type: string
nullable: false
example: passenger1
passengerType:
$ref: '#/components/schemas/PassengerType'
dateOfBirth:
type: string
format: date
nullable: true
age:
description: |
Age of the passenger at the date of travel. Less stable than the date of birth.
type: integer
format: int32
minimum: 0
exclusiveMinimum: true
nullable: true
contactDetails:
$ref: '#/components/schemas/ContactDetails'
example:
externalRef: passenger1
passengerType: PERSON
dateOfBirth: 2001-01-01
contactDetails:
firstName: Name
lastName: Lastname
eMail: name@test.com
preferredLanguage: en
After generating endpoints, examples are nowhere to be found, and after calling /v3/api-docs I'm geeting this:
So example values for ContactDeatils are being taken from Warning part
Warning:
type: object
additionalProperties: false
description: |
This element can be used to pass non-blocking information or events.
It is inspired on the JSON Problem structure.
required:
- type
properties:
type:
description: |
An absolute URI that identifies the warning type. When dereferenced,
it SHOULD provide human-readable documentation for the problem type
(e.g., using HTML).
type: string
format: uri
nullable: false
default: 'about:blank'
example: https://example.com/warns/price-updated
detail:
description: |
A human readable explanation specific to this occurrence of the
warning.
type: string
nullable: true
example: The price of the given offer part has been updated during the booking operation
And in response from /v3/api-docs this looks like default example for all JsonNullableString:
"JsonNullableString": {
"type": "object",
"properties": {
"present": {
"type": "boolean"
}
},
"description": "A human readable explanation specific to this occurrence of the warning. ",
"example": "The price of the given offer part has been updated during the booking operation"
}
openapi-generator version
6.2.1
expected output
when checking my source yaml file, examples look like this:
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 by reproducing the issue with the supplied Passenger, ContactDetails, and Warning schemas, then inspect the Java Spring example-generation path and generated /v3/api-docs output. Done means the Passenger and ContactDetails examples are preserved and the output no longer substitutes Warning or JsonNullableString example values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100