Skip to content

Incorrect encoding of nullable non-required field with default #2025

@OlegYch

Description

@OlegYch

using spec like this

{
  "openapi": "3.0.2",
  "components": {
    "schemas": {
      "test": {
        "type": "object",
        "properties": {
          "method": {
            "type": "string",
            "default": "",
            "example": "TEXT",
            "nullable": true
          }
        },
        "required": [
        ]
      }
    }
  }
}

and config like

addSbtPlugin("dev.guardrail" % "sbt-guardrail" % "1.0.0-M1")

libraryDependencies ++= Seq(
  "dev.guardrail" %% "guardrail-scala-pekko-http" % "1.0.0-M1",
)
Compile / guardrailTasks := List(
  ScalaClient(
    (Compile / resourceDirectory).value / "openapi" / "asd.json",
    pkg = "test",
    modules = List("pekko-http", "circe"),
  )
)

i get a compilation error

[error] 11 |case class Test(method: _root_.test.support.Presence[Option[String]] = _root_.test.support.Presence.Present(""))
[error]    |                                 Found:    ("" : String)
[error]    |                                 Required: Option[String]
[```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions