Skip to content

fixed referencing enums for optional fields#1327

Merged
adamw merged 2 commits intosoftwaremill:masterfrom
ae0n:optional-enum-docs-fix
Jun 18, 2021
Merged

fixed referencing enums for optional fields#1327
adamw merged 2 commits intosoftwaremill:masterfrom
ae0n:optional-enum-docs-fix

Conversation

@ae0n
Copy link
Copy Markdown
Contributor

@ae0n ae0n commented Jun 17, 2021

I've found that during documentation generation if a class contains an optional enum field then referenceEnums isn't affecting the result.
For example, if I have the enum:

sealed abstract class MyEnum extends EnumEntry

  object MyEnum extends Enum[MyEnum] {
    case object Foo1 extends MyEnum
    case object Foo2 extends MyEnum
    override def values: immutable.IndexedSeq[MyEnum] = findValues
  }

and use it in the class:

  case class MyResult(enumField: MyEnum, enumFieldOpt: Option[MyEnum])

Then generated documentation would use a reference to specify the type of enumField and will inline all options for enumFieldOpt.

I've found that the problem was inside TSchemaToASchema.scala because was not handled in a case when an option field might contain an enum.

@ae0n ae0n force-pushed the optional-enum-docs-fix branch from 01c3263 to 2969eab Compare June 17, 2021 19:33
aloise
aloise approved these changes Jun 17, 2021
@adamw adamw merged commit f34c553 into softwaremill:master Jun 18, 2021
@adamw
Copy link
Copy Markdown
Member

adamw commented Jun 18, 2021

Thank you!

@ae0n
Copy link
Copy Markdown
Contributor Author

ae0n commented Jun 18, 2021

Thank you for such quick response.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants