openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[KOTLIN-SPRING] Description and Example don't show up on generated objects

Open alsonlu opened this issue 1 year ago • 3 comments

Description

I want to show a description and example of fields of type object but the generated code leaves the example field null and the description field as an empty string (""). The preview of my openapi schema file shows those fields.

openapi-generator version

I'm using 7.2.0. I'm not sure if it's a regression but I did test with 6.6.0 as well and didn't see those fields populated

OpenAPI declaration file content or url
---
openapi: 3.0.1
info:
  title: Payment Service API
  description: Payments Platform Service REST Endpoints
  version: 0.0.1
servers:
  - url: http://localhost:8080
    description: Local
paths:
  "/payments/{chargeId}/capture":
    post:
      tags:
        - payment-controller
      operationId: capture
      parameters:
        - name: chargeId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/CaptureCommand"
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/CaptureResponse"
components:
  schemas:
    CaptureCommand:
      required:
        - amount
        - country
        - payment_partner
        - reference_id
      type: object
      properties:
        country:
          type: string
          example: US
        payment_partner:
          type: string
          example: citizens
        amount:
          type: integer
          format: int32
          description: amount in cents to be captured
          example: 50
        reference_id:
          type: string
          description: the ID of what the payment is against
          example: orderID
        financing_info:
          $ref: "#/components/schemas/FinancingInfo"
    CaptureResponse:
      required:
        - amount_paid
        - payment_partner
        - country
        - status
        - transaction_fee
      type: object
      properties:
        amount_paid:
          type: integer
          format: int32
        payment_partner:
          type: string
          example: citizens
        country:
          type: string
          example: US
        status:
          $ref: "#/components/schemas/PaymentStatus"
        transaction_fee:
          type: integer
          format: int32
    PaymentStatus:
      required:
        - is_success
        - message
        - name
      type: object
      properties:
        is_success:
          type: boolean
        message:
          type: string
        name:
          type: string
    FinancingInfo:
      required:
        - annual_percentage_rate
        - financing_term
      type: object
      description: Required if Citizens is the Payment Partner
      properties:
        annual_percentage_rate:
          type: number
          example: 4.99
        financing_term:
          type: integer
          example: 12
Command line used for generation

java -jar openapi-generator-cli.jar generate -i <PATH TO ABOVE FILE> -g kotlin-spring -o ~/temp/test2

Steps to reproduce

Using this command java -jar openapi-generator-cli.jar generate -i <PATH TO ABOVE FILE> -g kotlin-spring -o ~/temp/test2 and then looking at the src/main/kotlin/org/openapitools/model/CaptureCommand.kt the financingInfo has example as null and description as ""

Related issues/PRs
Suggest a fix/enhancement

alsonlu avatar Feb 02 '24 22:02 alsonlu

Can anyone help here? Thanks!

alsonlu avatar Mar 06 '24 15:03 alsonlu

Im having the same issue. The example section is compleity missing from the generated Spring controller.

meszaroszoltan avatar May 09 '24 15:05 meszaroszoltan

Looks like this PR solves our problem: https://github.com/OpenAPITools/openapi-generator/pull/17613

meszaroszoltan avatar May 10 '24 16:05 meszaroszoltan