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

allOf incorrectly uses discriminate type #291

Open
er1c opened this issue Jun 9, 2023 · 0 comments
Open

allOf incorrectly uses discriminate type #291

er1c opened this issue Jun 9, 2023 · 0 comments

Comments

@er1c
Copy link
Contributor

er1c commented Jun 9, 2023

    yield:
      type: object
      properties:
        product:
          type: string
      required:
        - product
    YieldWithWeight:
      allOf:
        - $ref: '#/components/schemas/yield'
        - type: object
          properties:
            weight:
              type: integer
              description: |
                Weight amount
          required:
            - weight

Produces:

package org.myapi
sealed trait `yield` {
  val product: String
}
object `yield` {
  implicit val customConfig: io.circe.generic.extras.Configuration = io.circe.generic.extras.Configuration.default.withDefaults.withDiscriminator("type")
  case class YieldWithWeight (
    weight: Int, product: String
  ) extends `yield`
}

I would expect to be able and create both a yield("foo") and a YieldWithWeight(10, "foo") since both are valid objects. Need to think through how this code should actually be generated though (forgive the yield) was working on fixing the reserved words escaping.

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

1 participant