openapi-generator: [BUG][SPRING] x-field-extra-annotation missing in 6.5.0

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
openapi-generator version

regression in 6.5.0

OpenAPI declaration file content or url

This OA spec snippet

    CompanyDto:
      type: object
      description: ....
      properties:
        priceCategory:
          description: The price category
          nullable: true
          x-field-extra-annotation: '@IgnoreForRoles("MEDIA_ADMIN")'
          allOf:
            - $ref: '#/components/schemas/SamplingPriceCategoryEnum'
Expected Output

… produced the following output in v6.4.0 (using openApiNullable = true):

  @JsonProperty("priceCategory")
  @IgnoreForRoles("MEDIA_ADMIN")
  private JsonNullable<SamplingPriceCategoryEnum> priceCategory = JsonNullable.undefined();
Actual Output

… but produces the following in 6.5.0:

  private JsonNullable<SamplingPriceCategoryEnum> priceCategory = JsonNullable.undefined();

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

i found an ugly way to at least mark the first field with @Id through jkt628/x-field-extra-annotation@a040d18. going through pojo.mushtache it looks like vendorExtensions.x-field-extra-annotation is not set for the field which will bomb a bunch of generators.

Unfortunately you can’t use both $ref & x-field-extra-annotation at same time. This would be the correct approach

    EventRouterMessage:
      type: object
      x-class-extra-annotation: |-
        @javax.persistence.Entity
        @javax.persistence.Table(name="event_router_requests")
      properties:
        guid:
          x-field-extra-annotation: |-
            @javax.persistence.Id
            @javax.persistence.Column(name = "id")
          type: string                  <--- this is the change. use direct configuration here instead of $ref
          pattern: '^[0-9A-Fa-f]{8}-(?:[0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'
        accounting:
          $ref: '#/components/schemas/Accounting'
        event:
          $ref: '#/components/schemas/Event'