Is it possible to exclude some of the endpoints fr...
# http4k
c
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
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
Good idea 👍
Is there a way to define things like server in the spec?
d
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
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
in the browser?
c
Yep, i am trying to add the docs to swaggerhub
d
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
Still null.
Sure I will do that if I have any more questions
Thank you
d
what's your Jackson setup?
are you using straight Jackson or a custom one?
c
straight Jackson
d
you using the swagger editor?
or the openapi gui?
c
swagger editor
d
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
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
the other option is to modify your Jackson to not serialise nulls
c
👍
d
(you only need to modify the one that gets passed into the OpenApi3 renderer)
c
Understood, thank you. Will look into it.
d
np 😄
c
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
👍