Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract class not getting created as abstract #190

Open
nembogda opened this issue Apr 10, 2023 · 2 comments
Open

Abstract class not getting created as abstract #190

nembogda opened this issue Apr 10, 2023 · 2 comments

Comments

@nembogda
Copy link

nembogda commented Apr 10, 2023

openapi: 3.0.0
info: "Discount Amount"
paths:
components:
  schemas:
    DiscountAmount:
      type: object
      x-abstract: true
      properties:
        discountType:
          type: string

    ProductAnnualDiscountSettings:
      allOf:
        - $ref: '#/components/schemas/DiscountAmount'
        - type: object
          properties:
            amount:
              type: number
            type:
              $ref: "#/components/schemas/DiscountType"
            enabled:
              type: boolean
              default: false

    ECPAnnualDiscountSettings:
      allOf:
        - $ref: '#/components/schemas/DiscountAmount'
        - type: object
          properties:
            amount:
              type: number
            type:
              $ref: "#/components/schemas/DiscountType"
            enabled:
              type: boolean
              default: false

    DiscountType:
      type: string
      enum:
        - PERCENT
        - FLAT

Generates

data class DiscountAmount(
  @param:JsonProperty("discountType")
  @get:JsonProperty("discountType")
  val discountType: String? = null
)

and

data class ProductAnnualDiscountSettings(
  @param:JsonProperty("discountType")
  @get:JsonProperty("discountType")
  val discountType: String? = null,
  @param:JsonProperty("amount")
  @get:JsonProperty("amount")
  val amount: BigDecimal? = null,
  @param:JsonProperty("type")
  @get:JsonProperty("type")
  val type: DiscountType? = null,
  @param:JsonProperty("enabled")
  @get:JsonProperty("enabled")
  @get:NotNull
  val enabled: Boolean = false
)

Please note that DiscountAmount is not abstract and that ProductAnnualDiscountSettings doesn't inherit from DiscountAmount

Am I doing something wrong or abstract types are not supported?

@atollk
Copy link
Contributor

atollk commented Apr 11, 2023

@cjbooms
Copy link
Owner

cjbooms commented Apr 22, 2023

If you want it to be polymorphic, you'll need to add a discriminator declaration in DiscountAmount

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants