Search in sources :

Example 41 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project engine by craftercms.

the class CheckboxGroupFieldFactory method createField.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public void createField(final Document contentTypeDefinition, final Node contentTypeField, final String contentTypeFieldId, final String parentGraphQLTypeName, final GraphQLObjectType.Builder parentGraphQLType, final String graphQLFieldName, final GraphQLFieldDefinition.Builder graphQLField) {
    String datasourceName = XmlUtils.selectSingleNodeValue(contentTypeField, datasourceNameXPath);
    String datasourceSettings = XmlUtils.selectSingleNodeValue(contentTypeDefinition, String.format(datasourceSettingsXPathFormat, datasourceName));
    String datasourceType = null;
    String datasourceSuffix = null;
    try {
        if (StringUtils.isNotEmpty(datasourceSettings)) {
            List<Map<String, Object>> typeSetting = objectMapper.readValue(datasourceSettings, List.class);
            Optional<Map<String, Object>> selectedType = typeSetting.stream().filter(s -> (Boolean) s.get(FIELD_NAME_SELECTED)).findFirst();
            if (selectedType.isPresent()) {
                datasourceType = selectedType.get().get(FIELD_NAME_VALUE).toString();
                datasourceSuffix = StringUtils.substringAfter(datasourceType, FIELD_SEPARATOR);
            }
        }
    } catch (IOException e) {
        logger.warn("Error checking data source type for '{}'", contentTypeFieldId);
    }
    String valueKey = FIELD_NAME_VALUE;
    if (StringUtils.isNotEmpty(datasourceSuffix)) {
        valueKey += FIELD_SEPARATOR + datasourceSuffix + FIELD_SUFFIX_MULTIVALUE;
    }
    GraphQLFieldDefinition.Builder valueField = GraphQLFieldDefinition.newFieldDefinition().name(valueKey).description("The value of the item");
    if (StringUtils.isNotEmpty(datasourceType)) {
        setTypeFromFieldName(datasourceType, valueField);
    } else {
        valueField.type(GraphQLString);
        valueField.argument(TEXT_FILTER);
    }
    GraphQLObjectType itemType = GraphQLObjectType.newObject().name(parentGraphQLTypeName + FIELD_SEPARATOR + graphQLFieldName + FIELD_SUFFIX_ITEM).description("Item for field " + contentTypeFieldId).field(GraphQLFieldDefinition.newFieldDefinition().name(FIELD_NAME_KEY).description("The key of the item").type(GraphQLString).argument(TEXT_FILTER)).field(valueField).build();
    GraphQLObjectType itemWrapper = GraphQLObjectType.newObject().name(parentGraphQLTypeName + FIELD_SEPARATOR + graphQLFieldName + FIELD_SUFFIX_ITEMS).description("Wrapper for field " + contentTypeFieldId).field(GraphQLFieldDefinition.newFieldDefinition().name(FIELD_NAME_ITEM).description("List of items for field " + contentTypeFieldId).type(list(itemType))).build();
    graphQLField.type(itemWrapper);
}
Also used : FIELD_SUFFIX_MULTIVALUE(org.craftercms.engine.graphql.SchemaUtils.FIELD_SUFFIX_MULTIVALUE) Document(org.dom4j.Document) GraphQLString(graphql.Scalars.GraphQLString) FIELD_NAME_SELECTED(org.craftercms.engine.graphql.SchemaUtils.FIELD_NAME_SELECTED) Node(org.dom4j.Node) GraphQLFieldDefinition(graphql.schema.GraphQLFieldDefinition) LoggerFactory(org.slf4j.LoggerFactory) FIELD_SUFFIX_ITEM(org.craftercms.engine.graphql.SchemaUtils.FIELD_SUFFIX_ITEM) StringUtils(org.apache.commons.lang3.StringUtils) GraphQLList.list(graphql.schema.GraphQLList.list) FIELD_SUFFIX_ITEMS(org.craftercms.engine.graphql.SchemaUtils.FIELD_SUFFIX_ITEMS) TEXT_FILTER(org.craftercms.engine.graphql.SchemaUtils.TEXT_FILTER) GraphQLFieldFactory(org.craftercms.engine.graphql.GraphQLFieldFactory) Map(java.util.Map) FIELD_NAME_VALUE(org.craftercms.engine.graphql.SchemaUtils.FIELD_NAME_VALUE) XmlUtils(org.craftercms.core.util.XmlUtils) FIELD_NAME_ITEM(org.craftercms.engine.graphql.SchemaUtils.FIELD_NAME_ITEM) FIELD_SEPARATOR(org.craftercms.engine.graphql.SchemaUtils.FIELD_SEPARATOR) GraphQLObjectType(graphql.schema.GraphQLObjectType) Logger(org.slf4j.Logger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) SchemaUtils.setTypeFromFieldName(org.craftercms.engine.graphql.SchemaUtils.setTypeFromFieldName) List(java.util.List) Optional(java.util.Optional) Required(org.springframework.beans.factory.annotation.Required) FIELD_NAME_KEY(org.craftercms.engine.graphql.SchemaUtils.FIELD_NAME_KEY) GraphQLObjectType(graphql.schema.GraphQLObjectType) GraphQLFieldDefinition(graphql.schema.GraphQLFieldDefinition) GraphQLString(graphql.Scalars.GraphQLString) IOException(java.io.IOException) Map(java.util.Map)

Example 42 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project kylo by Teradata.

the class LivyProperties method postConstruct.

@PostConstruct
private void postConstruct() {
    logger.debug("PostConstruct called for LivyProperties");
    if (!Lists.newArrayList(env.getActiveProfiles()).contains("kylo-livy")) {
        throw new IllegalStateException("Attempting to instantiate LivyProperties bean when 'kylo-livy' is not an active profile");
    }
    if (!StringUtils.isNotEmpty(hostname)) {
        throw new LivyConfigurationException("Attempt to start when 'kylo-livy' is an active profile and property 'spark.livy.hostname' not defined, or invalid.");
    }
    if (port == null || port <= 0) {
        throw new LivyConfigurationException("Attempt to start when 'kylo-livy' is an active profile and property 'spark.livy.port' not defined, or invalid.");
    }
    logger.debug("determine the set of spark properties to pass to Livy");
    MutablePropertySources propSrcs = ((AbstractEnvironment) env).getPropertySources();
    StreamSupport.stream(propSrcs.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource).map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::<String>stream).filter(propName -> propName.startsWith("spark.") && !(propName.startsWith("spark.livy.") || propName.startsWith("spark.shell."))).forEach(propName -> sparkProperties.put(propName, env.getProperty(propName)));
    logger.debug("Validate session kinds are supportable");
    if (!(livySessionKind.equals(SessionKind.shared) || livySessionKind.equals(SessionKind.spark))) {
        throw new LivyConfigurationException(String.format("Session kind='%s' is not yet supported"));
    }
    logger.info("The following spark properties were found in kylo config files: '{}'", sparkProperties);
}
Also used : LivyConfigurationException(com.thinkbiganalytics.kylo.spark.exceptions.LivyConfigurationException) LivyConfigurationException(com.thinkbiganalytics.kylo.spark.exceptions.LivyConfigurationException) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) SessionKind(com.thinkbiganalytics.kylo.spark.model.enums.SessionKind) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EnumerablePropertySource(org.springframework.core.env.EnumerablePropertySource) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) Lists(com.google.common.collect.Lists) Environment(org.springframework.core.env.Environment) Map(java.util.Map) PostConstruct(javax.annotation.PostConstruct) StreamSupport(java.util.stream.StreamSupport) MutablePropertySources(org.springframework.core.env.MutablePropertySources) AbstractEnvironment(org.springframework.core.env.AbstractEnvironment) EnumerablePropertySource(org.springframework.core.env.EnumerablePropertySource) AbstractEnvironment(org.springframework.core.env.AbstractEnvironment) MutablePropertySources(org.springframework.core.env.MutablePropertySources) Arrays(java.util.Arrays) PostConstruct(javax.annotation.PostConstruct)

Example 43 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project BroadleafCommerce by BroadleafCommerce.

the class ContentProcessor method populateModelVariables.

@Override
public Map<String, Object> populateModelVariables(String tagName, Map<String, String> tagAttributes, BroadleafTemplateContext context) {
    String contentType = tagAttributes.get("contentType");
    String contentName = tagAttributes.get("contentName");
    String maxResultsStr = tagAttributes.get("maxResults");
    if (StringUtils.isEmpty(contentType) && StringUtils.isEmpty(contentName)) {
        throw new IllegalArgumentException("The content processor must have a non-empty attribute value for 'contentType' or 'contentName'");
    }
    Integer maxResults = null;
    if (maxResultsStr != null) {
        maxResults = Ints.tryParse(maxResultsStr);
    }
    if (maxResults == null) {
        maxResults = Integer.MAX_VALUE;
    }
    String contentListVar = getAttributeValue(tagAttributes, "contentListVar", "contentList");
    String contentItemVar = getAttributeValue(tagAttributes, "contentItemVar", "contentItem");
    String numResultsVar = getAttributeValue(tagAttributes, "numResultsVar", "numResults");
    String fieldFilters = tagAttributes.get("fieldFilters");
    final String sorts = tagAttributes.get("sorts");
    BroadleafRequestContext blcContext = BroadleafRequestContext.getBroadleafRequestContext();
    HttpServletRequest request = blcContext.getRequest();
    Map<String, Object> mvelParameters = buildMvelParameters(blcContext.getRequest(), tagAttributes, context);
    SandBox currentSandbox = blcContext.getSandBox();
    List<StructuredContentDTO> contentItems;
    StructuredContentType structuredContentType = null;
    if (contentType != null) {
        structuredContentType = structuredContentService.findStructuredContentTypeByName(contentType);
    }
    Locale locale = blcContext.getLocale();
    Map<String, Object> newModelVars = new HashMap<>();
    contentItems = getContentItems(contentName, maxResults, request, mvelParameters, currentSandbox, structuredContentType, locale, tagName, tagAttributes, newModelVars, context);
    if (contentItems.size() > 0) {
        // sort the resulting list by the configured property sorts on the tag
        if (StringUtils.isNotEmpty(sorts)) {
            final BroadleafTemplateContext finalContext = context;
            // In order to use the context in a comparator it needs to be final
            Collections.sort(contentItems, new Comparator<StructuredContentDTO>() {

                @Override
                public int compare(StructuredContentDTO o1, StructuredContentDTO o2) {
                    List<BroadleafAssignation> sortAssignments = finalContext.getAssignationSequence(sorts, false);
                    CompareToBuilder compareBuilder = new CompareToBuilder();
                    for (BroadleafAssignation sortAssignment : sortAssignments) {
                        String property = sortAssignment.getLeftStringRepresentation(finalContext);
                        Object val1 = o1.getPropertyValue(property);
                        Object val2 = o2.getPropertyValue(property);
                        if (sortAssignment.parseRight(finalContext).equals("ASCENDING")) {
                            compareBuilder.append(val1, val2);
                        } else {
                            compareBuilder.append(val2, val1);
                        }
                    }
                    return compareBuilder.toComparison();
                }
            });
        }
        List<Map<String, Object>> contentItemFields = new ArrayList<>();
        for (StructuredContentDTO item : contentItems) {
            if (StringUtils.isNotEmpty(fieldFilters)) {
                List<BroadleafAssignation> assignments = context.getAssignationSequence(fieldFilters, false);
                boolean valid = true;
                for (BroadleafAssignation assignment : assignments) {
                    if (ObjectUtils.notEqual(assignment.parseRight(context), item.getValues().get(assignment.getLeftStringRepresentation(context)))) {
                        LOG.info("Excluding content " + item.getId() + " based on the property value of " + assignment.getLeftStringRepresentation(context));
                        valid = false;
                        break;
                    }
                }
                if (valid) {
                    contentItemFields.add(item.getValues());
                }
            } else {
                contentItemFields.add(item.getValues());
            }
        }
        Map<String, Object> contentItem = null;
        if (contentItemFields.size() > 0) {
            contentItem = contentItemFields.get(0);
        }
        newModelVars.put(contentItemVar, contentItem);
        newModelVars.put(contentListVar, contentItemFields);
        newModelVars.put(numResultsVar, contentItems.size());
    } else {
        if (LOG.isInfoEnabled()) {
            LOG.info("**************************The contentItems is null*************************");
        }
        newModelVars.put(contentItemVar, null);
        newModelVars.put(contentListVar, null);
        newModelVars.put(numResultsVar, 0);
    }
    String deepLinksVar = tagAttributes.get("deepLinks");
    if (StringUtils.isNotBlank(deepLinksVar) && contentItems.size() > 0) {
        List<DeepLink> links = contentDeepLinkService.getLinks(contentItems.get(0));
        extensionManager.getProxy().addExtensionFieldDeepLink(links, tagName, tagAttributes, context);
        extensionManager.getProxy().postProcessDeepLinks(links);
        newModelVars.put(deepLinksVar, links);
    }
    return newModelVars;
}
Also used : Locale(org.broadleafcommerce.common.locale.domain.Locale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) List(java.util.List) CompareToBuilder(org.apache.commons.lang3.builder.CompareToBuilder) BroadleafTemplateContext(org.broadleafcommerce.presentation.model.BroadleafTemplateContext) SandBox(org.broadleafcommerce.common.sandbox.domain.SandBox) StructuredContentDTO(org.broadleafcommerce.common.structure.dto.StructuredContentDTO) BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext) DeepLink(org.broadleafcommerce.common.web.deeplink.DeepLink) StructuredContentType(org.broadleafcommerce.cms.structure.domain.StructuredContentType) BroadleafAssignation(org.broadleafcommerce.presentation.model.BroadleafAssignation) HashMap(java.util.HashMap) Map(java.util.Map)

Example 44 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project azure-tools-for-java by Microsoft.

the class CosmosServerlessSparkBatchJob method getSubmissionLog.

@NotNull
@Override
public Observable<SparkLogLine> getSubmissionLog() {
    final ImmutableSet<String> ignoredEmptyLines = ImmutableSet.of("stdout:", "stderr:", "yarn diagnostics:");
    final int GET_LIVY_URL_REPEAT_DELAY_MILLISECONDS = 3000;
    final int MAX_LOG_LINES_PER_REQUEST = 128;
    final int GET_LOG_REPEAT_DELAY_MILLISECONDS = 1000;
    // We need to repeatly call getSparkBatchJobRequest() since "livyServerApi" field does not always exist in response but
    // only appeared for a while and before that we can't get the "livyServerApi" field.
    ctrlInfo("Trying to get livy URL...");
    return getSparkBatchJobRequest().flatMap(batchResp -> getJobSchedulerState(batchResp) == null ? Observable.error(new IOException("Failed to get scheduler state of the job.")) : Observable.just(batchResp)).retryWhen(err -> err.zipWith(Observable.range(1, getRetriesMax()), (n, i) -> i).delay(getDelaySeconds(), TimeUnit.SECONDS)).repeatWhen(ob -> ob.delay(GET_LIVY_URL_REPEAT_DELAY_MILLISECONDS, TimeUnit.MILLISECONDS)).takeUntil(batchResp -> isJobEnded(batchResp) || StringUtils.isNotEmpty(getLivyAPI(batchResp))).filter(batchResp -> isJobEnded(batchResp) || StringUtils.isNotEmpty(getLivyAPI(batchResp))).flatMap(job -> {
        if (isJobEnded(job)) {
            final String jobState = getJobState(job);
            final String schedulerState = getJobSchedulerState(job);
            final String message = String.format("Job scheduler state: %s. Job running state: %s.", schedulerState, jobState);
            return Observable.just(new SparkLogLine(TOOL, Info, message));
        } else {
            return Observable.just(job).doOnNext(batchResp -> {
                ctrlInfo("Successfully get livy URL: " + batchResp.properties().livyServerAPI());
                ctrlInfo("Trying to retrieve livy submission logs...");
                // After test we find batch id won't be provided until the job is in running state
                // However, since only one spark job will be run on the cluster, the batch ID should always be 0
                setBatchId(0);
            }).map(batchResp -> batchResp.properties().livyServerAPI()).flatMap(livyUrl -> Observable.defer(() -> getSubmissionLogRequest(livyUrl, getBatchId(), getLogStartIndex(), MAX_LOG_LINES_PER_REQUEST)).map(sparkJobLog -> Optional.ofNullable(sparkJobLog.getLog()).orElse(Collections.<String>emptyList())).doOnNext(logs -> setLogStartIndex(getLogStartIndex() + logs.size())).map(logs -> logs.stream().filter(logLine -> !ignoredEmptyLines.contains(logLine.trim().toLowerCase())).collect(Collectors.toList())).flatMap(logLines -> {
                if (logLines.size() > 0) {
                    return Observable.just(Triple.of(logLines, SparkBatchJobState.STARTING.toString(), SchedulerState.SCHEDULED.toString()));
                } else {
                    return getSparkBatchJobRequest().map(batchResp -> Triple.of(logLines, getJobState(batchResp), getJobSchedulerState(batchResp)));
                }
            }).onErrorResumeNext(errors -> getSparkBatchJobRequest().delay(getDelaySeconds(), TimeUnit.SECONDS).map(batchResp -> Triple.of(new ArrayList<>(), getJobState(batchResp), getJobSchedulerState(batchResp)))).repeatWhen(ob -> ob.delay(GET_LOG_REPEAT_DELAY_MILLISECONDS, TimeUnit.MILLISECONDS)).takeUntil(logAndStatesTriple -> {
                String jobRunningState = logAndStatesTriple.getMiddle();
                String jobSchedulerState = logAndStatesTriple.getRight();
                return jobRunningState != null && !jobRunningState.equalsIgnoreCase(SparkBatchJobState.STARTING.toString()) || jobSchedulerState != null && jobSchedulerState.equalsIgnoreCase(SchedulerState.ENDED.toString());
            }).flatMap(logAndStatesTriple -> {
                final String jobRunningState = logAndStatesTriple.getMiddle();
                final String jobSchedulerState = logAndStatesTriple.getRight();
                if (jobRunningState != null && !jobRunningState.equalsIgnoreCase(SparkBatchJobState.STARTING.toString()) || jobSchedulerState != null && jobSchedulerState.equalsIgnoreCase(SchedulerState.ENDED.toString())) {
                    final String message = String.format("Job scheduler state: %s. Job running state: %s.", jobSchedulerState, jobRunningState);
                    return Observable.just(new SparkLogLine(TOOL, Info, message));
                } else {
                    return Observable.from(logAndStatesTriple.getLeft()).map(line -> new SparkLogLine(LIVY, Log, line));
                }
            }));
        }
    });
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) AzureSparkServerlessAccount(com.microsoft.azure.hdinsight.sdk.common.azure.serverless.AzureSparkServerlessAccount) java.util(java.util) CreateSparkBatchJobParameters(com.microsoft.azure.hdinsight.sdk.rest.azure.serverless.spark.models.CreateSparkBatchJobParameters) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull) ADLStoreClient(com.microsoft.azure.datalake.store.ADLStoreClient) StringUtils(org.apache.commons.lang3.StringUtils) Header(org.apache.http.Header) Observable(rx.Observable) Info(com.microsoft.azure.hdinsight.common.MessageInfoType.Info) URI(java.net.URI) Triple(org.apache.commons.lang3.tuple.Triple) TOOL(com.microsoft.azure.hdinsight.spark.common.log.SparkLogLine.TOOL) ImmutableSet(com.google.common.collect.ImmutableSet) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable) IOException(java.io.IOException) SchedulerState(com.microsoft.azure.hdinsight.sdk.rest.azure.serverless.spark.models.SchedulerState) Collectors(java.util.stream.Collectors) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) Log(com.microsoft.azure.hdinsight.common.MessageInfoType.Log) BasicHeader(org.apache.http.message.BasicHeader) LIVY(com.microsoft.azure.hdinsight.spark.common.log.SparkLogLine.LIVY) NameValuePair(org.apache.http.NameValuePair) SparkLogLine(com.microsoft.azure.hdinsight.spark.common.log.SparkLogLine) AzureHttpObservable(com.microsoft.azure.hdinsight.sdk.common.AzureHttpObservable) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) IOException(java.io.IOException) SparkLogLine(com.microsoft.azure.hdinsight.spark.common.log.SparkLogLine) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 45 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project swagger-core by swagger-api.

the class ModelResolver method resolve.

@Override
public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context, Iterator<ModelConverter> next) {
    boolean isPrimitive = false;
    Schema model = null;
    List<String> requiredProps = new ArrayList<>();
    if (annotatedType == null) {
        return null;
    }
    if (this.shouldIgnoreClass(annotatedType.getType())) {
        return null;
    }
    final JavaType type;
    if (annotatedType.getType() instanceof JavaType) {
        type = (JavaType) annotatedType.getType();
    } else {
        type = _mapper.constructType(annotatedType.getType());
    }
    final Annotation resolvedSchemaOrArrayAnnotation = AnnotationsUtils.mergeSchemaAnnotations(annotatedType.getCtxAnnotations(), type);
    final io.swagger.v3.oas.annotations.media.Schema resolvedSchemaAnnotation = resolvedSchemaOrArrayAnnotation == null ? null : resolvedSchemaOrArrayAnnotation instanceof io.swagger.v3.oas.annotations.media.ArraySchema ? ((io.swagger.v3.oas.annotations.media.ArraySchema) resolvedSchemaOrArrayAnnotation).schema() : (io.swagger.v3.oas.annotations.media.Schema) resolvedSchemaOrArrayAnnotation;
    final io.swagger.v3.oas.annotations.media.ArraySchema resolvedArrayAnnotation = resolvedSchemaOrArrayAnnotation == null ? null : resolvedSchemaOrArrayAnnotation instanceof io.swagger.v3.oas.annotations.media.ArraySchema ? (io.swagger.v3.oas.annotations.media.ArraySchema) resolvedSchemaOrArrayAnnotation : null;
    final BeanDescription beanDesc;
    {
        BeanDescription recurBeanDesc = _mapper.getSerializationConfig().introspect(type);
        HashSet<String> visited = new HashSet<>();
        JsonSerialize jsonSerialize = recurBeanDesc.getClassAnnotations().get(JsonSerialize.class);
        while (jsonSerialize != null && !Void.class.equals(jsonSerialize.as())) {
            String asName = jsonSerialize.as().getName();
            if (visited.contains(asName))
                break;
            visited.add(asName);
            recurBeanDesc = _mapper.getSerializationConfig().introspect(_mapper.constructType(jsonSerialize.as()));
            jsonSerialize = recurBeanDesc.getClassAnnotations().get(JsonSerialize.class);
        }
        beanDesc = recurBeanDesc;
    }
    String name = annotatedType.getName();
    if (StringUtils.isBlank(name)) {
        // allow override of name from annotation
        if (!annotatedType.isSkipSchemaName() && resolvedSchemaAnnotation != null && !resolvedSchemaAnnotation.name().isEmpty()) {
            name = resolvedSchemaAnnotation.name();
        }
        if (StringUtils.isBlank(name) && !ReflectionUtils.isSystemType(type)) {
            name = _typeName(type, beanDesc);
        }
    }
    name = decorateModelName(annotatedType, name);
    // if we have a ref we don't consider anything else
    if (resolvedSchemaAnnotation != null && StringUtils.isNotEmpty(resolvedSchemaAnnotation.ref())) {
        if (resolvedArrayAnnotation == null) {
            return new Schema().$ref(resolvedSchemaAnnotation.ref()).name(name);
        } else {
            ArraySchema schema = new ArraySchema();
            resolveArraySchema(annotatedType, schema, resolvedArrayAnnotation);
            return schema.items(new Schema().$ref(resolvedSchemaAnnotation.ref()).name(name));
        }
    }
    if (!annotatedType.isSkipOverride() && resolvedSchemaAnnotation != null && !Void.class.equals(resolvedSchemaAnnotation.implementation())) {
        Class<?> cls = resolvedSchemaAnnotation.implementation();
        LOGGER.debug("overriding datatype from {} to {}", type, cls.getName());
        Annotation[] ctxAnnotation = null;
        if (resolvedArrayAnnotation != null && annotatedType.getCtxAnnotations() != null) {
            List<Annotation> annList = new ArrayList<>();
            for (Annotation a : annotatedType.getCtxAnnotations()) {
                if (!(a instanceof ArraySchema)) {
                    annList.add(a);
                }
            }
            annList.add(resolvedSchemaAnnotation);
            ctxAnnotation = annList.toArray(new Annotation[annList.size()]);
        } else {
            ctxAnnotation = annotatedType.getCtxAnnotations();
        }
        AnnotatedType aType = new AnnotatedType().type(cls).ctxAnnotations(ctxAnnotation).parent(annotatedType.getParent()).name(annotatedType.getName()).resolveAsRef(annotatedType.isResolveAsRef()).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()).propertyName(annotatedType.getPropertyName()).skipOverride(true);
        if (resolvedArrayAnnotation != null) {
            ArraySchema schema = new ArraySchema();
            resolveArraySchema(annotatedType, schema, resolvedArrayAnnotation);
            Schema innerSchema = null;
            Schema primitive = PrimitiveType.createProperty(cls);
            if (primitive != null) {
                innerSchema = primitive;
            } else {
                innerSchema = context.resolve(aType);
                if (innerSchema != null && "object".equals(innerSchema.getType()) && StringUtils.isNotBlank(innerSchema.getName())) {
                    // create a reference for the items
                    if (context.getDefinedModels().containsKey(innerSchema.getName())) {
                        innerSchema = new Schema().$ref(constructRef(innerSchema.getName()));
                    }
                } else if (innerSchema != null && innerSchema.get$ref() != null) {
                    innerSchema = new Schema().$ref(StringUtils.isNotEmpty(innerSchema.get$ref()) ? innerSchema.get$ref() : innerSchema.getName());
                }
            }
            schema.setItems(innerSchema);
            return schema;
        } else {
            Schema implSchema = context.resolve(aType);
            if (implSchema != null && aType.isResolveAsRef() && "object".equals(implSchema.getType()) && StringUtils.isNotBlank(implSchema.getName())) {
                // create a reference for the items
                if (context.getDefinedModels().containsKey(implSchema.getName())) {
                    implSchema = new Schema().$ref(constructRef(implSchema.getName()));
                }
            } else if (implSchema != null && implSchema.get$ref() != null) {
                implSchema = new Schema().$ref(StringUtils.isNotEmpty(implSchema.get$ref()) ? implSchema.get$ref() : implSchema.getName());
            }
            return implSchema;
        }
    }
    if (model == null && !annotatedType.isSkipOverride() && resolvedSchemaAnnotation != null && StringUtils.isNotEmpty(resolvedSchemaAnnotation.type()) && !resolvedSchemaAnnotation.type().equals("object")) {
        PrimitiveType primitiveType = PrimitiveType.fromTypeAndFormat(resolvedSchemaAnnotation.type(), resolvedSchemaAnnotation.format());
        if (primitiveType == null) {
            primitiveType = PrimitiveType.fromType(type);
        }
        if (primitiveType == null) {
            primitiveType = PrimitiveType.fromName(resolvedSchemaAnnotation.type());
        }
        if (primitiveType != null) {
            Schema primitive = primitiveType.createProperty();
            model = primitive;
            isPrimitive = true;
        }
    }
    if (model == null && type.isEnumType()) {
        model = new StringSchema();
        _addEnumProps(type.getRawClass(), model);
        isPrimitive = true;
    }
    if (model == null) {
        PrimitiveType primitiveType = PrimitiveType.fromType(type);
        if (primitiveType != null) {
            model = PrimitiveType.fromType(type).createProperty();
            isPrimitive = true;
        }
    }
    if (!annotatedType.isSkipJsonIdentity()) {
        JsonIdentityInfo jsonIdentityInfo = AnnotationsUtils.getAnnotation(JsonIdentityInfo.class, annotatedType.getCtxAnnotations());
        if (jsonIdentityInfo == null) {
            jsonIdentityInfo = type.getRawClass().getAnnotation(JsonIdentityInfo.class);
        }
        if (model == null && jsonIdentityInfo != null) {
            JsonIdentityReference jsonIdentityReference = AnnotationsUtils.getAnnotation(JsonIdentityReference.class, annotatedType.getCtxAnnotations());
            if (jsonIdentityReference == null) {
                jsonIdentityReference = type.getRawClass().getAnnotation(JsonIdentityReference.class);
            }
            model = new GeneratorWrapper().processJsonIdentity(annotatedType, context, _mapper, jsonIdentityInfo, jsonIdentityReference);
            if (model != null) {
                return model;
            }
        }
    }
    if (model == null && annotatedType.getJsonUnwrappedHandler() != null) {
        model = annotatedType.getJsonUnwrappedHandler().apply(annotatedType);
        if (model == null) {
            return null;
        }
    }
    if ("Object".equals(name)) {
        return new Schema();
    }
    if (isPrimitive) {
        if (annotatedType.isSchemaProperty()) {
        // model.name(name);
        }
        XML xml = resolveXml(beanDesc.getClassInfo(), annotatedType.getCtxAnnotations(), resolvedSchemaAnnotation);
        if (xml != null) {
            model.xml(xml);
        }
        applyBeanValidatorAnnotations(model, annotatedType.getCtxAnnotations(), null);
        resolveSchemaMembers(model, annotatedType);
        if (resolvedArrayAnnotation != null) {
            ArraySchema schema = new ArraySchema();
            resolveArraySchema(annotatedType, schema, resolvedArrayAnnotation);
            schema.setItems(model);
            return schema;
        }
        if (type.isEnumType() && shouldResolveEnumAsRef(resolvedSchemaAnnotation)) {
            // Store off the ref and add the enum as a top-level model
            context.defineModel(name, model, annotatedType, null);
            // Return the model as a ref only property
            model = new Schema().$ref(Components.COMPONENTS_SCHEMAS_REF + name);
        }
        return model;
    }
    /**
     * --Preventing parent/child hierarchy creation loops - Comment 1--
     * Creating a parent model will result in the creation of child models. Creating a child model will result in
     * the creation of a parent model, as per the second If statement following this comment.
     *
     * By checking whether a model has already been resolved (as implemented below), loops of parents creating
     * children and children creating parents can be short-circuited. This works because currently the
     * ModelConverterContextImpl will return null for a class that already been processed, but has not yet been
     * defined. This logic works in conjunction with the early immediate definition of model in the context
     * implemented later in this method (See "Preventing parent/child hierarchy creation loops - Comment 2") to
     * prevent such
     */
    Schema resolvedModel = context.resolve(annotatedType);
    if (resolvedModel != null) {
        if (name != null && name.equals(resolvedModel.getName())) {
            return resolvedModel;
        }
    }
    Type jsonValueType = findJsonValueType(beanDesc);
    if (jsonValueType != null) {
        AnnotatedType aType = new AnnotatedType().type(jsonValueType).parent(annotatedType.getParent()).name(annotatedType.getName()).schemaProperty(annotatedType.isSchemaProperty()).resolveAsRef(annotatedType.isResolveAsRef()).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()).propertyName(annotatedType.getPropertyName()).ctxAnnotations(annotatedType.getCtxAnnotations()).skipOverride(true);
        return context.resolve(aType);
    }
    List<Class<?>> composedSchemaReferencedClasses = getComposedSchemaReferencedClasses(type.getRawClass(), annotatedType.getCtxAnnotations(), resolvedSchemaAnnotation);
    boolean isComposedSchema = composedSchemaReferencedClasses != null;
    if (type.isContainerType()) {
        // TODO currently a MapSchema or ArraySchema don't also support composed schema props (oneOf,..)
        isComposedSchema = false;
        JavaType keyType = type.getKeyType();
        JavaType valueType = type.getContentType();
        String pName = null;
        if (valueType != null) {
            BeanDescription valueTypeBeanDesc = _mapper.getSerializationConfig().introspect(valueType);
            pName = _typeName(valueType, valueTypeBeanDesc);
        }
        Annotation[] schemaAnnotations = null;
        if (resolvedSchemaAnnotation != null) {
            schemaAnnotations = new Annotation[] { resolvedSchemaAnnotation };
        }
        if (keyType != null && valueType != null) {
            if (ReflectionUtils.isSystemType(type) && !annotatedType.isSchemaProperty() && !annotatedType.isResolveAsRef()) {
                context.resolve(new AnnotatedType().type(valueType).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()));
                return null;
            }
            Schema addPropertiesSchema = context.resolve(new AnnotatedType().type(valueType).schemaProperty(annotatedType.isSchemaProperty()).ctxAnnotations(schemaAnnotations).skipSchemaName(true).resolveAsRef(annotatedType.isResolveAsRef()).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()).propertyName(annotatedType.getPropertyName()).parent(annotatedType.getParent()));
            if (addPropertiesSchema != null) {
                if (StringUtils.isNotBlank(addPropertiesSchema.getName())) {
                    pName = addPropertiesSchema.getName();
                }
                if ("object".equals(addPropertiesSchema.getType()) && pName != null) {
                    // create a reference for the items
                    if (context.getDefinedModels().containsKey(pName)) {
                        addPropertiesSchema = new Schema().$ref(constructRef(pName));
                    }
                } else if (addPropertiesSchema.get$ref() != null) {
                    addPropertiesSchema = new Schema().$ref(StringUtils.isNotEmpty(addPropertiesSchema.get$ref()) ? addPropertiesSchema.get$ref() : addPropertiesSchema.getName());
                }
            }
            Schema mapModel = new MapSchema().additionalProperties(addPropertiesSchema);
            mapModel.name(name);
            model = mapModel;
        // return model;
        } else if (valueType != null) {
            if (ReflectionUtils.isSystemType(type) && !annotatedType.isSchemaProperty() && !annotatedType.isResolveAsRef()) {
                context.resolve(new AnnotatedType().type(valueType).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()));
                return null;
            }
            Schema items = context.resolve(new AnnotatedType().type(valueType).schemaProperty(annotatedType.isSchemaProperty()).ctxAnnotations(schemaAnnotations).skipSchemaName(true).resolveAsRef(annotatedType.isResolveAsRef()).propertyName(annotatedType.getPropertyName()).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()).parent(annotatedType.getParent()));
            if (items == null) {
                return null;
            }
            if (annotatedType.isSchemaProperty() && annotatedType.getCtxAnnotations() != null && annotatedType.getCtxAnnotations().length > 0) {
                if (!"object".equals(items.getType())) {
                    for (Annotation annotation : annotatedType.getCtxAnnotations()) {
                        if (annotation instanceof XmlElement) {
                            XmlElement xmlElement = (XmlElement) annotation;
                            if (xmlElement != null && xmlElement.name() != null && !"".equals(xmlElement.name()) && !JAXB_DEFAULT.equals(xmlElement.name())) {
                                XML xml = items.getXml() != null ? items.getXml() : new XML();
                                xml.setName(xmlElement.name());
                                items.setXml(xml);
                            }
                        }
                    }
                }
            }
            if (StringUtils.isNotBlank(items.getName())) {
                pName = items.getName();
            }
            if ("object".equals(items.getType()) && pName != null) {
                // create a reference for the items
                if (context.getDefinedModels().containsKey(pName)) {
                    items = new Schema().$ref(constructRef(pName));
                }
            } else if (items.get$ref() != null) {
                items = new Schema().$ref(StringUtils.isNotEmpty(items.get$ref()) ? items.get$ref() : items.getName());
            }
            Schema arrayModel = new ArraySchema().items(items);
            if (_isSetType(type.getRawClass())) {
                arrayModel.setUniqueItems(true);
            }
            arrayModel.name(name);
            model = arrayModel;
        } else {
            if (ReflectionUtils.isSystemType(type) && !annotatedType.isSchemaProperty() && !annotatedType.isResolveAsRef()) {
                return null;
            }
        }
    } else if (isComposedSchema) {
        model = new ComposedSchema().type("object").name(name);
    } else {
        AnnotatedType aType = OptionalUtils.unwrapOptional(annotatedType);
        if (aType != null) {
            model = context.resolve(aType);
            return model;
        } else {
            model = new Schema().type("object").name(name);
        }
    }
    if (!type.isContainerType() && StringUtils.isNotBlank(name)) {
        // define the model here to support self/cyclic referencing of models
        context.defineModel(name, model, annotatedType, null);
    }
    XML xml = resolveXml(beanDesc.getClassInfo(), annotatedType.getCtxAnnotations(), resolvedSchemaAnnotation);
    if (xml != null) {
        model.xml(xml);
    }
    if (!(model instanceof ArraySchema) || (model instanceof ArraySchema && resolvedArrayAnnotation == null)) {
        resolveSchemaMembers(model, annotatedType);
    }
    final XmlAccessorType xmlAccessorTypeAnnotation = beanDesc.getClassAnnotations().get(XmlAccessorType.class);
    // see if @JsonIgnoreProperties exist
    Set<String> propertiesToIgnore = resolveIgnoredProperties(beanDesc.getClassAnnotations(), annotatedType.getCtxAnnotations());
    List<Schema> props = new ArrayList<>();
    Map<String, Schema> modelProps = new LinkedHashMap<>();
    List<BeanPropertyDefinition> properties = beanDesc.findProperties();
    List<String> ignoredProps = getIgnoredProperties(beanDesc);
    properties.removeIf(p -> ignoredProps.contains(p.getName()));
    for (BeanPropertyDefinition propDef : properties) {
        Schema property = null;
        String propName = propDef.getName();
        Annotation[] annotations = null;
        AnnotatedMember member = propDef.getPrimaryMember();
        if (member == null) {
            final BeanDescription deserBeanDesc = _mapper.getDeserializationConfig().introspect(type);
            List<BeanPropertyDefinition> deserProperties = deserBeanDesc.findProperties();
            for (BeanPropertyDefinition prop : deserProperties) {
                if (StringUtils.isNotBlank(prop.getInternalName()) && prop.getInternalName().equals(propDef.getInternalName())) {
                    member = prop.getPrimaryMember();
                    break;
                }
            }
        }
        // it's ugly but gets around https://github.com/swagger-api/swagger-core/issues/415
        if (propDef.getPrimaryMember() != null) {
            final JsonProperty jsonPropertyAnn = propDef.getPrimaryMember().getAnnotation(JsonProperty.class);
            if (jsonPropertyAnn == null || !jsonPropertyAnn.value().equals(propName)) {
                if (member != null) {
                    java.lang.reflect.Member innerMember = member.getMember();
                    if (innerMember != null) {
                        String altName = innerMember.getName();
                        if (altName != null) {
                            final int length = altName.length();
                            for (String prefix : Arrays.asList("get", "is")) {
                                final int offset = prefix.length();
                                if (altName.startsWith(prefix) && length > offset && !Character.isUpperCase(altName.charAt(offset))) {
                                    propName = altName;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        PropertyMetadata md = propDef.getMetadata();
        if (member != null && !ignore(member, xmlAccessorTypeAnnotation, propName, propertiesToIgnore, propDef)) {
            List<Annotation> annotationList = new ArrayList<>();
            AnnotationMap annotationMap = member.getAllAnnotations();
            if (annotationMap != null) {
                for (Annotation a : annotationMap.annotations()) {
                    annotationList.add(a);
                }
            }
            annotations = annotationList.toArray(new Annotation[annotationList.size()]);
            if (hiddenByJsonView(annotations, annotatedType)) {
                continue;
            }
            JavaType propType = member.getType();
            if (propType != null && "void".equals(propType.getRawClass().getName())) {
                if (member instanceof AnnotatedMethod) {
                    propType = ((AnnotatedMethod) member).getParameterType(0);
                }
            }
            String propSchemaName = null;
            io.swagger.v3.oas.annotations.media.Schema ctxSchema = AnnotationsUtils.getSchemaAnnotation(annotations);
            if (AnnotationsUtils.hasSchemaAnnotation(ctxSchema)) {
                if (!StringUtils.isBlank(ctxSchema.name())) {
                    propSchemaName = ctxSchema.name();
                }
            }
            if (propSchemaName == null) {
                io.swagger.v3.oas.annotations.media.ArraySchema ctxArraySchema = AnnotationsUtils.getArraySchemaAnnotation(annotations);
                if (AnnotationsUtils.hasArrayAnnotation(ctxArraySchema)) {
                    if (AnnotationsUtils.hasSchemaAnnotation(ctxArraySchema.schema())) {
                        if (!StringUtils.isBlank(ctxArraySchema.schema().name())) {
                            propSchemaName = ctxArraySchema.schema().name();
                        }
                    }
                }
            }
            if (StringUtils.isNotBlank(propSchemaName)) {
                propName = propSchemaName;
            }
            Annotation propSchemaOrArray = AnnotationsUtils.mergeSchemaAnnotations(annotations, propType);
            final io.swagger.v3.oas.annotations.media.Schema propResolvedSchemaAnnotation = propSchemaOrArray == null ? null : propSchemaOrArray instanceof io.swagger.v3.oas.annotations.media.ArraySchema ? ((io.swagger.v3.oas.annotations.media.ArraySchema) propSchemaOrArray).schema() : (io.swagger.v3.oas.annotations.media.Schema) propSchemaOrArray;
            io.swagger.v3.oas.annotations.media.Schema.AccessMode accessMode = resolveAccessMode(propDef, type, propResolvedSchemaAnnotation);
            AnnotatedType aType = new AnnotatedType().type(propType).ctxAnnotations(annotations).parent(model).resolveAsRef(annotatedType.isResolveAsRef()).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()).skipSchemaName(true).schemaProperty(true).propertyName(propName);
            final AnnotatedMember propMember = member;
            aType.jsonUnwrappedHandler(t -> {
                JsonUnwrapped uw = propMember.getAnnotation(JsonUnwrapped.class);
                if (uw != null && uw.enabled()) {
                    t.ctxAnnotations(null).jsonUnwrappedHandler(null).resolveAsRef(false);
                    handleUnwrapped(props, context.resolve(t), uw.prefix(), uw.suffix(), requiredProps);
                    return null;
                } else {
                    return new Schema();
                // t.jsonUnwrappedHandler(null);
                // return context.resolve(t);
                }
            });
            property = clone(context.resolve(aType));
            if (property != null) {
                Boolean required = md.getRequired();
                if (required != null && !Boolean.FALSE.equals(required)) {
                    addRequiredItem(model, propName);
                } else {
                    if (propDef.isRequired()) {
                        addRequiredItem(model, propName);
                    }
                }
                if (property.get$ref() == null) {
                    if (accessMode != null) {
                        switch(accessMode) {
                            case AUTO:
                                break;
                            case READ_ONLY:
                                property.readOnly(true);
                                break;
                            case READ_WRITE:
                                break;
                            case WRITE_ONLY:
                                property.writeOnly(true);
                                break;
                            default:
                        }
                    }
                }
                final BeanDescription propBeanDesc = _mapper.getSerializationConfig().introspect(propType);
                if (property != null && !propType.isContainerType()) {
                    if ("object".equals(property.getType())) {
                        // create a reference for the property
                        String pName = _typeName(propType, propBeanDesc);
                        if (StringUtils.isNotBlank(property.getName())) {
                            pName = property.getName();
                        }
                        if (context.getDefinedModels().containsKey(pName)) {
                            property = new Schema().$ref(constructRef(pName));
                        }
                    } else if (property.get$ref() != null) {
                        property = new Schema().$ref(StringUtils.isNotEmpty(property.get$ref()) ? property.get$ref() : property.getName());
                    }
                }
                property.setName(propName);
                JAXBAnnotationsHelper.apply(propBeanDesc.getClassInfo(), annotations, property);
                applyBeanValidatorAnnotations(property, annotations, model);
                props.add(property);
            }
        }
    }
    for (Schema prop : props) {
        modelProps.put(prop.getName(), prop);
    }
    if (modelProps.size() > 0) {
        model.setProperties(modelProps);
        for (String propName : requiredProps) {
            addRequiredItem(model, propName);
        }
    }
    /**
     * --Preventing parent/child hierarchy creation loops - Comment 2--
     * Creating a parent model will result in the creation of child models, as per the first If statement following
     * this comment. Creating a child model will result in the creation of a parent model, as per the second If
     * statement following this comment.
     *
     * The current model must be defined in the context immediately. This done to help prevent repeated
     * loops where  parents create children and children create parents when a hierarchy is present. This logic
     * works in conjunction with the "early checking" performed earlier in this method
     * (See "Preventing parent/child hierarchy creation loops - Comment 1"), to prevent repeated creation loops.
     *
     * As an aside, defining the current model in the context immediately also ensures that child models are
     * available for modification by resolveSubtypes, when their parents are created.
     */
    if (!type.isContainerType() && StringUtils.isNotBlank(name)) {
        context.defineModel(name, model, annotatedType, null);
    }
    /**
     * This must be done after model.setProperties so that the model's set
     * of properties is available to filter from any subtypes
     */
    if (!resolveSubtypes(model, beanDesc, context)) {
        model.setDiscriminator(null);
    }
    Discriminator discriminator = resolveDiscriminator(type, context);
    if (discriminator != null) {
        model.setDiscriminator(discriminator);
    }
    if (resolvedSchemaAnnotation != null) {
        String ref = resolvedSchemaAnnotation.ref();
        // consider ref as is
        if (!StringUtils.isBlank(ref)) {
            model.$ref(ref);
        }
        Class<?> not = resolvedSchemaAnnotation.not();
        if (!Void.class.equals(not)) {
            model.not((new Schema().$ref(context.resolve(new AnnotatedType().type(not).jsonViewAnnotation(annotatedType.getJsonViewAnnotation())).getName())));
        }
        if (resolvedSchemaAnnotation.requiredProperties() != null && resolvedSchemaAnnotation.requiredProperties().length > 0 && StringUtils.isNotBlank(resolvedSchemaAnnotation.requiredProperties()[0])) {
            for (String prop : resolvedSchemaAnnotation.requiredProperties()) {
                addRequiredItem(model, prop);
            }
        }
    }
    Map<String, Schema> patternProperties = resolvePatternProperties(type, annotatedType.getCtxAnnotations(), context);
    if (model != null && patternProperties != null && !patternProperties.isEmpty()) {
        if (model.getPatternProperties() == null) {
            model.patternProperties(patternProperties);
        } else {
            model.getPatternProperties().putAll(patternProperties);
        }
    }
    Map<String, Schema> schemaProperties = resolveSchemaProperties(type, annotatedType.getCtxAnnotations(), context);
    if (model != null && schemaProperties != null && !schemaProperties.isEmpty()) {
        if (model.getProperties() == null) {
            model.properties(schemaProperties);
        } else {
            model.getProperties().putAll(schemaProperties);
        }
    }
    if (isComposedSchema) {
        ComposedSchema composedSchema = (ComposedSchema) model;
        Class<?>[] allOf = resolvedSchemaAnnotation.allOf();
        Class<?>[] anyOf = resolvedSchemaAnnotation.anyOf();
        Class<?>[] oneOf = resolvedSchemaAnnotation.oneOf();
        List<Class<?>> allOfFiltered = Stream.of(allOf).distinct().filter(c -> !this.shouldIgnoreClass(c)).filter(c -> !(c.equals(Void.class))).collect(Collectors.toList());
        allOfFiltered.forEach(c -> {
            Schema allOfRef = context.resolve(new AnnotatedType().type(c).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()));
            Schema refSchema = new Schema().$ref(allOfRef.getName());
            // allOf could have already being added during subtype resolving
            if (composedSchema.getAllOf() == null || !composedSchema.getAllOf().contains(refSchema)) {
                composedSchema.addAllOfItem(refSchema);
            }
            // remove shared properties defined in the parent
            if (isSubtype(beanDesc.getClassInfo(), c)) {
                removeParentProperties(composedSchema, allOfRef);
            }
        });
        List<Class<?>> anyOfFiltered = Stream.of(anyOf).distinct().filter(c -> !this.shouldIgnoreClass(c)).filter(c -> !(c.equals(Void.class))).collect(Collectors.toList());
        anyOfFiltered.forEach(c -> {
            Schema anyOfRef = context.resolve(new AnnotatedType().type(c).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()));
            composedSchema.addAnyOfItem(new Schema().$ref(anyOfRef.getName()));
            // remove shared properties defined in the parent
            if (isSubtype(beanDesc.getClassInfo(), c)) {
                removeParentProperties(composedSchema, anyOfRef);
            }
        });
        List<Class<?>> oneOfFiltered = Stream.of(oneOf).distinct().filter(c -> !this.shouldIgnoreClass(c)).filter(c -> !(c.equals(Void.class))).collect(Collectors.toList());
        oneOfFiltered.forEach(c -> {
            Schema oneOfRef = context.resolve(new AnnotatedType().type(c).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()));
            if (oneOfRef != null) {
                if (StringUtils.isBlank(oneOfRef.getName())) {
                    composedSchema.addOneOfItem(oneOfRef);
                } else {
                    composedSchema.addOneOfItem(new Schema().$ref(oneOfRef.getName()));
                }
                // remove shared properties defined in the parent
                if (isSubtype(beanDesc.getClassInfo(), c)) {
                    removeParentProperties(composedSchema, oneOfRef);
                }
            }
        });
        if (!composedModelPropertiesAsSibling) {
            if (composedSchema.getAllOf() != null && !composedSchema.getAllOf().isEmpty()) {
                if (composedSchema.getProperties() != null && !composedSchema.getProperties().isEmpty()) {
                    ObjectSchema propSchema = new ObjectSchema();
                    propSchema.properties(composedSchema.getProperties());
                    composedSchema.setProperties(null);
                    composedSchema.addAllOfItem(propSchema);
                }
            }
        }
    }
    if (!type.isContainerType() && StringUtils.isNotBlank(name)) {
        // define the model here to support self/cyclic referencing of models
        context.defineModel(name, model, annotatedType, null);
    }
    if (model != null && annotatedType.isResolveAsRef() && (isComposedSchema || "object".equals(model.getType())) && StringUtils.isNotBlank(model.getName())) {
        if (context.getDefinedModels().containsKey(model.getName())) {
            model = new Schema().$ref(constructRef(model.getName()));
        }
    } else if (model != null && model.get$ref() != null) {
        model = new Schema().$ref(StringUtils.isNotEmpty(model.get$ref()) ? model.get$ref() : model.getName());
    }
    if (model != null && resolvedArrayAnnotation != null) {
        if (!"array".equals(model.getType())) {
            ArraySchema schema = new ArraySchema();
            schema.setItems(model);
            resolveArraySchema(annotatedType, schema, resolvedArrayAnnotation);
            return schema;
        } else {
            if (model instanceof ArraySchema) {
                resolveArraySchema(annotatedType, (ArraySchema) model, resolvedArrayAnnotation);
            }
        }
    }
    resolveDiscriminatorProperty(type, context, model);
    model = resolveWrapping(type, context, model);
    return model;
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) UUIDSchema(io.swagger.v3.oas.models.media.UUIDSchema) Size(javax.validation.constraints.Size) Arrays(java.util.Arrays) JsonView(com.fasterxml.jackson.annotation.JsonView) AnnotationIntrospector(com.fasterxml.jackson.databind.AnnotationIntrospector) DiscriminatorMapping(io.swagger.v3.oas.annotations.media.DiscriminatorMapping) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) XmlElementRef(javax.xml.bind.annotation.XmlElementRef) ObjectMapperFactory(io.swagger.v3.core.util.ObjectMapperFactory) PropertyMetadata(com.fasterxml.jackson.databind.PropertyMetadata) ComposedSchema(io.swagger.v3.oas.models.media.ComposedSchema) POJOPropertyBuilder(com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder) AnnotationsUtils(io.swagger.v3.core.util.AnnotationsUtils) PatternProperties(io.swagger.v3.oas.annotations.media.PatternProperties) BigDecimal(java.math.BigDecimal) JsonValue(com.fasterxml.jackson.annotation.JsonValue) RefUtils.constructRef(io.swagger.v3.core.util.RefUtils.constructRef) Map(java.util.Map) AnnotatedMember(com.fasterxml.jackson.databind.introspect.AnnotatedMember) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) Max(javax.validation.constraints.Max) BeanDescription(com.fasterxml.jackson.databind.BeanDescription) Method(java.lang.reflect.Method) XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) Hidden(io.swagger.v3.oas.annotations.Hidden) Collection(java.util.Collection) Set(java.util.Set) IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) Min(javax.validation.constraints.Min) Collectors(java.util.stream.Collectors) AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) ExternalDocumentation(io.swagger.v3.oas.models.ExternalDocumentation) XML(io.swagger.v3.oas.models.media.XML) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) InvocationTargetException(java.lang.reflect.InvocationTargetException) JsonIdentityReference(com.fasterxml.jackson.annotation.JsonIdentityReference) List(java.util.List) Stream(java.util.stream.Stream) JsonTypeInfo(com.fasterxml.jackson.annotation.JsonTypeInfo) AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass) StringSchema(io.swagger.v3.oas.models.media.StringSchema) XmlElementRefs(javax.xml.bind.annotation.XmlElementRefs) Type(java.lang.reflect.Type) SchemaProperties(io.swagger.v3.oas.annotations.media.SchemaProperties) JsonUnwrapped(com.fasterxml.jackson.annotation.JsonUnwrapped) Pattern(javax.validation.constraints.Pattern) Annotation(java.lang.annotation.Annotation) Optional(java.util.Optional) PatternProperty(io.swagger.v3.oas.annotations.media.PatternProperty) ObjectSchema(io.swagger.v3.oas.models.media.ObjectSchema) JAXB_DEFAULT(io.swagger.v3.core.jackson.JAXBAnnotationsHelper.JAXB_DEFAULT) JsonIgnoreProperties(com.fasterxml.jackson.annotation.JsonIgnoreProperties) AnnotationMap(com.fasterxml.jackson.databind.introspect.AnnotationMap) ModelConverter(io.swagger.v3.core.converter.ModelConverter) Json(io.swagger.v3.core.util.Json) OptionalUtils(io.swagger.v3.core.util.OptionalUtils) DecimalMin(javax.validation.constraints.DecimalMin) HashMap(java.util.HashMap) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Annotations(com.fasterxml.jackson.databind.util.Annotations) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) JsonSerialize(com.fasterxml.jackson.databind.annotation.JsonSerialize) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) PrimitiveType(io.swagger.v3.core.util.PrimitiveType) Schema(io.swagger.v3.oas.models.media.Schema) JavaType(com.fasterxml.jackson.databind.JavaType) AnnotatedMethod(com.fasterxml.jackson.databind.introspect.AnnotatedMethod) XmlAttribute(javax.xml.bind.annotation.XmlAttribute) Discriminator(io.swagger.v3.oas.models.media.Discriminator) Logger(org.slf4j.Logger) JsonIdentityInfo(com.fasterxml.jackson.annotation.JsonIdentityInfo) Iterator(java.util.Iterator) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MapSchema(io.swagger.v3.oas.models.media.MapSchema) IOException(java.io.IOException) ObjectIdGenerator(com.fasterxml.jackson.annotation.ObjectIdGenerator) XmlRootElement(javax.xml.bind.annotation.XmlRootElement) SchemaProperty(io.swagger.v3.oas.annotations.media.SchemaProperty) Constants(io.swagger.v3.core.util.Constants) ReflectionUtils(io.swagger.v3.core.util.ReflectionUtils) Annotated(com.fasterxml.jackson.databind.introspect.Annotated) ModelConverterContext(io.swagger.v3.core.converter.ModelConverterContext) DecimalMax(javax.validation.constraints.DecimalMax) Components(io.swagger.v3.oas.models.Components) NumberUtils(org.apache.commons.lang3.math.NumberUtils) ObjectIdGenerators(com.fasterxml.jackson.annotation.ObjectIdGenerators) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) BeanPropertyDefinition(com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition) Collections(java.util.Collections) XmlElement(javax.xml.bind.annotation.XmlElement) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) UUIDSchema(io.swagger.v3.oas.models.media.UUIDSchema) ComposedSchema(io.swagger.v3.oas.models.media.ComposedSchema) IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) StringSchema(io.swagger.v3.oas.models.media.StringSchema) ObjectSchema(io.swagger.v3.oas.models.media.ObjectSchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) Schema(io.swagger.v3.oas.models.media.Schema) MapSchema(io.swagger.v3.oas.models.media.MapSchema) ArrayList(java.util.ArrayList) AnnotatedMember(com.fasterxml.jackson.databind.introspect.AnnotatedMember) LinkedHashMap(java.util.LinkedHashMap) JsonSerialize(com.fasterxml.jackson.databind.annotation.JsonSerialize) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) ObjectSchema(io.swagger.v3.oas.models.media.ObjectSchema) PropertyMetadata(com.fasterxml.jackson.databind.PropertyMetadata) PrimitiveType(io.swagger.v3.core.util.PrimitiveType) StringSchema(io.swagger.v3.oas.models.media.StringSchema) MapSchema(io.swagger.v3.oas.models.media.MapSchema) HashSet(java.util.HashSet) BeanDescription(com.fasterxml.jackson.databind.BeanDescription) JsonIdentityReference(com.fasterxml.jackson.annotation.JsonIdentityReference) JavaType(com.fasterxml.jackson.databind.JavaType) AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass) AnnotatedMethod(com.fasterxml.jackson.databind.introspect.AnnotatedMethod) AnnotationMap(com.fasterxml.jackson.databind.introspect.AnnotationMap) BeanPropertyDefinition(com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition) ComposedSchema(io.swagger.v3.oas.models.media.ComposedSchema) JsonUnwrapped(com.fasterxml.jackson.annotation.JsonUnwrapped) Annotation(java.lang.annotation.Annotation) Discriminator(io.swagger.v3.oas.models.media.Discriminator) JsonIdentityInfo(com.fasterxml.jackson.annotation.JsonIdentityInfo) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) Type(java.lang.reflect.Type) PrimitiveType(io.swagger.v3.core.util.PrimitiveType) JavaType(com.fasterxml.jackson.databind.JavaType) XML(io.swagger.v3.oas.models.media.XML) XmlElement(javax.xml.bind.annotation.XmlElement)

Aggregations

StringUtils (org.apache.commons.lang3.StringUtils)42 List (java.util.List)31 Map (java.util.Map)28 Collectors (java.util.stream.Collectors)21 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)19 IOException (java.io.IOException)17 LoggerFactory (org.slf4j.LoggerFactory)15 Set (java.util.Set)14 Autowired (org.springframework.beans.factory.annotation.Autowired)14 Logger (org.slf4j.Logger)13 Collections (java.util.Collections)12 HashSet (java.util.HashSet)12 Optional (java.util.Optional)12 Arrays (java.util.Arrays)11 File (java.io.File)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 java.util (java.util)7 Collection (java.util.Collection)7 Pattern (java.util.regex.Pattern)7