0

I have a simple data class being returned by one of my routes.

Data class:

data class Fruit(val id: Long, val name: String)

Route:

@Path("/fruit")
class FruitRoutes {

    @GET
    fun getAllFruit(): Multi<Fruit> {
        return Fruit.findAll()
    }
}

The schema generated by the quarkus-smallrye-openapi extension however does not have the id as required:

components:
  schemas:
    Fruit:
      required:
      - name
      type: object
      properties:
        id:
          format: int64
          type: integer
        name:
          type: string

This extension is a wrapper for Eclipse Microprofile Open Api.

How can I mark the id as required?

I've tried adding the following annotations to the id field:

  • @org.jetbrains.annotations.NotNull
  • @jakarta.validation.constraints.NotNull
  • @io.smallrye.common.constraint.NotNull
  • @org.eclipse.microprofile.openapi.annotations.parameters.Parameter(required = true)
  • @org.eclipse.microprofile.openapi.annotations.media.Schema(required = true)
  • @com.fasterxml.jackson.annotation.JsonProperty(required = true)

but with no success

1 Answers1

0

This was fixed by changing the data class:

@Schema(requiredProperties = ["id", "name", "createdAt"])
data class Fruit(val id: Long, val name: String)

probably a bug with the framework