@@ -253,17 +253,28 @@ def generateBySpec(
253253 List (commonCodecsPath.toFile())
254254 }
255255 schemas <- Future
256- .traverse(specs.schemas.filter(_._2.properties.nonEmpty) ) { (schemaPath, schema) =>
256+ .traverse(specs.schemas) { (schemaPath, schema) =>
257257 Future {
258- val code = schemasCode(
259- schema = schema,
260- pkg = schemasPkg,
261- jsonCodec = config.jsonCodec,
262- dialect = config.dialect,
263- hasProps = p => specs.hasProps(p),
264- arrType = config.arrayType,
265- commonCodecsPkg = if commonCodecs.nonEmpty && schema.hasArrays then Some (commonCodecsPkg) else None
266- )
258+ val code =
259+ (if schema.properties.nonEmpty then
260+ schemasCode(
261+ schema = schema,
262+ pkg = schemasPkg,
263+ jsonCodec = config.jsonCodec,
264+ dialect = config.dialect,
265+ hasProps = p => specs.hasProps(p),
266+ arrType = config.arrayType,
267+ commonCodecsPkg =
268+ if commonCodecs.nonEmpty && schema.hasArrays then Some (commonCodecsPkg) else None
269+ )
270+ else
271+ // create a type alias for objects without properties
272+ val comment = toComment(schema.description)
273+ s """ |package $schemasPkg
274+ |
275+ | ${comment}type ${schema.id.scalaName} = Option[""] """ .stripMargin
276+ )
277+
267278 val path = schemasPath / s " ${schemaPath.scalaName}.scala "
268279 Files .writeString(path, code)
269280 path.toFile()
0 commit comments