Error on startup
See original GitHub issueWhen using version 3.0.1-SNAPSHOT, its git hash is c459ac5cbb82cde4982a5a49df4b1715bc990fa8 I got the following error when starting my web application
Model already registered with different name
The issue is in springfox.documentation.schema.TypeNameIndexingAdapter#checkTypeRegistration, line 50
if (knownNames.containsKey(typeId)) {
if (!knownNames.get(typeId).equals(typeName)) {
LOGGER.debug("Rewriting type {} with model id: {} is not allowed, because it is already registered",
typeName,
typeId);
throw new IllegalStateException("Model already registered with different name.");
}
I have debugged the code and revealed that the value of typeName is “Job” when knownNames.get(typeId) evaluates to “Job_1”. “Job” is a re-usable class which appears in multiple REST functions as return value like
List<Job> allJobs();
Job getJob(int id);
Job has a field of User type which is also used in multiple REST controllers.
Seems when scanning REST controllers springfox assigns different names to the same entity in case the entity appears in multiple REST functions.
I have noticed that the knownNames
map has more than 1 record for the same entity, for example
“74_0_x.y.z.User” -> “User” “71_0_x.y.z.User” -> “User”
Removing prefix and suffix from typeName and model id could solve this issue with improved performance as a side effect.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:13 (1 by maintainers)
Top GitHub Comments
hi, Has this problem been solved?
+1