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

Cosmin Victor Celea

09/09/2020, 10:23 AM
Is it possible to exclude some of the endpoints from the OpenApi Specs? There are some internal endpoints, that I want to hide from the specs endpoint.
d

dave

09/09/2020, 10:26 AM
not especially - we've done this before by creating 2 separate contracts and then just composing them, so you get an internal and public APIs on different root urls
c

Cosmin Victor Celea

09/09/2020, 10:28 AM
Good idea 👍
Is there a way to define things like server in the spec?
d

dave

09/09/2020, 11:22 AM
it's not built in at the moment. there's an issue: https://github.com/http4k/http4k/issues/433
you could do it through an extension, but that would involve messing with the element model directly
c

Cosmin Victor Celea

09/09/2020, 1:34 PM
Sorry to bother you so much today but is there a way to add a description to responseLens object example
I see open api keeps complaining that description: null for example responses
d

dave

09/09/2020, 1:35 PM
in the browser?
c

Cosmin Victor Celea

09/09/2020, 1:35 PM
Yep, i am trying to add the docs to swaggerhub
d

dave

09/09/2020, 1:36 PM
Copy code
Body.auto<ArbObject1>("some description").toLens()
?
if you're around at 4pm BST (london) and want to pop into the office hours session then can maybe answer more questions if you have them?
c

Cosmin Victor Celea

09/09/2020, 1:39 PM
Still null.
Sure I will do that if I have any more questions
Thank you
d

dave

09/09/2020, 1:40 PM
what's your Jackson setup?
are you using straight Jackson or a custom one?
c

Cosmin Victor Celea

09/09/2020, 1:41 PM
straight Jackson
d

dave

09/09/2020, 1:43 PM
you using the swagger editor?
or the openapi gui?
c

Cosmin Victor Celea

09/09/2020, 1:43 PM
swagger editor
d

dave

09/09/2020, 1:46 PM
are you actually editing it? or just browsing?
if browsing, you can use https://www.http4k.org/openapi3/
(if you've got a URL to load it from)
c

Cosmin Victor Celea

09/09/2020, 1:47 PM
I was editing, but is ok I will add the stuff like server manually for now anyway. The docs aren’t going to change that often.
d

dave

09/09/2020, 1:47 PM
the other option is to modify your Jackson to not serialise nulls
c

Cosmin Victor Celea

09/09/2020, 1:47 PM
👍
d

dave

09/09/2020, 1:48 PM
(you only need to modify the one that gets passed into the OpenApi3 renderer)
c

Cosmin Victor Celea

09/09/2020, 1:48 PM
Understood, thank you. Will look into it.
d

dave

09/09/2020, 1:49 PM
np 😄
c

Cosmin Victor Celea

09/10/2020, 12:05 PM
Copy code
val objectNode =  mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL).convertValue(input, JsonNode::class.java)

if(objectNode is ObjectNode)
{
    if(objectNode.has("info"))
    {
        val e: List<ServerOpenApi> = getOpenApiServers()
        val array = mapper.valueToTree<ArrayNode>(e)
        objectNode.putArray("servers").addAll(array)
    }

}
created my own version of ConfigurableJackson
to exclude nulls and add servers field.
Now the definition is valid.
Thanks for the tips
d

dave

09/10/2020, 12:08 PM
👍
10 Views