OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.86k stars 6.59k forks source link

[BUG] [JAVA] [spring] Examples are not being generated correctly - MIME type example not yet supported #16595

Open Amaryliska opened 1 year ago

Amaryliska commented 1 year ago

Bug Report Checklist

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:

image

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: image

Darkrai1992 commented 1 year ago

i have the same or similar problem. Would be nice if someone could solve it.

mzefi commented 1 year ago

I am facing the same problem

gianluca-moro commented 3 months ago

I am currently facing a similar problem. Has anyone found a solution yet?