Closed skennedy closed 4 years ago
The schema defined for the io.circe.Json data type (https://github.com/softwaremill/tapir/blob/master/json/circe/src/main/scala/sttp/tapir/json/circe/TapirJsonCirce.scala#L25-L31), currently generates the following OpenAPI schema:
io.circe.Json
components: schemas: Json: type: object
This doesn't seem correct as io.circe.Json encodes any JSON value, including primitives, arrays, null, as well as objects.
I couldn't see a proper way of encoding the schema of "anything" in tapir. However, a hacky workaround I found was that an empty co-product...
implicit val schemaForCirceJson: Schema[Json] = Schema( SCoproduct( SObjectInfo("io.circe.Json"), List.empty, None ) )
...currently results in the empty schema...
components: schemas: Json: {}
...which seems to be the Json schema / OpenAPI to encode this.
Happy to submit a PR of the above if it's deemed acceptable :wink:
Please do! It makes sense: the Json type is a coproduct (as it has strings, arrays, objects, ...), with unknown implementations
Json
Thanks!
The schema defined for the
io.circe.Json
data type (https://github.com/softwaremill/tapir/blob/master/json/circe/src/main/scala/sttp/tapir/json/circe/TapirJsonCirce.scala#L25-L31), currently generates the following OpenAPI schema:This doesn't seem correct as
io.circe.Json
encodes any JSON value, including primitives, arrays, null, as well as objects.I couldn't see a proper way of encoding the schema of "anything" in tapir. However, a hacky workaround I found was that an empty co-product...
...currently results in the empty schema...
...which seems to be the Json schema / OpenAPI to encode this.