mongodbswagger-uiquarkusobjectid

Quarkus Swagger MongoDB ObjectId Format


I'am writting app with quarkus-resteasy and mongodb. After quarkus OpenAPI has been installed, I saw that swagger UI does not correctly showing ObjectID format.

[Look at the image][1].

I am would like to see something like "61338f5b47bfc65136b5de30". How globally set ObjectID output format?


Solution

  • Because an objectId its what it is, thouse are the fields inside and what openapi is interpreting.

    You can override what is being generated using the @Schema annotation, providing a format, an example and a type, in this case String, you can control what your swagger will contain.

    @Schema(description = "Identifier of the Whatever", type = SchemaType.STRING, format = "XXXXXX", example="<Insert and example here>")
    

    Because this is a value rather than a class that you can modify I think that you will need to put this annotation in all your DTO's that use these type.

    Another option is using a Wrapper object, but this may modify your json structure depending on how you implement it.