Comments on: Contract Testing on Kubernetes with Microcks https://piotrminkowski.com/2023/05/20/contract-testing-on-kubernetes-with-microcks/ Java, Spring, Kotlin, microservices, Kubernetes, containers Tue, 23 May 2023 22:05:38 +0000 hourly 1 https://wordpress.org/?v=6.9.1 By: piotr.minkowski https://piotrminkowski.com/2023/05/20/contract-testing-on-kubernetes-with-microcks/#comment-2014 Tue, 23 May 2023 22:05:38 +0000 https://piotrminkowski.com/?p=14182#comment-2014 In reply to lbroudoux (@lbroudoux).

Hi. Yes, I was thinking about it. Of course, it should work fine. However, I wasn’t sure I want to store such things directly in the code…

]]>
By: lbroudoux (@lbroudoux) https://piotrminkowski.com/2023/05/20/contract-testing-on-kubernetes-with-microcks/#comment-2012 Mon, 22 May 2023 12:34:49 +0000 https://piotrminkowski.com/?p=14182#comment-2012 Thanks a lot for this comprehensive blog post. Love it!

What do you think about the practice of adding OpenAPI annotations into your `EmployeeController` class to manage examples? Something like:

“`java
@GET
@APIResponses(value = {
@APIResponse(responseCode = “200”, content = {
@Content(mediaType = “application/json”, examples = {
@ExampleObject(name = “all_persons”, value = “[\n” +
“{\”id\”: 1, \”name\”: \”Test User 1\”, \”age\”: 20, \”organizationId\”: 1, \”departmentId\”: 1, \”position\”: \”developer\”},\n” +
“{\”id\”: 2, \”name\”: \”Test User 2\”, \”age\”: 30, \”organizationId\”: 1, \”departmentId\”: 2, \”position\”: \”architect\”},\n” +
“{\”id\”: 3, \”name\”: \”Test User 3\”, \”age\”: 40, \”organizationId\”: 2, \”departmentId\”: 3, \”position\”: \”developer\”},\n” +
“]”)
})
})
})
public Set findAll() {
LOGGER.info(“Employee find”);
return repository.findAll();
}
“`

That way, examples are kept in the code and can be adapted when you change the model. It also prevents editing the generated OpenAPI and forgetting something during dev iterations… I’ll try this and can push a PR if you mind.

]]>