https://kotlinlang.org logo
#http4k
Title
# http4k
s

Stefan

07/08/2021, 3:32 PM
Is it possible to add an openAPI descriptions to my domain objects? (e.g here https://github.com/http4k/http4k-by-example/blob/master/src/main/kotlin/verysecuresystems/domain.kt)
ok, I found
JacksonFieldMetadataRetrievalStrategyTest
. But using
@JsonPropertyDescription
doesn't seem to work for me out of the box 😞
when I annotate a domain field with @JsonProperty("SUPERNEWNAME") it crashes 🙂
Copy code
org.http4k.contract.openapi.v3.NoFieldFound: Could not find SUPERNEWNAME in Component(originDateTime=1970-01-01T00:00:00Z, invalidationDateTime=1970-01-01T02:46:40Z, org.http4k.core.Http4kKt$NoOp$1$1.invoke(Http4k.kt
	at org.http4k.contract.openapi.v3.FieldRetrieval$Companion$compose$1.invoke(FieldRetrieval.kt:17)
	at org.http4k.contract.openapi.v3.FieldRetrieval$Companion$compose$1.invoke(FieldRetrieval.kt:10)
	at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toObjectSchema(AutoJsonToJsonSchema.kt:94)
	at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toObjectOrMapSchema(AutoJsonToJsonSchema.kt:78)
	at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toSchema(AutoJsonToJsonSchema.kt:35)
	at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toArraySchema(AutoJsonToJsonSchema.kt:53)
	at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toSchema(AutoJsonToJsonSchema.kt:34)
	at org.http4k.contract.openapi.v3.AutoJsonToJsonSchema.toSchema(AutoJsonToJsonSchema.kt:25)
	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:205)
	at org.http4k.contract.openapi.v3.OpenApi3.collectSchemas(OpenApi3.kt:141)
	at org.http4k.contract.openapi.v3.OpenApi3.responses(OpenApi3.kt:134)
	at org.http4k.contract.openapi.v3.OpenApi3.apiPath(OpenApi3.kt:108)
	at org.http4k.contract.openapi.v3.OpenApi3.asPath(OpenApi3.kt:94)
	at org.http4k.contract.openapi.v3.OpenApi3.description(OpenApi3.kt:70)
	at org.http4k.contract.ContractRoutingHttpHandler$$special$$inlined$let$lambda$1.invoke(ContractRoutingHttpHandler.kt:66)
	at org.http4k.contract.ContractRoutingHttpHandler$$special$$inlined$let$lambda$1.invoke(ContractRoutingHttpHandler.kt:26)
	at org.http4k.routing.RouterMatch$MatchingHandler.invoke(Router.kt:47)
	at org.http4k.routing.RouterMatch$MatchingHandler.invoke(Router.kt:46)
	at org.http4k.core.Http4kKt$NoOp$1$1.invoke(Http4k.kt:11)
	at org.http4k.core.Http4kKt$NoOp$1$1.invoke(Http4k.kt)
	at org.http4k.core.Http4kKt$NoOp$1$1.invoke(Http4k.kt:11)
	at org.http4k.core.Http4kKt$NoOp$1$1.invoke(Http4k.kt)
	at org.http4k.core.Http4kKt$NoOp$1$1.invoke(Http4k.kt:11)
	at org.http4k.core.Http4kKt$NoOp$1$1.invoke(Http4k.kt)
	at org.http4k.filter.ServerFilters$Cors$invoke$1$1.invoke(ServerFilters.kt:55)
	at org.http4k.filter.ServerFilters$Cors$invoke$1$1.invoke(ServerFilters.kt:50)
	at org.http4k.contract.ContractRoutingHttpHandler$identify$1$1$1.invoke(ContractRoutingHttpHandler.kt:105)
	at org.http4k.contract.ContractRoutingHttpHandler$identify$1$1$1.invoke(ContractRoutingHttpHandler.kt:26)
	at org.http4k.core.Http4kKt$then$2.invoke(Http4k.kt:15)
	at org.http4k.core.Http4kKt$then$2.invoke(Http4k.kt)
	at org.http4k.routing.RouterMatch$MatchingHandler.invoke(Router.kt:47)
	at org.http4k.routing.RouterMatch$MatchingHandler.invoke(Router.kt:46)
	at org.http4k.routing.RouterBasedHttpHandler.invoke(RouterBasedHttpHandler.kt:23)
	at org.http4k.routing.RouterBasedHttpHandler.invoke(RouterBasedHttpHandler.kt:13)
	at org.http4k.filter.ServerFilters$CatchAll$invoke$1$1.invoke(ServerFilters.kt:256)
	at org.http4k.filter.ServerFilters$CatchAll$invoke$1$1.invoke(ServerFilters.kt:252)
	at org.http4k.core.Http4kKt$then$2.invoke(Http4k.kt:15)
	at org.http4k.core.Http4kKt$then$2.invoke(Http4k.kt)
	at org.http4k.server.Http4kUndertowHttpHandler.handleRequest(Http4kUndertowHttpHandler.kt:37)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:841)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449)
	at java.base/java.lang.Thread.run(Thread.java:832)
d

dave

07/09/2021, 8:52 AM
So you might need to create a new FieldRetreival class to cope with this (and add it to the composite chain) - or maybe there is a fix to be made to one that is already there. We do have one for the Jackson field naming annotations already.
The system works by reflecting on the example object defined in the contract spec. If an object is exposed to that then it will be interrogated by the ApiRenderer
6 Views