Having recently started a new Spring-based project with my team, we have decided to leave our well-known-but-outdated Swagger 2.0 documentation practices in favour of Swagger 3.0 standard following the OpenApi directives.
Not to make the jump too drastic, we are trying to stick to the configuration- and annotation-based style of auto-generated documentation. This, however, does not come without some difficulties.
We would like to define schemas used for some heavily reusable types just once, for the whole project to use. Namely, we are using org.bson.types.ObjectId fields coupled with -to-string and string-to- serializers/deserializers utilising type's hex-string representation. This is just fine for our controllers.
Meanwhile, Swagger UI (v. 1.2.9) insists on representing any ObjectId field and/or parameter as its full object form, i.e.
"id": {
"timestamp": 0,
"counter": 0,
"time": 0,
"date": "2020-02-11T11:13:57.130Z",
"machineIdentifier": 0,
"processIdentifier": 0,
"timeSecond": 0
}
Is there a way for our java code to define schema for the ObjectId type - that is an external dependency - once and for all so that our Swagger UI recognises this type can be represented as a simple string at any encountered instance?