Skip to content

Integer fields are not marked as required by quarkus-smallrye-openapi when using Kotlin #33778

Open

Description

Describe the bug

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()
    }
}

Expected behavior

The schema generated by the quarkus-smallrye-openapi extension has the id field as required:

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

Actual behavior

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

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

How to Reproduce?

No response

Output of uname -a or ver

Darwin lbattist-macOS 21.6.0 Darwin Kernel Version 21.6.0: Thu Mar 9 20:12:21 PST 2023; root:xnu-8020.240.18.700.8~1/RELEASE_ARM64_T6000 arm64

Output of java -version

openjdk version "17.0.5" 2022-10-18 OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08) OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.0.4.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 8.1.1

Additional information

This can be fixed by adding @Schema(requiredProperties = ["id", "name", "createdAt"]) to the class, but it shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions