<@U0M0EAG90> I too have notice this. I have just b...
# http4k
s
@elifarley I too have notice this. I have just been living with it but would like to be able to name the object. I haven't found a way.
e
Good to know I'm not the only one ­čśë
d
You can pass the override for the definitionId when defining the response.
The reason for the weird name is that we autogenerate the names from the hashcode of the object. This ensures that there is only one copy of any particular model generated.
Also, if you give them your own name, you have to manage the names yourself as opposed to having the library do it.
This override is only available for the top level object.
e
In fact, I think the current behavior is sensible, but in my specific case, I'd rather have a user-friendly name.
d
I'm not actually sure what the overall effect is from a API user perspective of having those weird names. I suppose that he names in the swagger UI might be different, but that's about it I think. As I said, you don't achieve the full power of the JSON schema if you override the names, because you might introduce duplication and/or erroneous overrides into the set of schemas.
e
I couldn't get it right...
Copy code
returning(ResponseMeta("Product information in JSON", Response(OK).with(
                    productInfoBody of ProductInfo.dummy
            ), "product-info"))
gives me
Copy code
"200": {
						"description": "Product information in JSON",
						"schema": null
					},
Weird... I've reverted to the old code, and the result is the same schema: null !!! It was working earlier today... What could be wrong? Here's the previous code:
Copy code
returning("Product information in JSON" to Response(OK).with(
                    productInfoBody of ProductInfo.dummy
            ))
d
have you upgraded the version?
not that that's bad - just useful!
e
nope, AFAIK I have just changed the parameter to a ResponseMeta !!
Well, I only slept for 4 hours today... maybe that's it
I guess I'll put a breakpoint on the part of the code that renders the API doc
d
this is the syntax from the test that we use to test the override, so should definitely work!
Copy code
returning(ResponseMeta("peachy",
                    Response(ACCEPTED).with(customBody of Argo.obj("anAnotherObject" to Argo.obj("aNumberField" to Argo.number(123)))), "someDefinitionId"))
you can replace the Argo with Jackson or Gson as appropraite
e
yep, it was working just a few hours ago... hehehe
ok, let me debug it to find out what I did differently now