override generation of specific object example for swagger ui

49 Views Asked by At

Im using Swagger UI (org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0) to generate OpenApi documentation endpoint and ui.

I have custom Value Object for Ids, lets consider

public class UserId {
    private UUID myProperty;

    public MyJavaClass(String uuid) {
        this.uuid = uuid;
    }

    public UUID getMyProperty() {
        return uuid;
    }
}

This is going to be shown in the example as

{
  "userId": {
     "uuid": "e73cd525-f324-4589-9498-006bd21750cd"
  }
}

and I want it to be shown in the example as a string like this

{
  "userId": "e73cd525-f324-4589-9498-006bd21750cd"
}

I know there is annotation for it, but I dont want to use it, I would rather inject my custom service to provide example of the testId in the payload. I tried to find any solution on google, but I failed.

Ive overriden serialization, so get/post is serialized and hydrated properly.

0

There are 0 best solutions below