dave
09/27/2019, 11:24 AMRajanS
09/27/2019, 11:26 AMswagger.json
docdave
09/27/2019, 11:26 AMRajanS
09/27/2019, 11:34 AM{
"swagger": "2.0",
"info": {
"title": "API",
"version": "v2.0",
"description": ""
},
"basePath": "/",
"tags": [],
"paths": {
"/api/v2/api": {
"get": {
"tags": [
""
],
"summary": "some desc",
"operationId": "get",
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"parameters": [
{
"in": "header",
"name": "Authorization",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "get a set of data",
"schema": {
"$ref": "#/definitions/object-31373813"
}
},
"204": {
"description": "not recognised",
"schema": {}
}
},
"security": [],
"description": "some desc"
}
}
},
"securityDefinitions": {},
"definitions": {
"object-164926786": {
"type": "object",
"properties": {
"consentType": {
"type": "string",
"example": "EMAIL"
},
"consentAllowed": {
"type": "boolean",
"example": true
}
}
},
"object2079760391": {
"type": "object",
"properties": {
"entity": {
"type": "string",
"example": "sourceA"
},
"consents": {
"type": "array",
"items": {
"$ref": "#/definitions/object-164926786"
}
}
}
},
"object-31373813": {
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "id"
},
"permissions": {
"type": "array",
"items": {
"$ref": "#/definitions/object2079760391"
}
}
}
}
}
}
dave
09/27/2019, 11:35 AMval contract = contract {
renderer = OpenApi3(ApiInfo("My great API", "v1.0"), Jackson)
descriptionPath = "/swagger.json"
security = mySecurity
routes += greetRoute()
routes += echoRoute()
}
renderer = OpenApi3(ApiInfo("My great API", "v1.0"), Jackson)
RajanS
09/27/2019, 11:44 AMcom.fasterxml.jackson
and we using OpenApi2
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.MapperFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.datatype.joda.JodaModule
import com.fasterxml.jackson.module.kotlin.KotlinModule
import org.http4k.format.ConfigurableJackson
object Json: ConfigurableJackson(ObjectMapper()
.registerModule(KotlinModule())
.registerModule(JodaModule())
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disableDefaultTyping()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false)
.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true)
.configure(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS, true)
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
)
dave
09/27/2019, 11:46 AMRajanS
09/27/2019, 11:47 AMdave
09/27/2019, 11:47 AMRajanS
09/27/2019, 11:49 AMreceiving(Body.auto<ObjectA>().toLens() to ObjectA(ObjectB(PHONE = true, POST = true, SMS = true)
I get the following error:
org.http4k.contract.openapi.v3.NoFieldFound: Could not find phone in ObjectB(PHONE=true, EMAIL=null, POST=true, SMS=true)
However, it’s fine when we do:
receiving(Body.auto<ObjectA>().toLens() to ObjectA(ObjectB())
Dataclass:
@JsonInclude(Include.NON_NULL)
data class ObjectB(
val PHONE: Boolean? = null,
val EMAIL: Boolean? = null,
val POST: Boolean? = null,
val SMS: Boolean? = null
)
dave
09/29/2019, 1:21 PM