# Ktor @Resource openapi generation enum as type object

**URL:** <https://discuss.kotlinlang.org/t/ktor-resource-openapi-generation-enum-as-type-object/28654>\
**Category:** Uncategorized\
**Created:** [May 22, 2024, 9:21am UTC](https://discuss.kotlinlang.org/t/ktor-resource-openapi-generation-enum-as-type-object/28654 "2024-05-22T09:21:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shawin](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@shawin](https://discuss.kotlinlang.org/u/shawin)\
**Post date:** [May 22, 2024, 9:21am UTC](https://discuss.kotlinlang.org/t/ktor-resource-openapi-generation-enum-as-type-object/28654/1 "2024-05-22T09:21:15Z")

</div>

When using the ktor plugin for generating openapi documentation it fails to resolve enum and instead resolves it as "object. It works for the response object.

I don’t understand why it correctly annotates the Predicate enum for the response but not for the type safe routing annotation with @Resource?

Thanks for any help!

documentation.yaml

```auto
  /api/tags/{id}/relations:
    get:
      description: ""
      parameters:
      - name: "dimension"
        in: "query"
        required: false
        schema:
          type: "string"
      - name: "id"
        in: "path"
        required: true
        schema:
          type: "string"
      - name: "predicate"
        in: "query"
        required: true
        schema:
          type: "object"
      responses:
        "200":
          description: "OK"
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RelationResponse"

    RelationResponse:
      type: "object"
      properties:
        subjectId:
          type: "string"
          format: "uuid"
        predicate:
          type: "string"
          enum:
          - "SUBGENRE_OF"
          - "INFLUENCED_BY"
          - "FUSION_OF"
          - "PARENT_OF"

```

Classes:

```auto
@Resource("/tags")
data class Tags(val dimension: String = "") {
    @Resource("{id}")
    data class Id(val parent: Tags = Tags(), val id: String) {
        @Resource("/relations")
        data class Relations(val parent: Id, val predicate: Relation.Predicate)
    }
}

data class RelationResponse(
    val subjectId: UUID,
    val predicate: Relation.Predicate,
    val objectId: UUID,
)

data class Relation(
    val subjectId: UUID,
    val predicate: Predicate,
    val objectId: UUID,
) {
    constructor(rs: ResultSet) :
        this(
            subjectId = rs.getString("subject_id").toUUID(),
            predicate = safeEnumValueOf<Predicate>(rs.getString("predicate"))!!,
            objectId = rs.getString("object_id").toUUID(),
        )

    enum class Predicate {
        SUBGENRE_OF,
        INFLUENCED_BY,
        FUSION_OF,
        PARENT_OF,
    }
}

```

Controller:

```auto
            get<Tags.Id.Relations> { tag ->
                val id = tag.parent.id.toUUID()
                val predicate = tag.predicate
                call.respond(service.getTagRelations(id, predicate))
            }

```
