Skip to content

Commit 5355de6

Browse files
authored
Merge pull request #1672 from altro3/improvements-by-swagger
Minor improvements by swagger issues
2 parents 2eeb3f2 + 85c20b8 commit 5355de6

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

openapi-common/src/main/java/io/micronaut/openapi/OpenApiUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package io.micronaut.openapi;
1717

18+
import com.fasterxml.jackson.core.JsonParser;
1819
import com.fasterxml.jackson.databind.DeserializationFeature;
1920
import com.fasterxml.jackson.databind.ObjectMapper;
2021
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -33,20 +34,23 @@ public final class OpenApiUtils {
3334
* The JSON mapper.
3435
*/
3536
public static final ObjectMapper JSON_MAPPER = ObjectMapperFactory.createJson()
36-
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
37+
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
38+
.enable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
3739
/**
3840
* The JSON 3.1 mapper.
3941
*/
4042
public static final ObjectMapper JSON_MAPPER_31 = ObjectMapperFactory.createJson31()
41-
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
43+
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
44+
.enable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
4245
/**
4346
* The JSON mapper for security scheme.
4447
*/
4548
public static final ObjectMapper CONVERT_JSON_MAPPER = ObjectMapperFactory.buildStrictGenericObjectMapper()
4649
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
4750
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS, SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
4851
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
49-
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING, DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
52+
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING, DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
53+
.enable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
5054
/**
5155
* The YAML mapper.
5256
*/

openapi/src/main/java/io/micronaut/openapi/visitor/SchemaDefinitionUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.micronaut.openapi.visitor;
1717

1818
import com.fasterxml.jackson.annotation.JsonAnySetter;
19+
import com.fasterxml.jackson.annotation.JsonBackReference;
1920
import com.fasterxml.jackson.annotation.JsonIgnore;
2021
import com.fasterxml.jackson.annotation.JsonProperty;
2122
import com.fasterxml.jackson.annotation.JsonUnwrapped;
@@ -1490,6 +1491,7 @@ private static void populateSchemaProperties(OpenAPI openAPI, VisitorContext con
14901491
PropertyElementQuery.of(classElement)
14911492
.excludedAnnotations(Set.of(
14921493
Hidden.class.getName(),
1494+
JsonBackReference.class.getName(),
14931495
JsonIgnore.class.getName()
14941496
))
14951497
).stream()
@@ -2365,6 +2367,7 @@ private static boolean isHiddenElement(TypedElement elementType) {
23652367
var jsonAnySetterAnn = getAnnotation(elementType, JsonAnySetter.class);
23662368
return elementType.getType().isAssignable(Class.class)
23672369
|| isAnnotationPresent(elementType, JsonIgnore.class)
2370+
|| isAnnotationPresent(elementType, JsonBackReference.class)
23682371
|| isAnnotationPresent(elementType, Hidden.class)
23692372
|| (jsonAnySetterAnn != null && jsonAnySetterAnn.booleanValue("enabled").orElse(true))
23702373
|| isHidden;

0 commit comments

Comments
 (0)