Bug Report Checklist
Description
Having a contract with not nested enum like StandAloneEnum in example below, and a type which is referencing the enum:
StandAloneEnum:
type: string
enum:
- on-my-own
TypeWhichUsesEnum:
type: object
properties:
standAloneEnum:
$ref: '#/components/schemas/StandAloneEnum'
Leads to the compile error where compiler cannot find a generated enum.
TypeWhichUsesEnum.scala:16: not found: type StandAloneEnum
case class TypeWhichUsesEnum(
standAloneEnum: Option[StandAloneEnum] = None // Because this enum is not imported properly
)
openapi-generator version
Occurs in 5.0.1
Generation Details
openapi-generator-cli generate \
-i name_of_file.yaml \
-g scala-sttp \
--additional-properties sttpClientVersion=2.2.0,mainPackage=test.api \
-o test-api
Related issues/PRs
It has relation to a recent contribution in #7432
Suggest a fix.
There are 2 ways of fixing the problem:
- Do a proper enum import like this
import openapi.codegen.model.StandAloneEnum._
case class TypeWhichUsesEnum(
standAloneEnum: Option[StandAloneEnum] = None
)
It will import type StandAloneEnum from the generated code file and it will make compiler happy.
object StandAloneEnum extends Enumeration {
type StandAloneEnum = StandAloneEnum.Value
val OnMyOwn = Value("on-my-own")
}
- Or use {some_enum_name}.Value like this
case class TypeWhichUsesEnum(
standAloneEnum: Option[StandAloneEnum.Value] = None
)
It also will make compiler happy.
P.S. it might be conflicting with enum nesting functionality: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/scala-sttp/model.mustache#L24
Bug Report Checklist
Description
Having a contract with not nested enum like
StandAloneEnumin example below, and a type which is referencing the enum:Leads to the compile error where compiler cannot find a generated enum.
TypeWhichUsesEnum.scala:16: not found: type StandAloneEnumopenapi-generator version
Occurs in 5.0.1
Generation Details
Related issues/PRs
It has relation to a recent contribution in #7432
Suggest a fix.
There are 2 ways of fixing the problem:
It will import
type StandAloneEnumfrom the generated code file and it will make compiler happy.It also will make compiler happy.
P.S. it might be conflicting with enum nesting functionality: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/scala-sttp/model.mustache#L24