From d72e46e2f735ef1aeee7e420119c5f308cb18a01 Mon Sep 17 00:00:00 2001 From: Michael Edgar Date: Fri, 14 Aug 2020 22:24:02 -0400 Subject: [PATCH 1/4] Resolve Sonar issues --- .../openapi/api/models/PathItemImpl.java | 6 +-- .../api/models/examples/ExampleImpl.java | 6 +-- .../api/models/headers/HeaderImpl.java | 6 +-- .../openapi/api/models/links/LinkImpl.java | 6 +-- .../openapi/api/models/media/SchemaImpl.java | 6 +-- .../api/models/parameters/ParameterImpl.java | 6 +-- .../models/parameters/RequestBodyImpl.java | 6 +-- .../api/models/responses/APIResponseImpl.java | 6 +-- .../models/security/SecuritySchemeImpl.java | 6 +-- .../smallrye/openapi/api/util/MergeUtil.java | 2 +- .../openapi/api/util/UtilLogging.java | 2 +- .../openapi/runtime/io/IoLogging.java | 2 +- .../runtime/io/callback/CallbackReader.java | 10 ++--- .../io/components/ComponentsReader.java | 4 +- .../runtime/io/contact/ContactReader.java | 4 +- .../runtime/io/content/ContentReader.java | 2 +- .../io/definition/DefinitionReader.java | 4 +- .../runtime/io/encoding/EncodingReader.java | 8 ++-- .../runtime/io/example/ExampleReader.java | 8 ++-- .../runtime/io/extension/ExtensionReader.java | 6 +-- .../io/externaldocs/ExternalDocsReader.java | 2 +- .../runtime/io/header/HeaderReader.java | 10 ++--- .../openapi/runtime/io/info/InfoReader.java | 4 +- .../runtime/io/license/LicenseReader.java | 4 +- .../openapi/runtime/io/link/LinkReader.java | 10 ++--- .../runtime/io/mediatype/MediaTypeReader.java | 4 +- .../openapi/runtime/io/oauth/OAuthReader.java | 16 +++---- .../runtime/io/operation/OperationReader.java | 4 +- .../runtime/io/parameter/ParameterReader.java | 14 +++---- .../openapi/runtime/io/paths/PathsReader.java | 4 +- .../io/requestbody/RequestBodyReader.java | 10 ++--- .../runtime/io/response/ResponseReader.java | 16 +++---- .../runtime/io/schema/SchemaFactory.java | 41 +++++++----------- .../runtime/io/schema/SchemaReader.java | 4 +- .../SecurityRequirementReader.java | 4 +- .../securityscheme/SecuritySchemeReader.java | 6 +-- .../runtime/io/server/ServerReader.java | 8 ++-- .../servervariable/ServerVariableReader.java | 8 ++-- .../openapi/runtime/io/tag/TagReader.java | 8 ++-- .../scanner/OpenApiAnnotationScanner.java | 4 +- .../scanner/OpenApiDataObjectScanner.java | 4 +- .../runtime/scanner/ScannerLogging.java | 2 +- .../runtime/scanner/SchemaRegistry.java | 4 +- .../dataobject/AnnotationTargetProcessor.java | 2 +- .../dataobject/BeanValidationScanner.java | 17 ++------ .../scanner/dataobject/DataObjectDeque.java | 6 +-- .../scanner/dataobject/DataObjectLogging.java | 2 +- .../scanner/dataobject/IgnoreResolver.java | 4 +- .../scanner/dataobject/TypeProcessor.java | 16 +++---- .../scanner/dataobject/TypeResolver.java | 2 +- .../spi/AbstractParameterProcessor.java | 3 -- .../scanner/spi/AnnotationScanner.java | 4 +- .../openapi/runtime/util/JandexUtil.java | 42 ++++--------------- .../openapi/spi/OASFactoryResolverImpl.java | 17 +++++--- .../openapi/runtime/util/JandexUtilTests.java | 6 +-- .../spring/SpringAnnotationScanner.java | 15 +++---- .../openapi/spring/SpringConstants.java | 5 ++- .../openapi/vertx/VertxAnnotationScanner.java | 14 +++---- .../openapi/vertx/VertxConstants.java | 3 ++ 59 files changed, 204 insertions(+), 251 deletions(-) diff --git a/core/src/main/java/io/smallrye/openapi/api/models/PathItemImpl.java b/core/src/main/java/io/smallrye/openapi/api/models/PathItemImpl.java index 0c68f41fa..b15a315f5 100644 --- a/core/src/main/java/io/smallrye/openapi/api/models/PathItemImpl.java +++ b/core/src/main/java/io/smallrye/openapi/api/models/PathItemImpl.java @@ -17,7 +17,7 @@ */ public class PathItemImpl extends ExtensibleImpl implements PathItem, ModelImpl { - private String $ref; + private String ref; private String summary; private String description; private Operation get; @@ -36,7 +36,7 @@ public class PathItemImpl extends ExtensibleImpl implements PathItem, */ @Override public String getRef() { - return $ref; + return ref; } /** @@ -44,7 +44,7 @@ public String getRef() { */ @Override public void setRef(String ref) { - this.$ref = ref; + this.ref = ref; } /** diff --git a/core/src/main/java/io/smallrye/openapi/api/models/examples/ExampleImpl.java b/core/src/main/java/io/smallrye/openapi/api/models/examples/ExampleImpl.java index 320a719c6..2ca6e8c8e 100644 --- a/core/src/main/java/io/smallrye/openapi/api/models/examples/ExampleImpl.java +++ b/core/src/main/java/io/smallrye/openapi/api/models/examples/ExampleImpl.java @@ -11,7 +11,7 @@ */ public class ExampleImpl extends ExtensibleImpl implements Example, ModelImpl { - private String $ref; + private String ref; private String summary; private String description; private Object value; @@ -22,7 +22,7 @@ public class ExampleImpl extends ExtensibleImpl implements Example, Mod */ @Override public String getRef() { - return this.$ref; + return this.ref; } /** @@ -33,7 +33,7 @@ public void setRef(String ref) { if (ref != null && !ref.contains("/")) { ref = OpenApiConstants.REF_PREFIX_EXAMPLE + ref; } - this.$ref = ref; + this.ref = ref; } /** diff --git a/core/src/main/java/io/smallrye/openapi/api/models/headers/HeaderImpl.java b/core/src/main/java/io/smallrye/openapi/api/models/headers/HeaderImpl.java index 10162c719..894aa5a4a 100644 --- a/core/src/main/java/io/smallrye/openapi/api/models/headers/HeaderImpl.java +++ b/core/src/main/java/io/smallrye/openapi/api/models/headers/HeaderImpl.java @@ -18,7 +18,7 @@ */ public class HeaderImpl extends ExtensibleImpl
implements Header, ModelImpl { - private String $ref; + private String ref; private String description; private Boolean required; private Boolean deprecated; @@ -35,7 +35,7 @@ public class HeaderImpl extends ExtensibleImpl
implements Header, ModelI */ @Override public String getRef() { - return this.$ref; + return this.ref; } /** @@ -46,7 +46,7 @@ public void setRef(String ref) { if (ref != null && !ref.contains("/")) { ref = OpenApiConstants.REF_PREFIX_HEADER + ref; } - this.$ref = ref; + this.ref = ref; } /** diff --git a/core/src/main/java/io/smallrye/openapi/api/models/links/LinkImpl.java b/core/src/main/java/io/smallrye/openapi/api/models/links/LinkImpl.java index 09d98094f..31906ec43 100644 --- a/core/src/main/java/io/smallrye/openapi/api/models/links/LinkImpl.java +++ b/core/src/main/java/io/smallrye/openapi/api/models/links/LinkImpl.java @@ -16,7 +16,7 @@ */ public class LinkImpl extends ExtensibleImpl implements Link, ModelImpl { - private String $ref; + private String ref; private String operationRef; private String operationId; private Map parameters; @@ -29,7 +29,7 @@ public class LinkImpl extends ExtensibleImpl implements Link, ModelImpl { */ @Override public String getRef() { - return this.$ref; + return this.ref; } /** @@ -40,7 +40,7 @@ public void setRef(String ref) { if (ref != null && !ref.contains("/")) { ref = OpenApiConstants.REF_PREFIX_LINK + ref; } - this.$ref = ref; + this.ref = ref; } /** diff --git a/core/src/main/java/io/smallrye/openapi/api/models/media/SchemaImpl.java b/core/src/main/java/io/smallrye/openapi/api/models/media/SchemaImpl.java index dcb06cd4b..bd7ee085e 100644 --- a/core/src/main/java/io/smallrye/openapi/api/models/media/SchemaImpl.java +++ b/core/src/main/java/io/smallrye/openapi/api/models/media/SchemaImpl.java @@ -21,7 +21,7 @@ */ public class SchemaImpl extends ExtensibleImpl implements Schema, ModelImpl { - private String $ref; + private String ref; private String format; private final String name; private String title; @@ -81,7 +81,7 @@ public String getName() { */ @Override public String getRef() { - return this.$ref; + return this.ref; } /** @@ -92,7 +92,7 @@ public void setRef(String ref) { if (ref != null && !ref.contains("/")) { ref = OpenApiConstants.REF_PREFIX_SCHEMA + ref; } - this.$ref = ref; + this.ref = ref; } /** diff --git a/core/src/main/java/io/smallrye/openapi/api/models/parameters/ParameterImpl.java b/core/src/main/java/io/smallrye/openapi/api/models/parameters/ParameterImpl.java index 79c837dd5..96cf787ea 100644 --- a/core/src/main/java/io/smallrye/openapi/api/models/parameters/ParameterImpl.java +++ b/core/src/main/java/io/smallrye/openapi/api/models/parameters/ParameterImpl.java @@ -18,7 +18,7 @@ */ public class ParameterImpl extends ExtensibleImpl implements Parameter, ModelImpl { - private String $ref; + private String ref; private String name; private In in; private String description; @@ -38,7 +38,7 @@ public class ParameterImpl extends ExtensibleImpl implements Paramete */ @Override public String getRef() { - return this.$ref; + return this.ref; } /** @@ -49,7 +49,7 @@ public void setRef(String ref) { if (ref != null && !ref.contains("/")) { ref = OpenApiConstants.REF_PREFIX_PARAMETER + ref; } - this.$ref = ref; + this.ref = ref; } /** diff --git a/core/src/main/java/io/smallrye/openapi/api/models/parameters/RequestBodyImpl.java b/core/src/main/java/io/smallrye/openapi/api/models/parameters/RequestBodyImpl.java index a8dc5d884..a8e5ef469 100644 --- a/core/src/main/java/io/smallrye/openapi/api/models/parameters/RequestBodyImpl.java +++ b/core/src/main/java/io/smallrye/openapi/api/models/parameters/RequestBodyImpl.java @@ -12,7 +12,7 @@ */ public class RequestBodyImpl extends ExtensibleImpl implements RequestBody, ModelImpl { - private String $ref; + private String ref; private String description; private Content content; private Boolean required; @@ -22,7 +22,7 @@ public class RequestBodyImpl extends ExtensibleImpl implements Requ */ @Override public String getRef() { - return this.$ref; + return this.ref; } /** @@ -33,7 +33,7 @@ public void setRef(String ref) { if (ref != null && !ref.contains("/")) { ref = OpenApiConstants.REF_PREFIX_REQUEST_BODY + ref; } - this.$ref = ref; + this.ref = ref; } /** diff --git a/core/src/main/java/io/smallrye/openapi/api/models/responses/APIResponseImpl.java b/core/src/main/java/io/smallrye/openapi/api/models/responses/APIResponseImpl.java index 322ccb315..ba90f1b28 100644 --- a/core/src/main/java/io/smallrye/openapi/api/models/responses/APIResponseImpl.java +++ b/core/src/main/java/io/smallrye/openapi/api/models/responses/APIResponseImpl.java @@ -18,7 +18,7 @@ */ public class APIResponseImpl extends ExtensibleImpl implements APIResponse, ModelImpl { - private String $ref; + private String ref; private String description; private Map headers; private Content content; @@ -29,7 +29,7 @@ public class APIResponseImpl extends ExtensibleImpl implements APIR */ @Override public String getRef() { - return this.$ref; + return this.ref; } /** @@ -40,7 +40,7 @@ public void setRef(String ref) { if (ref != null && !ref.contains("/")) { ref = OpenApiConstants.REF_PREFIX_API_RESPONSE + ref; } - this.$ref = ref; + this.ref = ref; } /** diff --git a/core/src/main/java/io/smallrye/openapi/api/models/security/SecuritySchemeImpl.java b/core/src/main/java/io/smallrye/openapi/api/models/security/SecuritySchemeImpl.java index dde4eff21..dbaa635f8 100644 --- a/core/src/main/java/io/smallrye/openapi/api/models/security/SecuritySchemeImpl.java +++ b/core/src/main/java/io/smallrye/openapi/api/models/security/SecuritySchemeImpl.java @@ -12,7 +12,7 @@ */ public class SecuritySchemeImpl extends ExtensibleImpl implements SecurityScheme, ModelImpl { - private String $ref; + private String ref; private Type type; private String description; private String name; @@ -27,7 +27,7 @@ public class SecuritySchemeImpl extends ExtensibleImpl implement */ @Override public String getRef() { - return this.$ref; + return this.ref; } /** @@ -38,7 +38,7 @@ public void setRef(String ref) { if (ref != null && !ref.contains("/")) { ref = OpenApiConstants.REF_PREFIX_SECURITY_SCHEME + ref; } - this.$ref = ref; + this.ref = ref; } /** diff --git a/core/src/main/java/io/smallrye/openapi/api/util/MergeUtil.java b/core/src/main/java/io/smallrye/openapi/api/util/MergeUtil.java index c10613ac3..e2bfca639 100644 --- a/core/src/main/java/io/smallrye/openapi/api/util/MergeUtil.java +++ b/core/src/main/java/io/smallrye/openapi/api/util/MergeUtil.java @@ -87,7 +87,7 @@ public static T mergeObjects(T object1, T object2) { try { descriptors = Introspector.getBeanInfo(object1.getClass()).getPropertyDescriptors(); } catch (IntrospectionException e) { - UtilLogging.log.failedToIntrospectBeanInfo(object1.getClass(), e); + UtilLogging.logger.failedToIntrospectBeanInfo(object1.getClass(), e); } for (PropertyDescriptor descriptor : descriptors) { diff --git a/core/src/main/java/io/smallrye/openapi/api/util/UtilLogging.java b/core/src/main/java/io/smallrye/openapi/api/util/UtilLogging.java index a1adfb4e6..203b4693b 100644 --- a/core/src/main/java/io/smallrye/openapi/api/util/UtilLogging.java +++ b/core/src/main/java/io/smallrye/openapi/api/util/UtilLogging.java @@ -9,7 +9,7 @@ @MessageLogger(projectCode = "SROAP", length = 5) interface UtilLogging extends BasicLogger { - UtilLogging log = Logger.getMessageLogger(UtilLogging.class, UtilLogging.class.getPackage().getName()); + UtilLogging logger = Logger.getMessageLogger(UtilLogging.class, UtilLogging.class.getPackage().getName()); @LogMessage(level = Logger.Level.ERROR) @Message(id = 1000, value = "Failed to introspect BeanInfo for: %s") diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/IoLogging.java b/core/src/main/java/io/smallrye/openapi/runtime/io/IoLogging.java index eb2ec0ab9..90b375627 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/IoLogging.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/IoLogging.java @@ -10,7 +10,7 @@ @MessageLogger(projectCode = "SROAP", length = 5) public interface IoLogging extends BasicLogger { - IoLogging log = Logger.getMessageLogger(IoLogging.class, IoLogging.class.getPackage().getName()); + IoLogging logger = Logger.getMessageLogger(IoLogging.class, IoLogging.class.getPackage().getName()); @LogMessage(level = Logger.Level.DEBUG) @Message(id = 2000, value = "Processing a map of %s annotations.") diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/callback/CallbackReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/callback/CallbackReader.java index 930adab81..f03865da6 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/callback/CallbackReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/callback/CallbackReader.java @@ -47,7 +47,7 @@ public static Map readCallbacks(final AnnotationScannerContext if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@Callback"); + IoLogging.logger.annotationsMap("@Callback"); Map callbacks = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -72,7 +72,7 @@ public static Map readCallbacks(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.jsonNodeMap("Callback"); + IoLogging.logger.jsonNodeMap("Callback"); Map callbacks = new LinkedHashMap<>(); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { String fieldName = fieldNames.next(); @@ -102,9 +102,9 @@ public static Callback readCallback(final AnnotationScannerContext context, if (annotation == null) { return null; } - IoLogging.log.singleAnnotation("@Callback"); + IoLogging.logger.singleAnnotation("@Callback"); Callback callback = new CallbackImpl(); - callback.setRef(JandexUtil.refValue(annotation, JandexUtil.RefType.Callback)); + callback.setRef(JandexUtil.refValue(annotation, JandexUtil.RefType.CALLBACK)); String expression = JandexUtil.stringValue(annotation, CallbackConstant.PROP_CALLBACK_URL_EXPRESSION); callback.addPathItem(expression, PathsReader.readPathItem(context, annotation.value(CallbackConstant.PROP_OPERATIONS), null)); @@ -121,7 +121,7 @@ private static Callback readCallback(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonNode("Callback"); + IoLogging.logger.singleJsonNode("Callback"); Callback callback = new CallbackImpl(); callback.setRef(JsonUtil.stringProperty(node, Referenceable.PROP_$REF)); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/components/ComponentsReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/components/ComponentsReader.java index bd860958b..0c854909e 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/components/ComponentsReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/components/ComponentsReader.java @@ -46,7 +46,7 @@ public static Components readComponents(final AnnotationScannerContext context, if (annotationValue == null) { return null; } - IoLogging.log.singleAnnotation("@Components"); + IoLogging.logger.singleAnnotation("@Components"); AnnotationInstance nested = annotationValue.asNested(); Components components = new ComponentsImpl(); // TODO for EVERY item below, handle the case where the annotation is ref-only. then strip the ref path and use the final segment as the name @@ -78,7 +78,7 @@ public static Components readComponents(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonNode("Components"); + IoLogging.logger.singleJsonNode("Components"); Components components = new ComponentsImpl(); components.setCallbacks(CallbackReader.readCallbacks(node.get(ComponentsConstant.PROP_CALLBACKS))); components.setExamples(ExampleReader.readExamples(node.get(ComponentsConstant.PROP_EXAMPLES))); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/contact/ContactReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/contact/ContactReader.java index 98e498e03..449f0f1ed 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/contact/ContactReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/contact/ContactReader.java @@ -35,7 +35,7 @@ public static Contact readContact(final AnnotationValue annotationValue) { if (annotationValue == null) { return null; } - IoLogging.log.singleAnnotation("@Contact"); + IoLogging.logger.singleAnnotation("@Contact"); AnnotationInstance nested = annotationValue.asNested(); Contact contact = new ContactImpl(); contact.setName(JandexUtil.stringValue(nested, ContactConstant.PROP_NAME)); @@ -54,7 +54,7 @@ public static Contact readContact(final JsonNode node) { if (node == null) { return null; } - IoLogging.log.singleJsonNode("Contact"); + IoLogging.logger.singleJsonNode("Contact"); Contact contact = new ContactImpl(); contact.setName(JsonUtil.stringProperty(node, ContactConstant.PROP_NAME)); contact.setUrl(JsonUtil.stringProperty(node, ContactConstant.PROP_URL)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/content/ContentReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/content/ContentReader.java index b8c67893c..3a022957a 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/content/ContentReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/content/ContentReader.java @@ -45,7 +45,7 @@ public static Content readContent(final AnnotationScannerContext context, if (annotationValue == null) { return null; } - IoLogging.log.singleAnnotation("@Content"); + IoLogging.logger.singleAnnotation("@Content"); Content content = new ContentImpl(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/definition/DefinitionReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/definition/DefinitionReader.java index 2f6218945..37c43a88f 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/definition/DefinitionReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/definition/DefinitionReader.java @@ -43,7 +43,7 @@ private DefinitionReader() { public static void processDefinition(final AnnotationScannerContext context, final OpenAPI openApi, final AnnotationInstance annotationInstance) { - IoLogging.log.annotation("@OpenAPIDefinition"); + IoLogging.logger.annotation("@OpenAPIDefinition"); openApi.setInfo(InfoReader.readInfo(annotationInstance.value(DefinitionConstant.PROP_INFO))); openApi.setTags(TagReader.readTags(annotationInstance.value(DefinitionConstant.PROP_TAGS)).orElse(null)); @@ -66,7 +66,7 @@ public static void processDefinition(final AnnotationScannerContext context, */ public static void processDefinition(final OpenAPI openApi, final JsonNode node) { - IoLogging.log.jsonNode("OpenAPIDefinition"); + IoLogging.logger.jsonNode("OpenAPIDefinition"); openApi.setOpenapi(JsonUtil.stringProperty(node, DefinitionConstant.PROP_OPENAPI)); openApi.setInfo(InfoReader.readInfo(node.get(DefinitionConstant.PROP_INFO))); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/encoding/EncodingReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/encoding/EncodingReader.java index 1f2f7aad4..0a5397873 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/encoding/EncodingReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/encoding/EncodingReader.java @@ -44,7 +44,7 @@ public static Map readEncodings(final AnnotationScannerContext if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@Encoding"); + IoLogging.logger.annotationsMap("@Encoding"); Map encodings = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance annotation : nestedArray) { @@ -66,7 +66,7 @@ public static Map readEncodings(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.jsonNodeMap("Encoding"); + IoLogging.logger.jsonNodeMap("Encoding"); Map encodings = new LinkedHashMap<>(); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { String name = fieldNames.next(); @@ -86,7 +86,7 @@ private static Encoding readEncoding(final AnnotationScannerContext context, fin if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotation("@Encoding"); + IoLogging.logger.singleAnnotation("@Encoding"); Encoding encoding = new EncodingImpl(); encoding.setContentType(JandexUtil.stringValue(annotationInstance, EncodingConstant.PROP_CONTENT_TYPE)); encoding.setStyle(JandexUtil.enumValue(annotationInstance, EncodingConstant.PROP_STYLE, Style.class)); @@ -108,7 +108,7 @@ private static Encoding readEncoding(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonNode("Encoding"); + IoLogging.logger.singleJsonNode("Encoding"); Encoding encoding = new EncodingImpl(); encoding.setContentType(JsonUtil.stringProperty(node, EncodingConstant.PROP_CONTENT_TYPE)); encoding.setHeaders(HeaderReader.readHeaders(node.get(EncodingConstant.PROP_HEADERS))); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/example/ExampleReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/example/ExampleReader.java index a91b3577f..67b6cb277 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/example/ExampleReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/example/ExampleReader.java @@ -42,7 +42,7 @@ public static Map readExamples(final AnnotationValue annotation if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@ExampleObject"); + IoLogging.logger.annotationsMap("@ExampleObject"); Map examples = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -87,9 +87,9 @@ private static Example readExample(AnnotationInstance annotationInstance) { if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotation("@ExampleObject"); + IoLogging.logger.singleAnnotation("@ExampleObject"); Example example = new ExampleImpl(); - example.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.Example)); + example.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.EXAMPLE)); example.setSummary(JandexUtil.stringValue(annotationInstance, ExampleConstant.PROP_SUMMARY)); example.setDescription(JandexUtil.stringValue(annotationInstance, ExampleConstant.PROP_DESCRIPTION)); example.setValue(JandexUtil.stringValue(annotationInstance, ExampleConstant.PROP_VALUE)); @@ -108,7 +108,7 @@ private static Example readExample(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonNode("ExampleObject"); + IoLogging.logger.singleJsonNode("ExampleObject"); Example example = new ExampleImpl(); example.setRef(JsonUtil.stringProperty(node, Referenceable.PROP_$REF)); example.setSummary(JsonUtil.stringProperty(node, ExampleConstant.PROP_SUMMARY)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/extension/ExtensionReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/extension/ExtensionReader.java index 66aef063d..c7168f89e 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/extension/ExtensionReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/extension/ExtensionReader.java @@ -46,7 +46,7 @@ public static Map readExtensions(final AnnotationScannerContext if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@Extension"); + IoLogging.logger.annotationsMap("@Extension"); Map e = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance annotation : nestedArray) { @@ -65,7 +65,7 @@ public static Map readExtensions(final AnnotationScannerContext */ public static Map readExtensions(final AnnotationScannerContext context, final List extensions) { - IoLogging.log.annotationsMap("@Extension"); + IoLogging.logger.annotationsMap("@Extension"); Map e = new LinkedHashMap<>(); for (AnnotationInstance annotation : extensions) { String extName = JandexUtil.stringValue(annotation, ExtensionConstant.PROP_NAME); @@ -87,7 +87,7 @@ public static Map readExtensions(final AnnotationScannerContext */ public static Object readExtensionValue(final AnnotationScannerContext context, final String name, final AnnotationInstance annotationInstance) { - IoLogging.log.annotation("@Extension"); + IoLogging.logger.annotation("@Extension"); String extValue = JandexUtil.stringValue(annotationInstance, ExtensionConstant.PROP_VALUE); boolean parseValue = JandexUtil.booleanValueWithDefault(annotationInstance, ExtensionConstant.PROP_PARSE_VALUE); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/externaldocs/ExternalDocsReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/externaldocs/ExternalDocsReader.java index 92ac14632..63c81249d 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/externaldocs/ExternalDocsReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/externaldocs/ExternalDocsReader.java @@ -49,7 +49,7 @@ public static ExternalDocumentation readExternalDocs(AnnotationInstance annotati if (annotationInstance == null) { return null; } - IoLogging.log.annotation("@ExternalDocumentation"); + IoLogging.logger.annotation("@ExternalDocumentation"); ExternalDocumentation externalDoc = new ExternalDocumentationImpl(); externalDoc.setDescription( JandexUtil.stringValue(annotationInstance, ExternalDocsConstant.PROP_DESCRIPTION)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/header/HeaderReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/header/HeaderReader.java index 90714e9e7..7ebce0bd8 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/header/HeaderReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/header/HeaderReader.java @@ -50,7 +50,7 @@ public static Map readHeaders(final AnnotationScannerContext con if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@Header"); + IoLogging.logger.annotationsMap("@Header"); Map headers = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -75,7 +75,7 @@ public static Map readHeaders(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.jsonNodeMap("Headers"); + IoLogging.logger.jsonNodeMap("Headers"); Map headers = new LinkedHashMap<>(); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { String fieldName = fieldNames.next(); @@ -96,9 +96,9 @@ private static Header readHeader(final AnnotationScannerContext context, final A if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotation("@Header"); + IoLogging.logger.singleAnnotation("@Header"); Header header = new HeaderImpl(); - header.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.Header)); + header.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.HEADER)); header.setDescription(JandexUtil.stringValue(annotationInstance, Parameterizable.PROP_DESCRIPTION)); header.setSchema( SchemaFactory.readSchema(context.getIndex(), context.getClassLoader(), @@ -119,7 +119,7 @@ private static Header readHeader(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonNode("Header"); + IoLogging.logger.singleJsonNode("Header"); Header header = new HeaderImpl(); header.setRef(JsonUtil.stringProperty(node, Referenceable.PROP_$REF)); header.setDescription(JsonUtil.stringProperty(node, Parameterizable.PROP_DESCRIPTION)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/info/InfoReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/info/InfoReader.java index 3746f8fa2..056cf5585 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/info/InfoReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/info/InfoReader.java @@ -37,7 +37,7 @@ public static Info readInfo(final AnnotationValue annotationValue) { if (annotationValue == null) { return null; } - IoLogging.log.annotation("@Info"); + IoLogging.logger.annotation("@Info"); AnnotationInstance nested = annotationValue.asNested(); Info info = new InfoImpl(); @@ -60,7 +60,7 @@ public static Info readInfo(final JsonNode node) { if (node == null) { return null; } - IoLogging.log.singleJsonNode("Info"); + IoLogging.logger.singleJsonNode("Info"); Info info = new InfoImpl(); info.setTitle(JsonUtil.stringProperty(node, InfoConstant.PROP_TITLE)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/license/LicenseReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/license/LicenseReader.java index bc9646ff7..3198eb4d3 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/license/LicenseReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/license/LicenseReader.java @@ -35,7 +35,7 @@ public static License readLicense(final AnnotationValue annotationValue) { if (annotationValue == null) { return null; } - IoLogging.log.singleAnnotation("@License"); + IoLogging.logger.singleAnnotation("@License"); AnnotationInstance nested = annotationValue.asNested(); License license = new LicenseImpl(); license.setName(JandexUtil.stringValue(nested, LicenseConstant.PROP_NAME)); @@ -53,7 +53,7 @@ public static License readLicense(final JsonNode node) { if (node == null) { return null; } - IoLogging.log.singleJsonNode("License"); + IoLogging.logger.singleJsonNode("License"); License license = new LicenseImpl(); license.setName(JsonUtil.stringProperty(node, LicenseConstant.PROP_NAME)); license.setUrl(JsonUtil.stringProperty(node, LicenseConstant.PROP_URL)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/link/LinkReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/link/LinkReader.java index 85bb7f709..16fc97bf9 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/link/LinkReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/link/LinkReader.java @@ -43,7 +43,7 @@ public static Map readLinks(final AnnotationValue annotationValue) if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@Link"); + IoLogging.logger.annotationsMap("@Link"); Map links = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -68,7 +68,7 @@ public static Map readLinks(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.jsonNodeMap("Link"); + IoLogging.logger.jsonNodeMap("Link"); Map links = new LinkedHashMap<>(); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { String fieldName = fieldNames.next(); @@ -89,7 +89,7 @@ private static Link readLink(final AnnotationInstance annotationInstance) { if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotation("@Link"); + IoLogging.logger.singleAnnotation("@Link"); Link link = new LinkImpl(); link.setOperationRef(JandexUtil.stringValue(annotationInstance, LinkConstant.PROP_OPERATION_REF)); link.setOperationId(JandexUtil.stringValue(annotationInstance, LinkConstant.PROP_OPERATION_ID)); @@ -97,7 +97,7 @@ private static Link readLink(final AnnotationInstance annotationInstance) { link.setDescription(JandexUtil.stringValue(annotationInstance, LinkConstant.PROP_DESCRIPTION)); link.setRequestBody(JandexUtil.stringValue(annotationInstance, LinkConstant.PROP_REQUEST_BODY)); link.setServer(ServerReader.readServer(annotationInstance.value(LinkConstant.PROP_SERVER))); - link.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.Link)); + link.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.LINK)); return link; } @@ -111,7 +111,7 @@ private static Link readLink(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonNode("Link"); + IoLogging.logger.singleJsonNode("Link"); Link link = new LinkImpl(); link.setRef(JsonUtil.stringProperty(node, Referenceable.PROP_$REF)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/mediatype/MediaTypeReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/mediatype/MediaTypeReader.java index 1f7cf6a66..99588ff83 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/mediatype/MediaTypeReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/mediatype/MediaTypeReader.java @@ -42,7 +42,7 @@ public static MediaType readMediaType(final AnnotationScannerContext context, if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotationAs("@Content", "MediaType"); + IoLogging.logger.singleAnnotationAs("@Content", "MediaType"); MediaType mediaType = new MediaTypeImpl(); mediaType.setExamples(ExampleReader.readExamples(annotationInstance.value(MediaTypeConstant.PROP_EXAMPLES))); mediaType.setExample(JandexUtil.stringValue(annotationInstance, MediaTypeConstant.PROP_EXAMPLE)); @@ -64,7 +64,7 @@ public static MediaType readMediaType(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonNode("Content"); + IoLogging.logger.singleJsonNode("Content"); MediaType mediaType = new MediaTypeImpl(); mediaType.setSchema(SchemaReader.readSchema(node.get(MediaTypeConstant.PROP_SCHEMA))); mediaType.setExample(readObject(node.get(MediaTypeConstant.PROP_EXAMPLE))); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/oauth/OAuthReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/oauth/OAuthReader.java index 25b417a34..090d7bcbf 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/oauth/OAuthReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/oauth/OAuthReader.java @@ -43,7 +43,7 @@ public static OAuthFlows readOAuthFlows(final AnnotationValue annotationValue) { if (annotationValue == null) { return null; } - IoLogging.log.singleAnnotation("@OAuthFlows"); + IoLogging.logger.singleAnnotation("@OAuthFlows"); AnnotationInstance annotation = annotationValue.asNested(); OAuthFlows flows = new OAuthFlowsImpl(); flows.setImplicit(readOAuthFlow(annotation.value(SecuritySchemeConstant.PROP_IMPLICIT))); @@ -63,7 +63,7 @@ public static OAuthFlows readOAuthFlows(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonObject("OAuthFlows"); + IoLogging.logger.singleJsonObject("OAuthFlows"); OAuthFlows flows = new OAuthFlowsImpl(); flows.setImplicit(readOAuthFlow(node.get(SecuritySchemeConstant.PROP_IMPLICIT))); flows.setPassword(readOAuthFlow(node.get(SecuritySchemeConstant.PROP_PASSWORD))); @@ -83,7 +83,7 @@ private static OAuthFlow readOAuthFlow(final AnnotationValue annotationValue) { if (annotationValue == null) { return null; } - IoLogging.log.singleAnnotation("@OAuthFlow"); + IoLogging.logger.singleAnnotation("@OAuthFlow"); AnnotationInstance annotation = annotationValue.asNested(); OAuthFlow flow = new OAuthFlowImpl(); flow.setAuthorizationUrl(JandexUtil.stringValue(annotation, SecuritySchemeConstant.PROP_AUTHORIZATION_URL)); @@ -103,7 +103,7 @@ private static OAuthFlow readOAuthFlow(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonObject("OAuthFlow"); + IoLogging.logger.singleJsonObject("OAuthFlow"); OAuthFlow flow = new OAuthFlowImpl(); flow.setAuthorizationUrl(JsonUtil.stringProperty(node, SecuritySchemeConstant.PROP_AUTHORIZATION_URL)); flow.setTokenUrl(JsonUtil.stringProperty(node, SecuritySchemeConstant.PROP_TOKEN_URL)); @@ -123,9 +123,9 @@ private static Map readOAuthScopes(final AnnotationValue annotat if (annotationValue == null) { return null; } - IoLogging.log.annotationsList("@OAuthScope"); + IoLogging.logger.annotationsList("@OAuthScope"); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); - Map scopes = new LinkedHashMap(); + Map scopes = new LinkedHashMap<>(); for (AnnotationInstance nested : nestedArray) { String name = JandexUtil.stringValue(nested, SecuritySchemeConstant.PROP_NAME); if (name != null) { @@ -147,8 +147,8 @@ public static Map readOAuthScopes(final JsonNode node) { return null; } - IoLogging.log.jsonMap("OAuthScope"); - Map scopes = new LinkedHashMap(); + IoLogging.logger.jsonMap("OAuthScope"); + Map scopes = new LinkedHashMap<>(); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { String fieldName = fieldNames.next(); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/operation/OperationReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/operation/OperationReader.java index 75fecb539..40c9740ca 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/operation/OperationReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/operation/OperationReader.java @@ -47,7 +47,7 @@ public static Operation readOperation(final AnnotationScannerContext context, final MethodInfo methodInfo) { if (annotationInstance != null) { - IoLogging.log.singleAnnotation("@Operation"); + IoLogging.logger.singleAnnotation("@Operation"); Operation operation = new OperationImpl(); operation.setSummary(JandexUtil.stringValue(annotationInstance, OperationConstant.PROP_SUMMARY)); operation.setDescription(JandexUtil.stringValue(annotationInstance, OperationConstant.PROP_DESCRIPTION)); @@ -90,7 +90,7 @@ public static Operation readOperation(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonObject("Operation"); + IoLogging.logger.singleJsonObject("Operation"); Operation model = new OperationImpl(); model.setTags(JsonUtil.readStringArray(node.get(OperationConstant.PROP_TAGS)).orElse(null)); model.setSummary(JsonUtil.stringProperty(node, OperationConstant.PROP_SUMMARY)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/parameter/ParameterReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/parameter/ParameterReader.java index 362f141ef..efb397b0d 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/parameter/ParameterReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/parameter/ParameterReader.java @@ -55,7 +55,7 @@ private ParameterReader() { public static Optional> readParametersList(final AnnotationScannerContext context, final AnnotationValue annotationValue) { if (annotationValue != null) { - IoLogging.log.annotationsList("@Parameter"); + IoLogging.logger.annotationsList("@Parameter"); List parameters = new ArrayList<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -77,7 +77,7 @@ public static Optional> readParametersList(final AnnotationScann */ public static Optional> readParameterList(final JsonNode node) { if (node != null && node.isArray()) { - IoLogging.log.jsonList("Parameter"); + IoLogging.logger.jsonList("Parameter"); List params = new ArrayList<>(); ArrayNode arrayNode = (ArrayNode) node; for (JsonNode paramNode : arrayNode) { @@ -100,7 +100,7 @@ public static Map readParameters(final AnnotationScannerConte if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@Parameter"); + IoLogging.logger.annotationsMap("@Parameter"); Map parameters = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -128,7 +128,7 @@ public static Map readParameters(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.jsonMap("Parameters"); + IoLogging.logger.jsonMap("Parameters"); Map parameters = new LinkedHashMap<>(); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { String fieldName = fieldNames.next(); @@ -152,7 +152,7 @@ public static Parameter readParameter(final AnnotationScannerContext context, if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotation("@Parameter"); + IoLogging.logger.singleAnnotation("@Parameter"); Parameter parameter = new ParameterImpl(); parameter.setName(JandexUtil.stringValue(annotationInstance, Parameterizable.PROP_NAME)); parameter.setIn(JandexUtil.enumValue(annotationInstance, ParameterConstant.PROP_IN, @@ -185,7 +185,7 @@ public static Parameter readParameter(final AnnotationScannerContext context, ContentDirection.PARAMETER)); parameter.setExamples(ExampleReader.readExamples(annotationInstance.value(Parameterizable.PROP_EXAMPLES))); parameter.setExample(JandexUtil.stringValue(annotationInstance, Parameterizable.PROP_EXAMPLE)); - parameter.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.Parameter)); + parameter.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.PARAMETER)); return parameter; } @@ -199,7 +199,7 @@ public static Parameter readParameter(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonObject("Parameter"); + IoLogging.logger.singleJsonObject("Parameter"); Parameter parameter = new ParameterImpl(); parameter.setName(JsonUtil.stringProperty(node, Parameterizable.PROP_NAME)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/paths/PathsReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/paths/PathsReader.java index cc58e62a6..cf20c8d6b 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/paths/PathsReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/paths/PathsReader.java @@ -97,7 +97,7 @@ public static PathItem readPathItem(final AnnotationScannerContext context, Method mutator = descriptor.getWriteMethod(); mutator.invoke(pathItem, operation); } catch (IntrospectionException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - IoLogging.log.readingCallbackOperation(e); + IoLogging.logger.readingCallbackOperation(e); } } return pathItem; @@ -113,7 +113,7 @@ public static PathItem readPathItem(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonNode("PathItem"); + IoLogging.logger.singleJsonNode("PathItem"); PathItem pathItem = new PathItemImpl(); pathItem.setRef(JsonUtil.stringProperty(node, Referenceable.PROP_$REF)); pathItem.setSummary(JsonUtil.stringProperty(node, PathsConstant.PROP_SUMMARY)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/requestbody/RequestBodyReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/requestbody/RequestBodyReader.java index 2bb688eb3..ca2347e77 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/requestbody/RequestBodyReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/requestbody/RequestBodyReader.java @@ -55,7 +55,7 @@ public static Map readRequestBodies(final AnnotationScanner if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@RequestBody"); + IoLogging.logger.annotationsMap("@RequestBody"); Map requestBodies = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -80,7 +80,7 @@ public static Map readRequestBodies(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.jsonMap("RequestBody"); + IoLogging.logger.jsonMap("RequestBody"); Map requestBodies = new LinkedHashMap<>(); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { String fieldName = fieldNames.next(); @@ -117,7 +117,7 @@ public static RequestBody readRequestBody(final AnnotationScannerContext context if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotation("@RequestBody"); + IoLogging.logger.singleAnnotation("@RequestBody"); RequestBody requestBody = new RequestBodyImpl(); requestBody.setDescription(JandexUtil.stringValue(annotationInstance, RequestBodyConstant.PROP_DESCRIPTION)); requestBody @@ -125,7 +125,7 @@ public static RequestBody readRequestBody(final AnnotationScannerContext context annotationInstance.value(RequestBodyConstant.PROP_CONTENT), ContentDirection.INPUT)); requestBody.setRequired(JandexUtil.booleanValue(annotationInstance, RequestBodyConstant.PROP_REQUIRED).orElse(null)); - requestBody.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.RequestBody)); + requestBody.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.REQUEST_BODY)); return requestBody; } @@ -142,7 +142,7 @@ public static RequestBody readRequestBodySchema(final AnnotationScannerContext c // Only generate the RequestBody if the endpoint declares an @Consumes media type return null; } - IoLogging.log.singleAnnotation("@RequestBodySchema"); + IoLogging.logger.singleAnnotation("@RequestBodySchema"); Content content = new ContentImpl(); for (String mediaType : CurrentScannerInfo.getCurrentConsumes()) { diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/response/ResponseReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/response/ResponseReader.java index 1834fb76e..74bf4a318 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/response/ResponseReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/response/ResponseReader.java @@ -58,7 +58,7 @@ public static APIResponses readResponses(final AnnotationScannerContext context, if (annotationValue == null) { return null; } - IoLogging.log.annotationsListInto("@APIResponse", "APIResponses model"); + IoLogging.logger.annotationsListInto("@APIResponse", "APIResponses model"); APIResponses responses = new APIResponsesImpl(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -81,7 +81,7 @@ public static APIResponses readResponses(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.jsonList("APIResponse"); + IoLogging.logger.jsonList("APIResponse"); APIResponses model = new APIResponsesImpl(); model.setDefaultValue(readResponse(node.get(ResponseConstant.PROP_DEFAULT))); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { @@ -106,7 +106,7 @@ public static Map readResponsesMap(final AnnotationScannerC if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@APIResponse"); + IoLogging.logger.annotationsMap("@APIResponse"); Map responses = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -131,7 +131,7 @@ public static Map readResponsesMap(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.jsonMap("APIResponse"); + IoLogging.logger.jsonMap("APIResponse"); Map responses = new LinkedHashMap<>(); for (Iterator fieldNames = node.fieldNames(); fieldNames.hasNext();) { String fieldName = fieldNames.next(); @@ -154,7 +154,7 @@ public static APIResponse readResponse(final AnnotationScannerContext context, if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotation("@APIResponse"); + IoLogging.logger.singleAnnotation("@APIResponse"); APIResponse response = new APIResponseImpl(); response.setDescription(JandexUtil.stringValue(annotationInstance, ResponseConstant.PROP_DESCRIPTION)); response.setHeaders( @@ -163,7 +163,7 @@ public static APIResponse readResponse(final AnnotationScannerContext context, response.setContent( ContentReader.readContent(context, annotationInstance.value(ResponseConstant.PROP_CONTENT), ContentDirection.OUTPUT)); - response.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.Response)); + response.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.RESPONSE)); return response; } @@ -180,7 +180,7 @@ public static APIResponse readResponseSchema(final AnnotationScannerContext cont // Only generate the APIResponse if the endpoint declares an @Produces media type return null; } - IoLogging.log.singleAnnotation("@APIResponseSchema"); + IoLogging.logger.singleAnnotation("@APIResponseSchema"); Content content = new ContentImpl(); for (String mediaType : CurrentScannerInfo.getCurrentProduces()) { @@ -208,7 +208,7 @@ private static APIResponse readResponse(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonObject("Response"); + IoLogging.logger.singleJsonObject("Response"); APIResponse model = new APIResponseImpl(); model.setRef(JsonUtil.stringProperty(node, Referenceable.PROP_$REF)); model.setDescription(JsonUtil.stringProperty(node, ResponseConstant.PROP_DESCRIPTION)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/schema/SchemaFactory.java b/core/src/main/java/io/smallrye/openapi/runtime/io/schema/SchemaFactory.java index 40236e6bd..72a8f284e 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/schema/SchemaFactory.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/schema/SchemaFactory.java @@ -65,14 +65,7 @@ public static Schema readSchema(IndexView index, ClassLoader cl, AnnotationValue AnnotationInstance schemaAnnotation = value.asNested(); - if (schemaAnnotation == null) { - return null; - } - - IoLogging.log.singleAnnotation("@Schema"); - - // Schemas can be hidden. Skip if that's the case. - if (Boolean.TRUE.equals(JandexUtil.value(schemaAnnotation, SchemaConstant.PROP_HIDDEN))) { + if (isAnnotationMissingOrHidden(schemaAnnotation, Collections.emptyMap())) { return null; } @@ -119,14 +112,7 @@ static Schema readSchema(IndexView index, ClassInfo clazz, Map defaults) { - if (annotation == null) { - return schema; - } - - // Schemas can be hidden. Skip if that's the case. - Boolean isHidden = readAttr(annotation, SchemaConstant.PROP_HIDDEN, defaults); - - if (Boolean.TRUE.equals(isHidden)) { + if (isAnnotationMissingOrHidden(annotation, defaults)) { return schema; } @@ -150,14 +136,8 @@ public static Schema readSchema(IndexView index, Schema schema, AnnotationInstance annotation, Map defaults) { - if (annotation == null) { - return schema; - } - // Schemas can be hidden. Skip if that's the case. - Boolean isHidden = readAttr(annotation, SchemaConstant.PROP_HIDDEN, defaults); - - if (Boolean.TRUE.equals(isHidden)) { + if (isAnnotationMissingOrHidden(annotation, defaults)) { return schema; } @@ -261,6 +241,15 @@ public static Schema readSchema(IndexView index, return schema; } + static boolean isAnnotationMissingOrHidden(AnnotationInstance annotation, Map defaults) { + if (annotation == null) { + return true; + } + + // Schemas can be hidden. Skip if that's the case. + return Boolean.TRUE.equals(readAttr(annotation, SchemaConstant.PROP_HIDDEN, defaults)); + } + /** * Reads the attribute named by propertyName from annotation. If no value was specified, * an optional default value is retrieved from the defaults map using the propertyName as @@ -430,7 +419,7 @@ public static Schema typeToSchema(IndexView index, ClassLoader cl, Type type, Li * @see java.lang.reflect.Field#isEnumConstant() */ public static Schema enumToSchema(IndexView index, ClassLoader cl, Type enumType) { - IoLogging.log.enumProcessing(enumType); + IoLogging.logger.enumProcessing(enumType); final int ENUM = 0x00004000; // see java.lang.reflect.Modifier#ENUM ClassInfo enumKlazz = index.getClassByName(TypeUtil.getName(enumType)); AnnotationInstance schemaAnnotation = enumKlazz.classAnnotation(SchemaConstant.DOTNAME_SCHEMA); @@ -539,7 +528,7 @@ static boolean allowRegistration(IndexView index, SchemaRegistry registry, Type * @param types the implementation types of the items to scan, never null */ private static List readClassSchemas(IndexView index, ClassLoader cl, Type[] types) { - IoLogging.log.annotationsList("schema Class"); + IoLogging.logger.annotationsList("schema Class"); return Arrays.stream(types) .map(type -> readClassSchema(index, cl, type, true)) @@ -614,7 +603,7 @@ private static Discriminator readDiscriminator(IndexView index, } if (annotation != null) { - IoLogging.log.annotationsList("@DiscriminatorMapping"); + IoLogging.logger.annotationsList("@DiscriminatorMapping"); for (AnnotationInstance nested : annotation) { String propertyValue = JandexUtil.stringValue(nested, SchemaConstant.PROP_VALUE); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/schema/SchemaReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/schema/SchemaReader.java index a2165b4ce..bdde1f7fb 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/schema/SchemaReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/schema/SchemaReader.java @@ -54,7 +54,7 @@ public static Map readSchemas(final AnnotationScannerContext con if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@Schema"); + IoLogging.logger.annotationsMap("@Schema"); Map map = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -86,7 +86,7 @@ public static Schema readSchema(final JsonNode node) { if (node == null || !node.isObject()) { return null; } - IoLogging.log.singleJsonObject("Schema"); + IoLogging.logger.singleJsonObject("Schema"); String name = JsonUtil.stringProperty(node, SchemaConstant.PROP_NAME); Schema schema = new SchemaImpl(name); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/securityrequirement/SecurityRequirementReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/securityrequirement/SecurityRequirementReader.java index 2426c808d..2e27ed324 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/securityrequirement/SecurityRequirementReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/securityrequirement/SecurityRequirementReader.java @@ -42,7 +42,7 @@ private SecurityRequirementReader() { */ public static Optional> readSecurityRequirements(final AnnotationValue annotationValue) { if (annotationValue != null) { - IoLogging.log.annotationsArray("@SecurityRequirement"); + IoLogging.logger.annotationsArray("@SecurityRequirement"); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); List requirements = new ArrayList<>(); for (AnnotationInstance requirementAnno : nestedArray) { @@ -64,7 +64,7 @@ public static Optional> readSecurityRequirements(final */ public static Optional> readSecurityRequirements(final JsonNode node) { if (node != null && node.isArray()) { - IoLogging.log.jsonArray("SecurityRequirement"); + IoLogging.logger.jsonArray("SecurityRequirement"); List requirements = new ArrayList<>(node.size()); ArrayNode arrayNode = (ArrayNode) node; for (JsonNode arrayItem : arrayNode) { diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/securityscheme/SecuritySchemeReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/securityscheme/SecuritySchemeReader.java index 9a86f633c..9b52656a8 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/securityscheme/SecuritySchemeReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/securityscheme/SecuritySchemeReader.java @@ -47,7 +47,7 @@ public static Map readSecuritySchemes(final AnnotationVa if (annotationValue == null) { return null; } - IoLogging.log.annotationsMap("@SecurityScheme"); + IoLogging.logger.annotationsMap("@SecurityScheme"); Map securitySchemes = new LinkedHashMap<>(); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); for (AnnotationInstance nested : nestedArray) { @@ -92,7 +92,7 @@ public static SecurityScheme readSecurityScheme(final AnnotationInstance annotat if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotation("@SecurityScheme"); + IoLogging.logger.singleAnnotation("@SecurityScheme"); SecurityScheme securityScheme = new SecuritySchemeImpl(); securityScheme .setType(JandexUtil.enumValue(annotationInstance, SecuritySchemeConstant.PROP_TYPE, Type.class)); @@ -107,7 +107,7 @@ public static SecurityScheme readSecurityScheme(final AnnotationInstance annotat securityScheme .setOpenIdConnectUrl( JandexUtil.stringValue(annotationInstance, SecuritySchemeConstant.PROP_OPEN_ID_CONNECT_URL)); - securityScheme.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.SecurityScheme)); + securityScheme.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.SECURITY_SCHEME)); return securityScheme; } diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/server/ServerReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/server/ServerReader.java index bb7b03c67..733f34155 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/server/ServerReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/server/ServerReader.java @@ -40,7 +40,7 @@ private ServerReader() { */ public static Optional> readServers(final AnnotationValue annotationValue) { if (annotationValue != null) { - IoLogging.log.annotationsArray("@Server"); + IoLogging.logger.annotationsArray("@Server"); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); List servers = new ArrayList<>(); for (AnnotationInstance serverAnno : nestedArray) { @@ -59,7 +59,7 @@ public static Optional> readServers(final AnnotationValue annotatio */ public static Optional> readServers(final JsonNode node) { if (node != null && node.isArray()) { - IoLogging.log.jsonArray("Server"); + IoLogging.logger.jsonArray("Server"); ArrayNode nodes = (ArrayNode) node; List rval = new ArrayList<>(nodes.size()); for (JsonNode serverNode : nodes) { @@ -91,7 +91,7 @@ public static Server readServer(final AnnotationValue annotationValue) { */ public static Server readServer(final AnnotationInstance annotationInstance) { if (annotationInstance != null) { - IoLogging.log.singleAnnotation("@Server"); + IoLogging.logger.singleAnnotation("@Server"); Server server = new ServerImpl(); server.setUrl(JandexUtil.stringValue(annotationInstance, ServerConstant.PROP_URL)); server.setDescription(JandexUtil.stringValue(annotationInstance, ServerConstant.PROP_DESCRIPTION)); @@ -110,7 +110,7 @@ public static Server readServer(final AnnotationInstance annotationInstance) { */ public static Server readServer(final JsonNode node) { if (node != null && node.isObject()) { - IoLogging.log.singleJsonNode("Server"); + IoLogging.logger.singleJsonNode("Server"); Server server = new ServerImpl(); server.setUrl(JsonUtil.stringProperty(node, ServerConstant.PROP_URL)); server.setDescription(JsonUtil.stringProperty(node, ServerConstant.PROP_DESCRIPTION)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/servervariable/ServerVariableReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/servervariable/ServerVariableReader.java index be9b17a61..54ca08e26 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/servervariable/ServerVariableReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/servervariable/ServerVariableReader.java @@ -43,7 +43,7 @@ public static Map readServerVariables(final AnnotationVa if (annotationValue == null) { return null; } - IoLogging.log.annotationsArray("@ServerVariable"); + IoLogging.logger.annotationsArray("@ServerVariable"); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); Map variables = new LinkedHashMap<>(); for (AnnotationInstance serverVariableAnno : nestedArray) { @@ -65,7 +65,7 @@ public static Map readServerVariables(final JsonNode nod if (node == null) { return null; } - IoLogging.log.jsonNodeMap("ServerVariable"); + IoLogging.logger.jsonNodeMap("ServerVariable"); Map variables = new LinkedHashMap<>(); for (Iterator iterator = node.fieldNames(); iterator.hasNext();) { String fieldName = iterator.next(); @@ -88,7 +88,7 @@ private static ServerVariable readServerVariable(final AnnotationInstance annota if (annotationInstance == null) { return null; } - IoLogging.log.singleAnnotation("@ServerVariable"); + IoLogging.logger.singleAnnotation("@ServerVariable"); ServerVariable variable = new ServerVariableImpl(); variable.setDescription( JandexUtil.stringValue(annotationInstance, ServerVariableConstant.PROP_DESCRIPTION)); @@ -109,7 +109,7 @@ private static ServerVariable readServerVariable(JsonNode node) { if (node == null) { return null; } - IoLogging.log.singleJsonNode("ServerVariable"); + IoLogging.logger.singleJsonNode("ServerVariable"); ServerVariable variable = new ServerVariableImpl(); JsonNode enumNode = node.get(ServerVariableConstant.PROP_ENUM); if (enumNode != null && enumNode.isArray()) { diff --git a/core/src/main/java/io/smallrye/openapi/runtime/io/tag/TagReader.java b/core/src/main/java/io/smallrye/openapi/runtime/io/tag/TagReader.java index aab372b5e..368f8cc44 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/io/tag/TagReader.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/io/tag/TagReader.java @@ -44,7 +44,7 @@ private TagReader() { */ public static Optional> readTags(final AnnotationValue annotationValue) { if (annotationValue != null) { - IoLogging.log.annotationsArray("@Tag"); + IoLogging.logger.annotationsArray("@Tag"); AnnotationInstance[] nestedArray = annotationValue.asNestedArray(); List tags = new ArrayList<>(); for (AnnotationInstance tagAnno : nestedArray) { @@ -65,7 +65,7 @@ public static Optional> readTags(final AnnotationValue annotationValue */ public static Optional> readTags(final JsonNode node) { if (node != null && node.isArray()) { - IoLogging.log.jsonArray("Tag"); + IoLogging.logger.jsonArray("Tag"); ArrayNode nodes = (ArrayNode) node; List rval = new ArrayList<>(nodes.size()); for (JsonNode tagNode : nodes) { @@ -84,7 +84,7 @@ public static Optional> readTags(final JsonNode node) { */ public static Tag readTag(final AnnotationInstance annotationInstance) { Objects.requireNonNull(annotationInstance, "Tag annotation must not be null"); - IoLogging.log.singleAnnotation("@Tag"); + IoLogging.logger.singleAnnotation("@Tag"); Tag tag = new TagImpl(); tag.setName(JandexUtil.stringValue(annotationInstance, TagConstant.PROP_NAME)); tag.setDescription(JandexUtil.stringValue(annotationInstance, TagConstant.PROP_DESCRIPTION)); @@ -100,7 +100,7 @@ public static Tag readTag(final AnnotationInstance annotationInstance) { * @return Tag model */ private static Tag readTag(final JsonNode node) { - IoLogging.log.singleJsonNode("Tag"); + IoLogging.logger.singleJsonNode("Tag"); Tag tag = new TagImpl(); tag.setName(JsonUtil.stringProperty(node, TagConstant.PROP_NAME)); tag.setDescription(JsonUtil.stringProperty(node, TagConstant.PROP_DESCRIPTION)); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/OpenApiAnnotationScanner.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/OpenApiAnnotationScanner.java index f6a7e855f..2866fb574 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/OpenApiAnnotationScanner.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/OpenApiAnnotationScanner.java @@ -105,7 +105,7 @@ public OpenAPI scan() { // Now load all entry points with SPI and scan those List annotationScanners = annotationScannerFactory.getAnnotationScanners(); for (AnnotationScanner annotationScanner : annotationScanners) { - ScannerLogging.log.scanning(annotationScanner.getName()); + ScannerLogging.logger.scanning(annotationScanner.getName()); CurrentScannerInfo.register(annotationScanner); openApi = annotationScanner.scan(annotationScannerContext, openApi); } @@ -126,7 +126,7 @@ private OpenAPI scanMicroProfileOpenApiAnnotations() { getCustomSchemaRegistry(annotationScannerContext.getConfig()).registerCustomSchemas(schemaRegistry); // Find all OpenAPIDefinition annotations at the package level - ScannerLogging.log.scanning("OpenAPI"); + ScannerLogging.logger.scanning("OpenAPI"); processPackageOpenAPIDefinitions(annotationScannerContext, openApi); return openApi; diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/OpenApiDataObjectScanner.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/OpenApiDataObjectScanner.java index 99c020614..e66697ffa 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/OpenApiDataObjectScanner.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/OpenApiDataObjectScanner.java @@ -189,7 +189,7 @@ public static Schema process(PrimitiveType primitive) { * @return the OAI schema */ Schema process() { - ScannerLogging.log.startProcessing(rootClassType.name()); + ScannerLogging.logger.startProcessing(rootClassType.name()); // If top level item is simple if (TypeUtil.isTerminalType(rootClassType)) { @@ -253,7 +253,7 @@ private void depthFirstGraphSearch() { continue; } - ScannerLogging.log.gettingFields(currentType, currentClass); + ScannerLogging.logger.gettingFields(currentType, currentClass); // reference will be the field or method that declaring the current class type being scanned AnnotationTarget reference = currentPathEntry.getAnnotationTarget(); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/ScannerLogging.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/ScannerLogging.java index d1ea46f31..fa5b717b0 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/ScannerLogging.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/ScannerLogging.java @@ -11,7 +11,7 @@ @MessageLogger(projectCode = "SROAP", length = 5) interface ScannerLogging extends BasicLogger { - ScannerLogging log = Logger.getMessageLogger(ScannerLogging.class, ScannerLogging.class.getPackage().getName()); + ScannerLogging logger = Logger.getMessageLogger(ScannerLogging.class, ScannerLogging.class.getPackage().getName()); @LogMessage(level = Logger.Level.DEBUG) @Message(id = 4000, value = "Scanning deployment for %s Annotations.") diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/SchemaRegistry.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/SchemaRegistry.java index 3eac01479..2de03fc02 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/SchemaRegistry.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/SchemaRegistry.java @@ -265,13 +265,13 @@ private SchemaRegistry(OpenApiConfig config, OpenAPI oai, IndexView index) { try { schema = OpenApiParser.parseSchema(jsonSchema); } catch (Exception e) { - ScannerLogging.log.errorParsingSchema(className); + ScannerLogging.logger.errorParsingSchema(className); return; } Type type = Type.create(DotName.createSimple(className), Type.Kind.CLASS); this.register(new TypeKey(type), schema, ((SchemaImpl) schema).getName()); - ScannerLogging.log.configSchemaRegistered(className); + ScannerLogging.logger.configSchemaRegistered(className); }); } diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/AnnotationTargetProcessor.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/AnnotationTargetProcessor.java index 5bda81505..20d2f80a3 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/AnnotationTargetProcessor.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/AnnotationTargetProcessor.java @@ -195,7 +195,7 @@ Schema processField() { } private Schema readSchemaAnnotatedField(String propertyKey, AnnotationInstance annotation, Type postProcessedField) { - DataObjectLogging.log.processingFieldAnnotation(annotation, propertyKey); + DataObjectLogging.logger.processingFieldAnnotation(annotation, propertyKey); // If "required" attribute is on field. It should be applied to the *parent* schema. // Required is false by default. diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/BeanValidationScanner.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/BeanValidationScanner.java index 78338f809..ff6e9b48c 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/BeanValidationScanner.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/BeanValidationScanner.java @@ -38,14 +38,9 @@ public interface RequirementHandler { static final DotName BV_CONTRAINTS = createComponentized(BV_BASE, "constraints"); - //static final DotName BV_ASSERT_TRUE = createComponentized(BV_CONTRAINTS, "AssertTrue"); - //static final DotName BV_ASSERT_FALSE = createComponentized(BV_CONTRAINTS, "AssertFalse"); static final DotName BV_DECIMAL_MAX = createComponentized(BV_CONTRAINTS, "DecimalMax"); static final DotName BV_DECIMAL_MIN = createComponentized(BV_CONTRAINTS, "DecimalMin"); static final DotName BV_DIGITS = createComponentized(BV_CONTRAINTS, "Digits"); - //static final DotName BV_EMAIL = createComponentized(BV_CONTRAINTS, "Email"); - //static final DotName BV_FUTURE = createComponentized(BV_CONTRAINTS, "Future"); - //static final DotName BV_FUTURE_OR_PRESENT = createComponentized(BV_CONTRAINTS, "FutureOrPresent"); static final DotName BV_MAX = createComponentized(BV_CONTRAINTS, "Max"); static final DotName BV_MIN = createComponentized(BV_CONTRAINTS, "Min"); static final DotName BV_NEGATIVE = createComponentized(BV_CONTRAINTS, "Negative"); @@ -53,10 +48,6 @@ public interface RequirementHandler { static final DotName BV_NOT_BLANK = createComponentized(BV_CONTRAINTS, "NotBlank"); static final DotName BV_NOT_EMPTY = createComponentized(BV_CONTRAINTS, "NotEmpty"); static final DotName BV_NOT_NULL = createComponentized(BV_CONTRAINTS, "NotNull"); - //static final DotName BV_NULL = createComponentized(BV_CONTRAINTS, "Null"); - //static final DotName BV_PAST = createComponentized(BV_CONTRAINTS, "Past"); - //static final DotName BV_PAST_OR_PRESENT = createComponentized(BV_CONTRAINTS, "PastOrPresent"); - //static final DotName BV_PATTERN = createComponentized(BV_CONTRAINTS, "Pattern"); static final DotName BV_POSITIVE = createComponentized(BV_CONTRAINTS, "Positive"); static final DotName BV_POSITIVE_OR_ZERO = createComponentized(BV_CONTRAINTS, "PositiveOrZero"); static final DotName BV_SIZE = createComponentized(BV_CONTRAINTS, "Size"); @@ -187,11 +178,11 @@ void decimalMax(AnnotationTarget target, Schema schema) { Optional inclusive = booleanValue(constraint, INCLUSIVE); - if (schema.getExclusiveMaximum() == null && inclusive.isPresent() && !inclusive.get()) { + if (schema.getExclusiveMaximum() == null && inclusive.isPresent() && !inclusive.get().booleanValue()) { schema.setExclusiveMaximum(Boolean.TRUE); } } catch (@SuppressWarnings("unused") NumberFormatException e) { - DataObjectLogging.log.invalidAnnotationFormat(decimalValue); + DataObjectLogging.logger.invalidAnnotationFormat(decimalValue); } } } @@ -206,11 +197,11 @@ void decimalMin(AnnotationTarget target, Schema schema) { schema.setMinimum(decimal); Optional inclusive = booleanValue(constraint, INCLUSIVE); - if (schema.getExclusiveMinimum() == null && inclusive.isPresent() && !inclusive.get()) { + if (schema.getExclusiveMinimum() == null && inclusive.isPresent() && !inclusive.get().booleanValue()) { schema.setExclusiveMinimum(Boolean.TRUE); } } catch (@SuppressWarnings("unused") NumberFormatException e) { - DataObjectLogging.log.invalidAnnotationFormat(decimalValue); + DataObjectLogging.logger.invalidAnnotationFormat(decimalValue); } } diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/DataObjectDeque.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/DataObjectDeque.java index ffb80c9ca..210311e4a 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/DataObjectDeque.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/DataObjectDeque.java @@ -88,14 +88,14 @@ public void push(AnnotationTarget annotationTarget, ClassInfo klazzInfo = entry.getClazz(); if (parentPathEntry.hasParent(entry)) { // Cycle detected, don't push path. - DataObjectLogging.log.possibleCycle(klazzInfo); - DataObjectLogging.log.path(entry.toStringWithGraph()); + DataObjectLogging.logger.possibleCycle(klazzInfo); + DataObjectLogging.logger.path(entry.toStringWithGraph()); if (schema.getDescription() == null) { schema.description("Cyclic reference to " + klazzInfo.name()); } } else { // Push path to be inspected later. - DataObjectLogging.log.addingChildNode(klazzInfo); + DataObjectLogging.logger.addingChildNode(klazzInfo); path.push(entry); } } diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/DataObjectLogging.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/DataObjectLogging.java index 9b64472c7..5c7448600 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/DataObjectLogging.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/DataObjectLogging.java @@ -16,7 +16,7 @@ @MessageLogger(projectCode = "SROAP", length = 5) interface DataObjectLogging extends BasicLogger { - DataObjectLogging log = Logger.getMessageLogger(DataObjectLogging.class, DataObjectLogging.class.getPackage().getName()); + DataObjectLogging logger = Logger.getMessageLogger(DataObjectLogging.class, DataObjectLogging.class.getPackage().getName()); @LogMessage(level = Logger.Level.DEBUG) @Message(id = 6000, value = "Processing @Schema annotation %s on a field %s") diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/IgnoreResolver.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/IgnoreResolver.java index d386f1503..71c712524 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/IgnoreResolver.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/IgnoreResolver.java @@ -260,14 +260,14 @@ public Visibility shouldIgnore(AnnotationTarget target, AnnotationTarget referen ClassInfo classInfo = index.getClass(classType); if (ignoredTypes.contains(classInfo.name())) { - DataObjectLogging.log.ignoringType(classInfo.name()); + DataObjectLogging.logger.ignoringType(classInfo.name()); return Visibility.IGNORED; } AnnotationInstance annotationInstance = TypeUtil.getAnnotation(classInfo, getName()); if (annotationInstance != null && valueAsBooleanOrTrue(annotationInstance)) { // Add the ignored field or class name - DataObjectLogging.log.ignoringTypeAndAddingToSet(classInfo.name()); + DataObjectLogging.logger.ignoringTypeAndAddingToSet(classInfo.name()); ignoredTypes.add(classInfo.name()); return Visibility.IGNORED; } diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeProcessor.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeProcessor.java index c03e6d00e..4b4144aa8 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeProcessor.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeProcessor.java @@ -79,7 +79,7 @@ public Type processType() { } if (type.kind() == Type.Kind.ARRAY) { - DataObjectLogging.log.processingArray(type); + DataObjectLogging.logger.processingArray(type); ArrayType arrayType = type.asArrayType(); // Array-type schema @@ -150,19 +150,19 @@ public Type processType() { } else { // If the type is not in Jandex then we don't have easy access to it. // Future work could consider separate code to traverse classes reachable from this classloader. - DataObjectLogging.log.typeNotInJandexIndex(type); + DataObjectLogging.logger.typeNotInJandexIndex(type); } return type; } private Type readParameterizedType(ParameterizedType pType) { - DataObjectLogging.log.processingParametrizedType(pType); + DataObjectLogging.logger.processingParametrizedType(pType); Type typeRead = pType; // If it's a collection, we should treat it as an array. if (isA(pType, COLLECTION_TYPE) || isA(pType, ITERABLE_TYPE)) { - DataObjectLogging.log.processingTypeAs("Java Collection", "Array"); + DataObjectLogging.logger.processingTypeAs("Java Collection", "Array"); Schema arraySchema = new SchemaImpl(); schema.type(Schema.SchemaType.ARRAY); @@ -183,7 +183,7 @@ private Type readParameterizedType(ParameterizedType pType) { typeRead = ARRAY_TYPE_OBJECT; // Representing collection as JSON array } else if (isA(pType, MAP_TYPE)) { - DataObjectLogging.log.processingTypeAs("Map", "object"); + DataObjectLogging.logger.processingTypeAs("Map", "object"); schema.type(Schema.SchemaType.OBJECT); if (pType.arguments().size() == 2) { @@ -217,7 +217,7 @@ private Schema resolveParameterizedType(Type valueType, Schema propsSchema) { } } else if (index.containsClass(valueType)) { if (isA(valueType, ENUM_TYPE)) { - DataObjectLogging.log.processingEnum(type); + DataObjectLogging.logger.processingEnum(type); propsSchema = SchemaFactory.enumToSchema(index, cl, valueType); pushToStack(valueType); } else { @@ -234,10 +234,10 @@ private Schema resolveParameterizedType(Type valueType, Schema propsSchema) { private Type resolveTypeVariable(Schema schema, Type fieldType, boolean pushToStack) { // Type variable (e.g. A in Foo) Type resolvedType = typeResolver.getResolvedType(fieldType); - DataObjectLogging.log.resolvedType(fieldType, resolvedType); + DataObjectLogging.logger.resolvedType(fieldType, resolvedType); if (isTerminalType(resolvedType) || !index.containsClass(resolvedType)) { - DataObjectLogging.log.terminalType(resolvedType); + DataObjectLogging.logger.terminalType(resolvedType); TypeUtil.applyTypeAttributes(resolvedType, schema); } else if (pushToStack) { // Add resolved type to stack. diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeResolver.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeResolver.java index 249559708..bdd1b5f47 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeResolver.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeResolver.java @@ -776,7 +776,7 @@ private static Map buildParamTypeResolutionMap(ClassInfo klazz, Pa List arguments = parameterizedType.arguments(); if (arguments.size() != typeVariables.size()) { - DataObjectLogging.log.classNotAvailable(typeVariables, arguments); + DataObjectLogging.logger.classNotAvailable(typeVariables, arguments); } Map resolutionMap = new LinkedHashMap<>(); diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java index 9f70197a8..9cfdb734e 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java @@ -126,9 +126,6 @@ protected static class ParameterContext { public AnnotationTarget target; public Type targetType; - public ParameterContext() { - } - @Override public String toString() { return "name: " + name + "; in: " + location + "; target: " + target; diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AnnotationScanner.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AnnotationScanner.java index 3d9071e72..d964d7180 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AnnotationScanner.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AnnotationScanner.java @@ -554,9 +554,7 @@ default boolean responseCodeExistInMethodAnnotations(AnnotationInstance exMapper return methodApiResponseAnnotations.stream() .map(ResponseReader::getResponseName) .filter(Objects::nonNull) - .filter(code -> code.equals(exMapperResponseCode)) - .findFirst() - .isPresent(); + .anyMatch(code -> code.equals(exMapperResponseCode)); } /** diff --git a/core/src/main/java/io/smallrye/openapi/runtime/util/JandexUtil.java b/core/src/main/java/io/smallrye/openapi/runtime/util/JandexUtil.java index cbe53a004..d8895e961 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/util/JandexUtil.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/util/JandexUtil.java @@ -2,7 +2,6 @@ import static java.util.stream.Collectors.toList; -import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -42,15 +41,15 @@ public class JandexUtil { * @author eric.wittmann@gmail.com */ public enum RefType { - Header("headers"), - Schema("schemas"), - SecurityScheme("securitySchemes"), - Callback("callbacks"), - Link("links"), - Response("responses"), - Parameter("parameters"), - Example("examples"), - RequestBody("requestBodies"); + HEADER("headers"), + SCHEMA("schemas"), + SECURITY_SCHEME("securitySchemes"), + CALLBACK("callbacks"), + LINK("links"), + RESPONSE("responses"), + PARAMETER("parameters"), + EXAMPLE("examples"), + REQUEST_BODY("requestBodies"); String componentPath; @@ -198,29 +197,6 @@ public static boolean booleanValueWithDefault(AnnotationInstance annotation, Str return value != null && value.asBoolean(); } - /** - * Reads a Double property value from the given annotation instance. If no value is found - * this will return null. - * - * @param annotation AnnotationInstance - * @param propertyName String - * @return BigDecimal value - */ - public static BigDecimal bigDecimalValue(AnnotationInstance annotation, String propertyName) { - AnnotationValue value = annotation.value(propertyName); - if (value == null) { - return null; - } - if (value.kind() == AnnotationValue.Kind.DOUBLE) { - return BigDecimal.valueOf(value.asDouble()); - } - if (value.kind() == AnnotationValue.Kind.STRING) { - return new BigDecimal(value.asString()); - } - throw new RuntimeException( - "Call to bigDecimalValue failed because the annotation property was not a double or a String."); - } - /** * Reads a Integer property value from the given annotation instance. If no value is found * this will return null. diff --git a/core/src/main/java/io/smallrye/openapi/spi/OASFactoryResolverImpl.java b/core/src/main/java/io/smallrye/openapi/spi/OASFactoryResolverImpl.java index b9ef1452f..85260106c 100644 --- a/core/src/main/java/io/smallrye/openapi/spi/OASFactoryResolverImpl.java +++ b/core/src/main/java/io/smallrye/openapi/spi/OASFactoryResolverImpl.java @@ -1,5 +1,6 @@ package io.smallrye.openapi.spi; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; @@ -119,13 +120,17 @@ public T createObject(Class clazz) { if (clazz == null) { throw new NullPointerException(); } + + Class implClass = registry.get(clazz); + + if (implClass == null) { + throw SpiMessages.msg.classNotConstructible(clazz.getName()); + } + try { - Class implClass = registry.get(clazz); - if (implClass == null) { - throw SpiMessages.msg.classNotConstructible(clazz.getName()); - } - return (T) implClass.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + return (T) implClass.getConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | SecurityException e) { throw new IllegalArgumentException(e); } } diff --git a/extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/util/JandexUtilTests.java b/extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/util/JandexUtilTests.java index 09a629686..4fc67a386 100644 --- a/extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/util/JandexUtilTests.java +++ b/extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/util/JandexUtilTests.java @@ -41,7 +41,7 @@ public void testRefValueWithHttpUrl() { AnnotationInstance annotation = AnnotationInstance.create(DotName.createSimple(""), null, Arrays.asList(AnnotationValue.createStringValue("ref", ref))); - String outRef = JandexUtil.refValue(annotation, RefType.Link); + String outRef = JandexUtil.refValue(annotation, RefType.LINK); assertEquals(ref, outRef); } @@ -51,7 +51,7 @@ public void testRefValueWithRelativeUrl() { AnnotationInstance annotation = AnnotationInstance.create(DotName.createSimple(""), null, Arrays.asList(AnnotationValue.createStringValue("ref", ref))); - String outRef = JandexUtil.refValue(annotation, RefType.Link); + String outRef = JandexUtil.refValue(annotation, RefType.LINK); assertEquals(ref, outRef); } @@ -61,7 +61,7 @@ public void testRefValueWithValidLinkName() { AnnotationInstance annotation = AnnotationInstance.create(DotName.createSimple(""), null, Arrays.asList(AnnotationValue.createStringValue("ref", ref))); - String outRef = JandexUtil.refValue(annotation, RefType.Link); + String outRef = JandexUtil.refValue(annotation, RefType.LINK); assertEquals("#/components/links/L1nk.T0_Something-Useful", outRef); } diff --git a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringAnnotationScanner.java b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringAnnotationScanner.java index 8ff6190ea..7915979f4 100644 --- a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringAnnotationScanner.java +++ b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringAnnotationScanner.java @@ -300,8 +300,8 @@ private void processControllerMethod(final AnnotationScannerContext context, SpringLogging.log.processingMethod(method.toString()); // Figure out the current @Produces and @Consumes (if any) - CurrentScannerInfo.setCurrentConsumes(getMediaTypes(method, MediaTypeProperty.consumes).orElse(null)); - CurrentScannerInfo.setCurrentProduces(getMediaTypes(method, MediaTypeProperty.produces).orElse(null)); + CurrentScannerInfo.setCurrentConsumes(getMediaTypes(method, SpringConstants.MAPPING_CONSUMES).orElse(null)); + CurrentScannerInfo.setCurrentProduces(getMediaTypes(method, SpringConstants.MAPPING_PRODUCES).orElse(null)); // Process any @Operation annotation Optional maybeOperation = processOperation(context, method); @@ -364,18 +364,18 @@ private void processControllerMethod(final AnnotationScannerContext context, } } - static Optional getMediaTypes(MethodInfo resourceMethod, MediaTypeProperty property) { + static Optional getMediaTypes(MethodInfo resourceMethod, String property) { Set annotationNames = SpringConstants.HTTP_METHODS; for (DotName annotationName : annotationNames) { AnnotationInstance annotation = resourceMethod.annotation(annotationName); - if (annotation == null || annotation.value(property.name()) == null) { + if (annotation == null || annotation.value(property) == null) { annotation = JandexUtil.getClassAnnotation(resourceMethod.declaringClass(), SpringConstants.REQUEST_MAPPING); } if (annotation != null) { - AnnotationValue annotationValue = annotation.value(property.name()); + AnnotationValue annotationValue = annotation.value(property); if (annotationValue != null) { return Optional.of(annotationValue.asStringArray()); @@ -386,9 +386,4 @@ static Optional getMediaTypes(MethodInfo resourceMethod, MediaTypeProp } return Optional.empty(); } - - enum MediaTypeProperty { - consumes, - produces - } } diff --git a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringConstants.java b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringConstants.java index 440af9399..b6f0b2e93 100644 --- a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringConstants.java +++ b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringConstants.java @@ -9,7 +9,7 @@ /** * Constants related to Spring - * + * * @author Phillip Kruger (phillip.kruger@redhat.com) */ public class SpringConstants { @@ -48,6 +48,9 @@ public class SpringConstants { DELETE_MAPPING, PATCH_MAPPING))); + public static final String MAPPING_CONSUMES = "consumes"; + public static final String MAPPING_PRODUCES = "produces"; + private SpringConstants() { } } diff --git a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxAnnotationScanner.java b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxAnnotationScanner.java index 16d82decd..48da97877 100644 --- a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxAnnotationScanner.java +++ b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxAnnotationScanner.java @@ -256,8 +256,8 @@ private void processRouteMethod(final AnnotationScannerContext context, VertxLogging.log.processingMethod(method.toString()); // Figure out the current @Produces and @Consumes (if any) - CurrentScannerInfo.setCurrentConsumes(getMediaTypes(method, MediaTypeProperty.consumes).orElse(null)); - CurrentScannerInfo.setCurrentProduces(getMediaTypes(method, MediaTypeProperty.produces).orElse(null)); + CurrentScannerInfo.setCurrentConsumes(getMediaTypes(method, VertxConstants.ROUTE_CONSUMES).orElse(null)); + CurrentScannerInfo.setCurrentProduces(getMediaTypes(method, VertxConstants.ROUTE_PRODUCES).orElse(null)); // Process any @Operation annotation Optional maybeOperation = processOperation(context, method); @@ -334,17 +334,17 @@ static boolean shouldScan(MethodInfo resourceMethod) { return true; } - static Optional getMediaTypes(MethodInfo resourceMethod, MediaTypeProperty property) { + static Optional getMediaTypes(MethodInfo resourceMethod, String property) { DotName annotationName = VertxConstants.ROUTE; AnnotationInstance annotation = resourceMethod.annotation(annotationName); - if (annotation == null || annotation.value(property.name()) == null) { + if (annotation == null || annotation.value(property) == null) { annotation = JandexUtil.getClassAnnotation(resourceMethod.declaringClass(), VertxConstants.ROUTE_BASE); } if (annotation != null) { - AnnotationValue annotationValue = annotation.value(property.name()); + AnnotationValue annotationValue = annotation.value(property); if (annotationValue != null) { return Optional.of(annotationValue.asStringArray()); @@ -356,8 +356,4 @@ static Optional getMediaTypes(MethodInfo resourceMethod, MediaTypeProp return Optional.empty(); } - enum MediaTypeProperty { - consumes, - produces - } } diff --git a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxConstants.java b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxConstants.java index ef279835a..d58d8c018 100644 --- a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxConstants.java +++ b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxConstants.java @@ -37,6 +37,9 @@ public class VertxConstants { R_HTTP_SERVER_REQUEST, R_HTTP_SERVER_RESPONSE)); + public static final String ROUTE_CONSUMES = "consumes"; + public static final String ROUTE_PRODUCES = "produces"; + private VertxConstants() { } } From 617afbe0a73d65eec4f0e85ed3cc0f0658ba3525 Mon Sep 17 00:00:00 2001 From: Michael Edgar Date: Fri, 14 Aug 2020 22:25:54 -0400 Subject: [PATCH 2/4] Rename framework parameter compilation units --- .../{ParameterProcessor.java => JaxRsParameterProcessor.java} | 0 .../{ParameterProcessor.java => SpringParameterProcessor.java} | 0 .../{ParameterProcessor.java => VertxParameterProcessor.java} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/{ParameterProcessor.java => JaxRsParameterProcessor.java} (100%) rename extension-spring/src/main/java/io/smallrye/openapi/spring/{ParameterProcessor.java => SpringParameterProcessor.java} (100%) rename extension-vertx/src/main/java/io/smallrye/openapi/vertx/{ParameterProcessor.java => VertxParameterProcessor.java} (100%) diff --git a/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/ParameterProcessor.java b/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsParameterProcessor.java similarity index 100% rename from extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/ParameterProcessor.java rename to extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsParameterProcessor.java diff --git a/extension-spring/src/main/java/io/smallrye/openapi/spring/ParameterProcessor.java b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java similarity index 100% rename from extension-spring/src/main/java/io/smallrye/openapi/spring/ParameterProcessor.java rename to extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java diff --git a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/ParameterProcessor.java b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java similarity index 100% rename from extension-vertx/src/main/java/io/smallrye/openapi/vertx/ParameterProcessor.java rename to extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java From 4b9d4d83aa00fb65364abd3c8ece07e5a55906fe Mon Sep 17 00:00:00 2001 From: Michael Edgar Date: Fri, 14 Aug 2020 22:26:33 -0400 Subject: [PATCH 3/4] Update references to renamed `ParameterProcessor`s --- .../io/smallrye/openapi/jaxrs/JaxRsAnnotationScanner.java | 4 ++-- .../io/smallrye/openapi/jaxrs/JaxRsParameterProcessor.java | 6 +++--- .../io/smallrye/openapi/spring/SpringAnnotationScanner.java | 4 ++-- .../smallrye/openapi/spring/SpringParameterProcessor.java | 6 +++--- .../io/smallrye/openapi/vertx/VertxAnnotationScanner.java | 2 +- .../io/smallrye/openapi/vertx/VertxParameterProcessor.java | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsAnnotationScanner.java b/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsAnnotationScanner.java index ce808c4b8..61a308426 100644 --- a/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsAnnotationScanner.java +++ b/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsAnnotationScanner.java @@ -330,7 +330,7 @@ private void processSubResource(final AnnotationScannerContext context, if (subResourceClass != null && !this.subResourceStack.contains(locator)) { Function reader = t -> ParameterReader.readParameter(context, t); - ResourceParameters params = ParameterProcessor.process(context, resourceClass, method, + ResourceParameters params = JaxRsParameterProcessor.process(context, resourceClass, method, reader, context.getExtensions()); final String originalAppPath = this.currentAppPath; @@ -399,7 +399,7 @@ private void processResourceMethod(final AnnotationScannerContext context, // Process @Parameter annotations. Function reader = t -> ParameterReader.readParameter(context, t); - ResourceParameters params = ParameterProcessor.process(context, resourceClass, method, + ResourceParameters params = JaxRsParameterProcessor.process(context, resourceClass, method, reader, context.getExtensions()); operation.setParameters(params.getOperationParameters()); diff --git a/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsParameterProcessor.java b/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsParameterProcessor.java index a590927d8..a30eaacf8 100644 --- a/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsParameterProcessor.java +++ b/extension-jaxrs/src/main/java/io/smallrye/openapi/jaxrs/JaxRsParameterProcessor.java @@ -35,7 +35,7 @@ * @author Michael Edgar {@literal } * */ -public class ParameterProcessor extends AbstractParameterProcessor { +public class JaxRsParameterProcessor extends AbstractParameterProcessor { /** * Pattern to describe a path template parameter with a regular expression pattern restriction. @@ -48,7 +48,7 @@ public class ParameterProcessor extends AbstractParameterProcessor { static final Pattern TEMPLATE_PARAM_PATTERN = Pattern .compile("\\{[ \\t]*(\\w[\\w\\.-]*)[ \\t]*:[ \\t]*((?:[^{}]|\\{[^{}]+\\})+)\\}"); //NOSONAR - private ParameterProcessor(AnnotationScannerContext scannerContext, + private JaxRsParameterProcessor(AnnotationScannerContext scannerContext, Function reader, List extensions) { super(scannerContext, reader, extensions); @@ -76,7 +76,7 @@ public static ResourceParameters process(AnnotationScannerContext context, Function reader, List extensions) { - ParameterProcessor processor = new ParameterProcessor(context, reader, extensions); + JaxRsParameterProcessor processor = new JaxRsParameterProcessor(context, reader, extensions); return processor.process(resourceClass, resourceMethod, reader); } diff --git a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringAnnotationScanner.java b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringAnnotationScanner.java index 7915979f4..f8b051c3a 100644 --- a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringAnnotationScanner.java +++ b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringAnnotationScanner.java @@ -199,7 +199,7 @@ private OpenAPI processControllerClass(final AnnotationScannerContext context, C SpringConstants.REQUEST_MAPPING); if (requestMappingAnnotation != null) { - this.currentAppPath = ParameterProcessor.requestMappingValuesToPath(requestMappingAnnotation); + this.currentAppPath = SpringParameterProcessor.requestMappingValuesToPath(requestMappingAnnotation); } else { this.currentAppPath = "/"; } @@ -316,7 +316,7 @@ private void processControllerMethod(final AnnotationScannerContext context, // Process @Parameter annotations. PathItem pathItem = new PathItemImpl(); Function reader = t -> ParameterReader.readParameter(context, t); - ResourceParameters params = ParameterProcessor.process(context, resourceClass, + ResourceParameters params = SpringParameterProcessor.process(context, resourceClass, method, reader, context.getExtensions()); operation.setParameters(params.getOperationParameters()); diff --git a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java index 65880eefa..8dd1edf50 100644 --- a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java +++ b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java @@ -33,7 +33,7 @@ * * @author Phillip Kruger (phillip.kruger@redhat.com) */ -public class ParameterProcessor extends AbstractParameterProcessor { +public class SpringParameterProcessor extends AbstractParameterProcessor { /** * Sonar validation is disabled on this expression because there is no danger of denial of @@ -42,7 +42,7 @@ public class ParameterProcessor extends AbstractParameterProcessor { static final Pattern TEMPLATE_PARAM_PATTERN = Pattern .compile("\\{[ \\t]*(\\w[\\w\\.-]*)[ \\t]*:[ \\t]*((?:[^{}]|\\{[^{}]+\\})+)\\}"); //NOSONAR - private ParameterProcessor(AnnotationScannerContext scannerContext, + private SpringParameterProcessor(AnnotationScannerContext scannerContext, Function reader, List extensions) { super(scannerContext, reader, extensions); @@ -71,7 +71,7 @@ public static ResourceParameters process(AnnotationScannerContext context, Function reader, List extensions) { - ParameterProcessor processor = new ParameterProcessor(context, reader, extensions); + SpringParameterProcessor processor = new SpringParameterProcessor(context, reader, extensions); return processor.process(resourceClass, resourceMethod, reader); } diff --git a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxAnnotationScanner.java b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxAnnotationScanner.java index 48da97877..e7c9a683a 100644 --- a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxAnnotationScanner.java +++ b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxAnnotationScanner.java @@ -273,7 +273,7 @@ private void processRouteMethod(final AnnotationScannerContext context, PathItem pathItem = new PathItemImpl(); Function reader = t -> ParameterReader.readParameter(context, t); - ResourceParameters params = ParameterProcessor.process(context, resourceClass, + ResourceParameters params = VertxParameterProcessor.process(context, resourceClass, method, reader, context.getExtensions()); operation.setParameters(params.getOperationParameters()); diff --git a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java index 12ce0c34a..52969ab43 100644 --- a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java +++ b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java @@ -34,7 +34,7 @@ * * @author Phillip Kruger (phillip.kruger@redhat.com) */ -public class ParameterProcessor extends AbstractParameterProcessor { +public class VertxParameterProcessor extends AbstractParameterProcessor { /** * Sonar validation is disabled on this expression because there is no danger of denial of @@ -43,7 +43,7 @@ public class ParameterProcessor extends AbstractParameterProcessor { static final Pattern TEMPLATE_PARAM_PATTERN = Pattern .compile(":[ \\t]*(\\w[\\w\\.-]*)[ \\t]*:[ \\t]*((?:[^{}]|\\{[^{}]+\\})+)"); //NOSONAR - private ParameterProcessor(AnnotationScannerContext scannerContext, + private VertxParameterProcessor(AnnotationScannerContext scannerContext, Function reader, List extensions) { super(scannerContext, reader, extensions); @@ -71,7 +71,7 @@ public static ResourceParameters process(AnnotationScannerContext context, Function reader, List extensions) { - ParameterProcessor processor = new ParameterProcessor(context, reader, extensions); + VertxParameterProcessor processor = new VertxParameterProcessor(context, reader, extensions); return processor.process(resourceClass, resourceMethod, reader); } From 972ff8eff67523921811528a8b8de6fd3625b174 Mon Sep 17 00:00:00 2001 From: Michael Edgar Date: Mon, 17 Aug 2020 07:10:15 -0400 Subject: [PATCH 4/4] Fix JavaDoc errors --- .../spi/AbstractParameterProcessor.java | 54 ++++++++++--------- .../spring/SpringParameterProcessor.java | 3 +- .../vertx/VertxParameterProcessor.java | 2 +- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java index 9cfdb734e..e82f97ab5 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java @@ -63,8 +63,8 @@ /** * - * Note, {@link javax.ws.rs.PathParam PathParam} targets of - * {@link javax.ws.rs.core.PathSegment PathSegment} are not currently supported. + * Common parameter processing that may be customized by individual frameworks + * such as JAX-RS, Spring, Vert.x, etc. * * @author Michael Edgar {@literal } * @@ -257,8 +257,8 @@ protected void processFinalize(ClassInfo resourceClass, MethodInfo resourceMetho * Add the name of any discovered matrix parameters. * * @param target the target (either class or method) - * @param parameters - * @return + * @param parameters list of all parameters processed + * @return the path for the target */ protected String generatePath(AnnotationTarget target, List parameters) { final StringBuilder path = new StringBuilder(pathOf(target)); @@ -341,7 +341,8 @@ boolean templateParameterPatternEligible(Parameter param) { /** * Performs the final merging of framework parameters with MP-OAI parameters to produce the list * of {@link Parameter}s found while scanning the current level (class or method). - * + * + * @param resourceMethod the method to which the returned parameters are applicable * @return list of {@link Parameter}s */ protected List getParameters(MethodInfo resourceMethod) { @@ -515,13 +516,13 @@ protected void setSchemaProperties(Schema schema, } /** - * Create a {@link Content} and use the scanned {@link javax.ws.rs.FormParam}s - * as the properties. The media type will be defaulted to - * 'application/x-www-form-urlencoded' or set to 'multipart/form-data' if a - * RESTEasy {@link org.jboss.resteasy.annotations.providers.multipart.MultipartForm MultipartForm} - * annotation was used to wrap the {@link javax.ws.rs.FormParam}s. The encoding values - * for the {@link Content} will be set to the value of any - * {@link org.jboss.resteasy.annotations.providers.multipart.PartType PartType} + * Create a {@link Content} and use the scanned form parameters + * as the properties. The media type will be determined by the framework's + * subclass - e.g. for JAX-RS it may be defaulted to 'application/x-www-form-urlencoded' or set + * to 'multipart/form-data' if a + * RESTEasy MultipartForm + * annotation was used to wrap the javax.ws.rs.FormParams. The encoding values + * for the {@link Content} will be set to the value of any RESTEasy PartType * annotations found for each parameter. * * @return generated form content @@ -556,12 +557,12 @@ protected String getDefaultFormMediaType() { /** * Determine if the paramTarget is annotated with the RestEasy - * {@link org.jboss.resteasy.annotations.providers.multipart.PartType @PartType} + * PartType * annotation and add the value to the encodings map. * * @param encodings map of encodings applicable to the current {@link MediaType} being processed * @param paramName name of the current form parameter being mapped to a schema property - * @param paramTarget the target annotated with {@link javax.ws.rs.FormParam FormParam} + * @param paramTarget the target annotated with the framework's form annotation * */ protected void addEncoding(Map encodings, String paramName, AnnotationTarget paramTarget) { @@ -648,8 +649,10 @@ static boolean parameterInPath(String paramName, Style paramStyle, String resour } /** - * Read a single annotation that is either {@link @Parameter} or - * {@link @Parameters}. The results are stored in the private {@link #params} + * Read a single annotation that is either {@link org.eclipse.microprofile.openapi.annotations.parameters.Parameter + * {@literal @}Parameter} or + * {@link org.eclipse.microprofile.openapi.annotations.parameters.Parameters {@literal @}Parameters}. The results are stored + * in the private {@link #params} * collection. * * @param annotation a parameter annotation to be read and processed @@ -679,7 +682,8 @@ protected void readParameterAnnotation(AnnotationInstance annotation) { } /** - * Read a single annotation that is either {@link @Parameter} or + * Read a single annotation that is either {@link org.eclipse.microprofile.openapi.annotations.parameters.Parameter + * {@literal @}Parameter} or * one of the framework parameter annotations. The results are stored in the * private {@link #params} collection, depending on the type of parameter. * @@ -690,13 +694,14 @@ protected void readAnnotatedType(AnnotationInstance annotation) { } /** - * Read a single annotation that is either {@link @Parameter} or + * Read a single annotation that is either {@link org.eclipse.microprofile.openapi.annotations.parameters.Parameter + * {@literal @}Parameter} or * one of the framework parameter annotations. The results are stored in the * private {@link #params} collection. When overriddenParametersOnly is true, * new parameters not already known in {@link #params} will be ignored. * * @param annotation a parameter annotation to be read and processed - * @param beanParamAnnotation + * @param beanParamAnnotation a framework's bean-type (POJO) parameter annotation * @param overriddenParametersOnly true if only parameters already known to the scanner are considered, false otherwise */ protected abstract void readAnnotatedType(AnnotationInstance annotation, AnnotationInstance beanParamAnnotation, @@ -924,7 +929,7 @@ protected String fullPathOf(AnnotationTarget target) { * Concatenate the method's path with the path of its declaring * class. * - * @param method the method annotated with {@link javax.ws.rs.Path Path} + * @param method the method annotated with the framework's path annotation */ String methodPath(MethodInfo method) { String methodPath = pathOf(method); @@ -938,11 +943,11 @@ String methodPath(MethodInfo method) { } /** - * Reads the {@link javax.ws.rs.Path @Path} annotation present on the + * Reads the framework's path annotation present on the * target and strips leading and trailing slashes. * * @param target target object - * @return value of the {@link javax.ws.rs.Path @Path} without + * @return value of the framework's path annotation without * leading/trailing slashes. */ protected abstract String pathOf(AnnotationTarget target); @@ -999,8 +1004,7 @@ protected static Type getType(AnnotationTarget target) { * @param key the key for the parameter being processed * @param oaiParam scanned {@link org.eclipse.microprofile.openapi.annotations.parameters.Parameter @Parameter} * @param frameworkParam Meta detail about the framework parameter being processed, if found. - * @param defaultValue value read from the {@link javax.ws.rs.DefaultValue @DefaultValue} - * annotation. + * @param defaultValue value read from the framework's default-value annotation. * @param target target of the annotation * @param overriddenParametersOnly true if only parameters already known to the scanner are considered, false otherwise */ @@ -1153,7 +1157,7 @@ protected void readParametersInherited(ClassInfo clazz, AnnotationInstance beanP /** * Scans for class level parameters. This method is used for both resource class - * annotation scanning and {@link javax.ws.rs.BeanParam @BeanParam} target type scanning. + * annotation scanning and framework-specific 'bean' parameter type target type scanning. * * @param clazz the class to be scanned for parameters. * @param beanParamAnnotation the bean parameter annotation to be used for path derivation diff --git a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java index 8dd1edf50..2cc8bcfb0 100644 --- a/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java +++ b/extension-spring/src/main/java/io/smallrye/openapi/spring/SpringParameterProcessor.java @@ -54,8 +54,7 @@ private SpringParameterProcessor(AnnotationScannerContext scannerContext, * {@link ResourceParameters}. Second, method-level parameters are processed. Form parameters * are only applicable to the method-level in this component. * - * @param index index of classes to be used for further introspection, if necessary - * @param cl the classloader + * @param context the AnnotationScannerContext * @param resourceClass the class info * @param resourceMethod the Spring resource method, annotated with one of the * Spring HTTP annotations diff --git a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java index 52969ab43..90e2ee64f 100644 --- a/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java +++ b/extension-vertx/src/main/java/io/smallrye/openapi/vertx/VertxParameterProcessor.java @@ -55,7 +55,7 @@ private VertxParameterProcessor(AnnotationScannerContext scannerContext, * {@link ResourceParameters}. Second, method-level parameters are processed. Form parameters * are only applicable to the method-level in this component. * - * @param index index of classes to be used for further introspection, if necessary + * @param context the AnnotationScannerContext * @param resourceClass the class info * @param resourceMethod the Vert.x resource method, annotated with one of the * Vert.x HTTP annotations