Skip to content

Conversation

frantuma
Copy link
Contributor

up to 1.5.23 release any defined JsonRootName annotation on a model takes precedence over a
defined ApiModel.value annotation on the same model, causing e.g. issues like the one described in #3286. This PR addresses this by reversing the logic in such cases.

Note this breaks default behaviour in such scenarios comparing to previous versions, as an expected effect, given that previous logic can be considered a bug, as swagger annotations must take precedence to provide full control of the resolved spec.

To maintain previous behavior for any reason, a custom model resolver can be provided:

class CustomSchemaNameResolverConverter extends ModelResolver {

        public CustomSchemaNameResolverConverter(ObjectMapper mapper) {
            super(mapper);
        }
        protected boolean prioritizeAnnotationInspectorSchemaName() {
          return true;
        }
    }
ModelConverters.getInstance().addConverter(new CustomSchemaNameResolverConverter(Json.mapper()));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant