swagger-api/swagger-codegen

[FINCH] no enum support

Open

#4,863 建立於 2017年2月27日

在 GitHub 查看
 (4 留言) (0 反應) (0 負責人)HTML (5,474 fork)batch import
Enhancement: FeatureFeature: EnumServer: Scalahelp wanted

倉庫指標

Star
 (12,701 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Description

The Finch code generator does not support enums. An inline enum generates a normal variable of the desired type; a referenced enum generates an empty case class.

Swagger-codegen version

2.2.2-SNAPSHOT

Swagger declaration file content or url
      resultCode:
        type: string
        enum: [
          "OK",
          "EXCEPTION",
          "BAD_REQUEST"
        ]
Suggest a Fix

As far as I know there is no single best implementation choice for enumerations in scala. Possible choices are:

  • scala enumeration class (no warning for non-exhaustive match, type erasure issues)
  • sealed case objects (no easy way of iterating through values, no default serialization / deserialization) The serialization issue might not be a problem if circe supports it; still, scala enumerations might be easier to implement.

貢獻者指南