use of jetbrains.buildServer.server.rest.swagger.annotations.ModelBaseType in project teamcity-rest by JetBrains.
the class ExtensionModelResolver method resolve.
@Override
public Model resolve(JavaType type, ModelConverterContext context, Iterator<ModelConverter> next) {
ModelImpl model = (ModelImpl) super.resolve(type, context, next);
if (model != null) {
BeanDescription beanDesc = _mapper.getSerializationConfig().introspect(type);
final ModelBaseType baseTypeAnnotation = beanDesc.getClassAnnotations().get(ModelBaseType.class);
if (baseTypeAnnotation != null) {
model.setVendorExtension(ExtensionType.X_BASE_TYPE, baseTypeAnnotation.value());
if (!baseTypeAnnotation.baseEntity().isEmpty()) {
model.setVendorExtension(ExtensionType.X_BASE_ENTITY, baseTypeAnnotation.baseEntity());
}
}
final ModelDescription descriptionAnnotation = beanDesc.getClassAnnotations().get(ModelDescription.class);
if (descriptionAnnotation != null) {
model.setDescription(descriptionAnnotation.value());
if (!descriptionAnnotation.externalArticleLink().isEmpty()) {
if (!descriptionAnnotation.externalArticleName().isEmpty()) {
model.setVendorExtension(ExtensionType.X_HELP_ARTICLE_NAME, descriptionAnnotation.externalArticleName());
} else {
model.setVendorExtension(ExtensionType.X_HELP_ARTICLE_NAME, model.getName());
}
model.setVendorExtension(ExtensionType.X_HELP_ARTICLE_LINK, descriptionAnnotation.externalArticleLink());
}
}
// set default x-base-type vendor extension
if (baseTypeAnnotation == null || !model.getVendorExtensions().containsKey(ExtensionType.X_BASE_TYPE)) {
model.setVendorExtension(ExtensionType.X_BASE_TYPE, ObjectType.DATA);
}
setPackageExtension(model, type);
setIsTypeVendorExtension(model);
setParamExtensions(model);
setDescriptionVendorExtension(model);
} else {
LOGGER.debug(type.toString() + " type resolved to null");
}
return model;
}
Aggregations