Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import io.swagger.v3.oas.models.servers.Server;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.annotations.RouterOperations;
Expand Down Expand Up @@ -556,8 +557,9 @@ protected void calculateWebhooks(OpenAPI calculatedOpenAPI, Locale locale) {
.filter(clazz -> isPackageToScan(clazz.getPackage()))
.toArray(Class<?>[]::new);
Webhooks[] webhooksAttr = openAPIService.getWebhooks(refinedClasses);
if (ArrayUtils.isEmpty(webhooksAttr))
if (ArrayUtils.isEmpty(webhooksAttr)) {
return;
}
var webhooks = Arrays.stream(webhooksAttr).map(Webhooks::value).flatMap(Arrays::stream).toArray(Webhook[]::new);
Arrays.stream(webhooks).forEach(webhook -> {
io.swagger.v3.oas.annotations.Operation apiOperation = webhook.operation();
Expand Down Expand Up @@ -683,7 +685,7 @@ protected void calculatePath(HandlerMethod handlerMethod, RouterOperation router
// allow for customisation
operation = customizeOperation(operation, components, handlerMethod);

if (StringUtils.contains(operationPath, "*")) {
if (Strings.CS.contains(operationPath, "*")) {
Matcher matcher = pathPattern.matcher(operationPath);
while (matcher.find()) {
String pathParam = matcher.group(1);
Expand Down Expand Up @@ -1297,7 +1299,7 @@ private PathItem buildPathItem(RequestMethod requestMethod, Operation operation,
if (ParameterIn.PATH.toString().equals(parameter.getIn())) {
// check it's present in the path
String name = parameter.getName();
if (!StringUtils.containsAny(operationPath, "{" + name + "}", "{*" + name + "}"))
if (!Strings.CS.containsAny(operationPath, "{" + name + "}", "{*" + name + "}"))
paramIt.remove();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import io.swagger.v3.core.converter.ModelConverter;
import io.swagger.v3.core.converter.ModelConverterContext;
import io.swagger.v3.oas.models.media.Schema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.providers.ObjectMapperProvider;

import static org.springdoc.core.utils.SpringDocUtils.cloneViaJson;
Expand Down Expand Up @@ -65,11 +63,6 @@ public class AdditionalModelsConverter implements ModelConverter {
*/
private static final Map<Class, Class> paramObjectReplacementMap = new HashMap<>();

/**
* The constant LOGGER.
*/
private static final Logger LOGGER = LoggerFactory.getLogger(AdditionalModelsConverter.class);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* The Spring doc object mapper.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,13 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato
private Schema composePolymorphicSchema(AnnotatedType type, Schema schema, Collection<Schema> schemas) {
String ref = schema.get$ref();
List<Schema> composedSchemas = findComposedSchemas(ref, schemas);
if (composedSchemas.isEmpty()) return schema;
if (composedSchemas.isEmpty()) {
return schema;
}
ComposedSchema result = new ComposedSchema();
if (isConcreteClass(type)) result.addOneOfItem(schema);
if (isConcreteClass(type)) {
result.addOneOfItem(schema);
}
JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType());
Class<?> clazz = javaType.getRawClass();
if (TYPES_TO_SKIP.stream().noneMatch(typeToSkip -> typeToSkip.equals(clazz.getSimpleName())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
import org.springframework.data.querydsl.binding.QuerydslBindings;
import org.springframework.data.querydsl.binding.QuerydslBindingsFactory;
import org.springframework.data.querydsl.binding.QuerydslPredicate;
import org.springframework.data.util.CastUtils;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.CollectionUtils;
import org.springframework.web.method.HandlerMethod;
Expand Down Expand Up @@ -174,12 +172,12 @@ private boolean getFieldValueOfBoolean(QuerydslBindings instance, String fieldNa
* @return the querydsl bindings
*/
private QuerydslBindings extractQdslBindings(QuerydslPredicate predicate) {
ClassTypeInformation<?> classTypeInformation = ClassTypeInformation.from(predicate.root());
TypeInformation<?> domainType = classTypeInformation.getRequiredActualType();
TypeInformation<?> typeInformation = TypeInformation.of(predicate.root());
TypeInformation<?> domainType = typeInformation.getRequiredActualType();

Optional<Class<? extends QuerydslBinderCustomizer<?>>> bindingsAnnotation = Optional.of(predicate)
.map(QuerydslPredicate::bindings)
.map(CastUtils::cast);
.map(binder -> (Class<? extends QuerydslBinderCustomizer<?>>) binder);

return bindingsAnnotation
.map(it -> querydslBindingsFactory.createBindingsFor(domainType, it))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,7 @@ private void setHeaders(String[] headers) {
}
else {
String key = header.substring(0, neqIdx);
if (!this.headers.containsKey(key))
this.headers.put(key, StringUtils.EMPTY);
this.headers.putIfAbsent(key, StringUtils.EMPTY);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,7 @@ private Map<String, ApiResponse> getGenericMapResponse(HandlerMethod handlerMeth
}

if (addToGenericMap || exceptions.isEmpty()) {
methodAdviceInfo.getApiResponses().forEach((key, apiResponse) ->
genericApiResponseMap.putIfAbsent(key, apiResponse));
methodAdviceInfo.getApiResponses().forEach(genericApiResponseMap::putIfAbsent);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

package org.springdoc.core.service;

import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -256,7 +255,7 @@ public Optional<RequestBody> buildRequestBodyFromDoc(
*/
public void calculateRequestBodyInfo(Components components, MethodAttributes methodAttributes,
ParameterInfo parameterInfo, RequestBodyInfo requestBodyInfo) {
RequestBody requestBody = requestBodyInfo.getRequestBody();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RequestBody requestBody;
MethodParameter methodParameter = parameterInfo.getMethodParameter();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ private static boolean ctorParamHasAnyAnnotationSimpleName(Field f, Collection<S
}
}
}
} catch (Throwable ignored) {
} catch (Exception ignored) {
// best-effort only
}
return false;
Expand Down Expand Up @@ -525,7 +525,7 @@ private static boolean hasJsonPropertyName(java.lang.reflect.Parameter p, String
try {
JsonProperty jp = p.getAnnotation(JsonProperty.class);
return jp != null && expected.equals(jp.value());
} catch (Throwable ignored) {
} catch (Exception ignored) {
return false;
}
}
Expand All @@ -545,7 +545,9 @@ private static Method findGetter(Field f) {
for (String m : names) {
try {
return f.getDeclaringClass().getMethod(m);
} catch (NoSuchMethodException ignored) {}
} catch (NoSuchMethodException ignored) {
// best-effort only
}
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,10 @@ public static Optional<Map<String, Header>> getHeaders(io.swagger.v3.oas.annotat
* @param javadocProvider the javadoc provider
*/
public static void clearCache(JavadocProvider javadocProvider) {
if (javadocProvider != null)
if (javadocProvider != null) {
javadocProvider.clearCache();
MODEL_CONVERTER_CONTEXT_MAP.remove();;
}
MODEL_CONVERTER_CONTEXT_MAP.remove();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ private static Boolean kotlinMarkedNullableFallback(Field f) {
return p.getReturnType().isMarkedNullable();
}
}
} catch (Throwable ignored) {}
} catch (Exception ignored) {
// best-effort only
}
return null;
}

Expand All @@ -94,7 +96,9 @@ static Boolean kotlinConstructorParamIsOptional(Field f) {
}
}
}
} catch (Throwable ignored) {}
} catch (Exception ignored) {
// best-effort only
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;

Expand Down Expand Up @@ -231,7 +232,7 @@ public static void removeNullKeyProperties(Schema<?> schema) {
if (schema == null || schema.getProperties() == null) {
return;
}
schema.getProperties().keySet().removeIf(key -> key == null);
schema.getProperties().keySet().removeIf(Objects::isNull);
schema.getProperties().values().forEach(SpringDocUtils::removeNullKeyProperties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ protected void calculateOauth2RedirectUrl(SwaggerUiConfigParameters swaggerUiCon
}
}

@Override
protected void calculateUiRootPath(SwaggerUiConfigParameters swaggerUiConfigParameters, StringBuilder... sbUrls) {
super.calculateUiRootPath(swaggerUiConfigParameters, sbUrls);
}

/**
* Gets swagger ui config.
*
Expand All @@ -106,6 +101,11 @@ protected Map<String, Object> getSwaggerUiConfig(ServerWebExchange exchange) {
return swaggerUiConfigParameters.getConfigParameters();
}

@Override
protected void calculateUiRootPath(SwaggerUiConfigParameters swaggerUiConfigParameters, StringBuilder... sbUrls) {
super.calculateUiRootPath(swaggerUiConfigParameters, sbUrls);
}

/**
* From current context path string.
*
Expand Down
Loading