Mikael Ståldal
05/23/2023, 2:51 PMhttp4k-contract
generates description
fields with null
value if you leave out description. I think this is not according to the spec, the description
field should be left out if there is no value for it.Andrew O'Hara
05/23/2023, 6:33 PMOpenApiJackson
, which excludes null
values from generated json. How are you defining your ContractRenderer
? The minimal version should look like this:
contract {
renderer = OpenApi3(
ApiInfo("My Service", "v1.0")
)
routes += TODO()
}
Mikael Ståldal
05/24/2023, 7:03 AMcontract {
renderer = OpenApi3(
ApiInfo("Nice service", "1.0"),
org.http4k.format.Gson
)
routes += TODO()
}
Mikael Ståldal
05/24/2023, 7:15 AMorg.http4k.format.Jackson
, but then I get:
java.lang.IllegalArgumentException: Don't know how to translate "pYG4MIG1pWswaaEiBCADmKHnsPh3Ca/RTNGCHqqvtBkxqAl/+i2D5f4Q2n5N1aUaMBilFjAUog4MDG15X29wZXJhdGlvbqUCMAClJzAloSMEIQMr8Pz4Oih/texx5NrqXeiSgEpbu+1hMNvN24cQFcNOoKVGMEShQgRAS0JXeb+L1e1QODcze74QK3AT95HzvPuBJybqk+B2oyZ2Vux3OqEGF+Gr2yXperHPKZLNs+BZ1mjJC9pruR/oNg=="
at org.http4k.format.ConfigurableJackson.typeOf(ConfigurableJackson.kt:52)
at org.http4k.format.ConfigurableJackson.typeOf(ConfigurableJackson.kt:37)
at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.makePropertySchemaFor(AutoJsonToJsonSchema.kt:184)
at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toObjectSchema(AutoJsonToJsonSchema.kt:123)
at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toObjectOrMapSchema(AutoJsonToJsonSchema.kt:110)
at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toSchema(AutoJsonToJsonSchema.kt:45)
at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toSchema(AutoJsonToJsonSchema.kt:29)
at org.http4k.contract.openapi.ApiRenderer$Companion$Auto$fallbackSchema$1.toSchema(ApiRenderer.kt:30)
at org.http4k.contract.openapi.ApiRenderer$Companion$Auto$1.toSchema(ApiRenderer.kt)
at org.http4k.contract.openapi.v3.OpenApi3.toSchemaContent(OpenApi3.kt:288)
at org.http4k.contract.openapi.v3.OpenApi3.requestBody(OpenApi3.kt:261)
at org.http4k.contract.openapi.v3.OpenApi3.apiPath(OpenApi3.kt:141)
at org.http4k.contract.openapi.v3.OpenApi3.apiPath(OpenApi3.kt:126)
at org.http4k.contract.openapi.v3.OpenApi3.asPath(OpenApi3.kt:123)
at org.http4k.contract.openapi.v3.OpenApi3.description(OpenApi3.kt:88)
at org.http4k.contract.ContractRoutingHttpHandler$descriptionRoute$2$1.invoke(ContractRoutingHttpHandler.kt:79)
at org.http4k.contract.ContractRoutingHttpHandler$descriptionRoute$2$1.invoke(ContractRoutingHttpHandler.kt:78)
at org.http4k.routing.RouterMatch$MatchingHandler.invoke(Router.kt:54)
at org.http4k.routing.RouterMatch$MatchingHandler.invoke(Router.kt:53)
Mikael Ståldal
05/24/2023, 7:28 AM"info": {
"title": "Test API",
"version": "1.0",
"description": null
},
Andrew O'Hara
05/24/2023, 1:49 PMGson
is known to not be supported by the auto renderer; in fact only Jackson
and OpenApiJackson
are supported.
Now that you've fixed the Jackson incompatibility, you can switch from Jackson
to OpenApiJackson
, and the nulls won't be rendered. In fact, the only difference between the two is that one doesn't render nulls.