From ee0b8dba3b2189111fadfd5ba98730cc6b60c7ef Mon Sep 17 00:00:00 2001 From: altro3 Date: Sat, 25 Nov 2023 15:48:05 +0700 Subject: [PATCH 1/2] Code cleanup --- .../docs/controllers/HelloController.java | 4 +- .../annotations/HelloController.java | 2 +- gradle/libs.versions.toml | 2 +- .../openapi/adoc/md/ToAsciiDocSerializer.java | 3 +- .../core/jackson/MediaTypeSerializer.java | 2 +- .../core/jackson/Schema31Serializer.java | 2 +- .../core/jackson/SchemaSerializer.java | 2 +- .../swagger/core/util/PrimitiveType.java | 12 ++--- .../AbstractMicronautJavaCodegen.java | 6 +-- ...ClientCodegenSerializationLibraryTest.java | 2 - .../generator/assertions/TestUtils.java | 2 +- .../openapi/javadoc/JavadocDescription.java | 2 +- .../OpenApiOperationsPostProcessor.java | 48 ++++++++++--------- .../openapi/view/OpenApiViewConfig.java | 2 +- .../visitor/AbstractOpenApiVisitor.java | 8 +--- .../openapi/visitor/ContextProperty.java | 2 +- .../openapi/visitor/ContextUtils.java | 2 +- .../micronaut/openapi/visitor/Endpoint.java | 7 ++- .../visitor/EndpointsConfiguration.java | 2 +- .../visitor/OpenApiApplicationVisitor.java | 46 +++++++++--------- .../io/micronaut/openapi/JAXBElement.java | 8 ++-- .../groovy/io/micronaut/openapi/ObjectId.java | 9 +++- .../OpenApiApplicationVisitorSpec.groovy | 8 ++-- .../OpenApiDuplicateElementsSpec.groovy | 6 +-- .../visitor/OpenApiOperationTagsSpec.groovy | 16 +++---- src/main/docs/guide/gettingStarted.adoc | 5 +- src/main/docs/guide/kotlin.adoc | 4 +- src/main/docs/guide/openApiViews/rapidoc.adoc | 2 +- src/main/docs/guide/openApiViews/rapipdf.adoc | 2 +- src/main/docs/guide/openApiViews/redoc.adoc | 2 +- .../docs/guide/openApiViews/swaggerui.adoc | 4 +- .../guide/openApiViews/swaggerui/oauth2.adoc | 2 +- .../petstore.json | 2 +- .../petstore.json | 2 +- .../test/api/ResponseBodyController.kt | 4 +- .../petstore.json | 2 +- .../test/api/ResponseBodyController.kt | 4 +- 37 files changed, 122 insertions(+), 118 deletions(-) diff --git a/docs-examples/example-java/src/test/java/io/micronaut/configuration/openapi/docs/controllers/HelloController.java b/docs-examples/example-java/src/test/java/io/micronaut/configuration/openapi/docs/controllers/HelloController.java index 1b5fcbe001..b077e399ac 100644 --- a/docs-examples/example-java/src/test/java/io/micronaut/configuration/openapi/docs/controllers/HelloController.java +++ b/docs-examples/example-java/src/test/java/io/micronaut/configuration/openapi/docs/controllers/HelloController.java @@ -8,7 +8,7 @@ // end::imports[] // tag::clazz[] -@Controller("/") +@Controller public class HelloController { /** @@ -20,4 +20,4 @@ public Mono index(String name) { return Mono.just("Hello " + name + "!"); } } -// end::clazz[] \ No newline at end of file +// end::clazz[] diff --git a/docs-examples/example-java/src/test/java/io/micronaut/configuration/openapi/docs/controllers/annotations/HelloController.java b/docs-examples/example-java/src/test/java/io/micronaut/configuration/openapi/docs/controllers/annotations/HelloController.java index c1b137dec0..99ee24c59b 100644 --- a/docs-examples/example-java/src/test/java/io/micronaut/configuration/openapi/docs/controllers/annotations/HelloController.java +++ b/docs-examples/example-java/src/test/java/io/micronaut/configuration/openapi/docs/controllers/annotations/HelloController.java @@ -16,7 +16,7 @@ // end::imports[] // tag::clazz[] -@Controller("/") +@Controller public class HelloController { /** diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index baf3ce9b72..ccf4f738cd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,7 +7,7 @@ managed-parboiled = "1.4.1" managed-freemarker = "2.3.32" managed-pegdown = "1.6.0" -kotlin = "1.9.21" +kotlin = "1.9.20" ksp = "1.9.20-1.0.14" jspecify = "0.3.0" jdt-annotation = "2.2.700" diff --git a/openapi-adoc/src/main/java/io/micronaut/openapi/adoc/md/ToAsciiDocSerializer.java b/openapi-adoc/src/main/java/io/micronaut/openapi/adoc/md/ToAsciiDocSerializer.java index 7dc8b78dd8..11ebd96706 100644 --- a/openapi-adoc/src/main/java/io/micronaut/openapi/adoc/md/ToAsciiDocSerializer.java +++ b/openapi-adoc/src/main/java/io/micronaut/openapi/adoc/md/ToAsciiDocSerializer.java @@ -200,8 +200,7 @@ public void visit(DefinitionNode node) { public void visit(ExpImageNode node) { String text = printChildrenToString(node); LinkRenderer.Rendering imageRenderer = linkRenderer.render(node, text); - Node linkNode; - if ((linkNode = findParentNode(node, rootNode)) instanceof ExpLinkNode expLinkNode) { + if (findParentNode(node, rootNode) instanceof ExpLinkNode expLinkNode) { printImageTagWithLink(imageRenderer, linkRenderer.render(expLinkNode, null)); } else { printImageTag(linkRenderer.render(node, text)); diff --git a/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/MediaTypeSerializer.java b/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/MediaTypeSerializer.java index a225bda6a8..a142e1df25 100644 --- a/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/MediaTypeSerializer.java +++ b/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/MediaTypeSerializer.java @@ -32,7 +32,7 @@ */ public class MediaTypeSerializer extends JsonSerializer implements ResolvableSerializer { - private JsonSerializer defaultSerializer; + private final JsonSerializer defaultSerializer; public MediaTypeSerializer(JsonSerializer serializer) { defaultSerializer = serializer; diff --git a/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/Schema31Serializer.java b/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/Schema31Serializer.java index 3b832ca330..e49a785fc5 100644 --- a/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/Schema31Serializer.java +++ b/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/Schema31Serializer.java @@ -32,7 +32,7 @@ */ public class Schema31Serializer extends JsonSerializer implements ResolvableSerializer { - private JsonSerializer defaultSerializer; + private final JsonSerializer defaultSerializer; public Schema31Serializer(JsonSerializer serializer) { defaultSerializer = serializer; diff --git a/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/SchemaSerializer.java b/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/SchemaSerializer.java index bef1a6662f..8d48e3a9b8 100644 --- a/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/SchemaSerializer.java +++ b/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/jackson/SchemaSerializer.java @@ -32,7 +32,7 @@ */ public class SchemaSerializer extends JsonSerializer implements ResolvableSerializer { - private JsonSerializer defaultSerializer; + private final JsonSerializer defaultSerializer; public SchemaSerializer(JsonSerializer serializer) { defaultSerializer = serializer; diff --git a/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/util/PrimitiveType.java b/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/util/PrimitiveType.java index 0e75ef31c8..a0a7855bd9 100644 --- a/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/util/PrimitiveType.java +++ b/openapi-common/src/main/java/io/micronaut/openapi/swagger/core/util/PrimitiveType.java @@ -186,31 +186,31 @@ public Schema createProperty() { /** * Allows to exclude specific classes from KEY_CLASSES mappings to primitive */ - private static Set customExcludedClasses = ConcurrentHashMap.newKeySet(); + private static final Set customExcludedClasses = ConcurrentHashMap.newKeySet(); /** * Allows to exclude specific classes from EXTERNAL_CLASSES mappings to primitive */ - private static Set customExcludedExternalClasses = ConcurrentHashMap.newKeySet(); + private static final Set customExcludedExternalClasses = ConcurrentHashMap.newKeySet(); /** * Adds support for custom mapping of classes to primitive types */ - private static Map customClasses = new ConcurrentHashMap<>(); + private static final Map customClasses = new ConcurrentHashMap<>(); /** * class qualified names prefixes to be considered as "system" types */ - private static Set systemPrefixes = ConcurrentHashMap.newKeySet(); + private static final Set systemPrefixes = ConcurrentHashMap.newKeySet(); /** * class qualified names NOT to be considered as "system" types */ - private static Set nonSystemTypes = ConcurrentHashMap.newKeySet(); + private static final Set nonSystemTypes = ConcurrentHashMap.newKeySet(); /** * package names NOT to be considered as "system" types */ - private static Set nonSystemTypePackages = ConcurrentHashMap.newKeySet(); + private static final Set nonSystemTypePackages = ConcurrentHashMap.newKeySet(); /** * Alternative names for primitive types that have to be supported for diff --git a/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautJavaCodegen.java b/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautJavaCodegen.java index fd60806033..8763c8d4cd 100644 --- a/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautJavaCodegen.java +++ b/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautJavaCodegen.java @@ -313,7 +313,7 @@ public void processOpts() { // Get boolean properties if (additionalProperties.containsKey(USE_BEANVALIDATION)) { - setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); + useBeanValidation = convertPropertyToBoolean(USE_BEANVALIDATION); } writePropertyBack(USE_BEANVALIDATION, useBeanValidation); @@ -333,12 +333,12 @@ public void processOpts() { writePropertyBack(OPT_GENERATED_ANNOTATION, generatedAnnotation); if (additionalProperties.containsKey(USE_OPTIONAL)) { - setUseOptional(convertPropertyToBoolean(USE_OPTIONAL)); + useOptional = convertPropertyToBoolean(USE_OPTIONAL); } writePropertyBack(USE_OPTIONAL, useOptional); if (additionalProperties.containsKey(OPT_VISITABLE)) { - setVisitable(convertPropertyToBoolean(OPT_VISITABLE)); + visitable = convertPropertyToBoolean(OPT_VISITABLE); } writePropertyBack(OPT_VISITABLE, visitable); diff --git a/openapi-generator/src/test/java/io/micronaut/openapi/generator/JavaMicronautClientCodegenSerializationLibraryTest.java b/openapi-generator/src/test/java/io/micronaut/openapi/generator/JavaMicronautClientCodegenSerializationLibraryTest.java index 36051ec906..30580a32b7 100644 --- a/openapi-generator/src/test/java/io/micronaut/openapi/generator/JavaMicronautClientCodegenSerializationLibraryTest.java +++ b/openapi-generator/src/test/java/io/micronaut/openapi/generator/JavaMicronautClientCodegenSerializationLibraryTest.java @@ -4,12 +4,10 @@ import io.micronaut.openapi.generator.MicronautCodeGeneratorOptionsBuilder.GeneratorLanguage; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.openapitools.codegen.CodegenConstants; -import org.openapitools.codegen.DefaultCodegen; import static io.micronaut.openapi.generator.MicronautCodeGeneratorOptionsBuilder.GeneratorLanguage.JAVA; import static io.micronaut.openapi.generator.MicronautCodeGeneratorOptionsBuilder.GeneratorLanguage.KOTLIN; diff --git a/openapi-generator/src/testFixtures/java/io/micronaut/openapi/generator/assertions/TestUtils.java b/openapi-generator/src/testFixtures/java/io/micronaut/openapi/generator/assertions/TestUtils.java index 48d20aa9fa..56e9302edd 100644 --- a/openapi-generator/src/testFixtures/java/io/micronaut/openapi/generator/assertions/TestUtils.java +++ b/openapi-generator/src/testFixtures/java/io/micronaut/openapi/generator/assertions/TestUtils.java @@ -135,7 +135,7 @@ public static void assertFileContains(Path path, String... lines) { } public static String linearize(String target) { - return target.replaceAll("\r?\n", "").replaceAll("\\s+", "\\s"); + return target.replaceAll("\r?\n", "").replaceAll("\\s+", "s"); } public static void assertFileNotContains(Path path, String... lines) { diff --git a/openapi/src/main/java/io/micronaut/openapi/javadoc/JavadocDescription.java b/openapi/src/main/java/io/micronaut/openapi/javadoc/JavadocDescription.java index 259c809d0e..818e366be0 100644 --- a/openapi/src/main/java/io/micronaut/openapi/javadoc/JavadocDescription.java +++ b/openapi/src/main/java/io/micronaut/openapi/javadoc/JavadocDescription.java @@ -30,8 +30,8 @@ public class JavadocDescription { private String methodSummary; private String methodDescription; - private Map parameters = new HashMap<>(4); private String returnDescription; + private final Map parameters = new HashMap<>(4); /** * @return method summary diff --git a/openapi/src/main/java/io/micronaut/openapi/postprocessors/OpenApiOperationsPostProcessor.java b/openapi/src/main/java/io/micronaut/openapi/postprocessors/OpenApiOperationsPostProcessor.java index d7073efe74..89187b6076 100644 --- a/openapi/src/main/java/io/micronaut/openapi/postprocessors/OpenApiOperationsPostProcessor.java +++ b/openapi/src/main/java/io/micronaut/openapi/postprocessors/OpenApiOperationsPostProcessor.java @@ -16,8 +16,8 @@ package io.micronaut.openapi.postprocessors; import java.util.HashMap; -import java.util.Map; +import io.micronaut.core.util.CollectionUtils; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; @@ -29,39 +29,43 @@ public class OpenApiOperationsPostProcessor { /** * Process operations, making operation ids unique. * - * @param openAPI OpenApi object with all definitions + * @param openApi OpenApi object with all definitions */ - public void processOperations(OpenAPI openAPI) { - if (openAPI.getPaths() == null) { + public void processOperations(OpenAPI openApi) { + if (CollectionUtils.isEmpty(openApi.getPaths())) { return; } - Map operationIdsIndex = new HashMap<>(); + var operationIdsIndex = new HashMap(); - openAPI.getPaths().values().stream() - .flatMap(pathItem -> pathItem.readOperations().stream()) - .forEach(operation -> { + for (var pathItem : openApi.getPaths().values()) { + for (var operation : pathItem.readOperations()) { String operationId = operation.getOperationId(); - if (operationIdsIndex.containsKey(operationId)) { - int nextValue = operationIdsIndex.get(operationId); - - String newOperationId = operationId + '_' + nextValue; - operation.setOperationId(newOperationId); - updateResponseDescription(operation, operationId, newOperationId); - - operationIdsIndex.put(operationId, ++nextValue); - } else { + if (!operationIdsIndex.containsKey(operationId)) { operationIdsIndex.put(operationId, 1); + continue; } - }); + int nextValue = operationIdsIndex.get(operationId); + + String newOperationId = operationId + '_' + nextValue; + operation.setOperationId(newOperationId); + updateResponseDescription(operation, operationId, newOperationId); + + operationIdsIndex.put(operationId, ++nextValue); + } + } } private static void updateResponseDescription(Operation operation, String originalId, String newOperationId) { - if (operation.getResponses() != null) { - operation.getResponses().values().stream() - .filter(apiResponse -> apiResponse != null && apiResponse.getDescription() != null) - .forEach(apiResponse -> apiResponse.setDescription(apiResponse.getDescription().replaceFirst(originalId, newOperationId))); + if (CollectionUtils.isEmpty(operation.getResponses())) { + return; + } + for (var apiResponse : operation.getResponses().values()) { + if (apiResponse == null || apiResponse.getDescription() == null) { + continue; + } + apiResponse.setDescription(apiResponse.getDescription().replaceFirst(originalId, newOperationId)); } } diff --git a/openapi/src/main/java/io/micronaut/openapi/view/OpenApiViewConfig.java b/openapi/src/main/java/io/micronaut/openapi/view/OpenApiViewConfig.java index 46c9fd7fed..4c2c8115f5 100644 --- a/openapi/src/main/java/io/micronaut/openapi/view/OpenApiViewConfig.java +++ b/openapi/src/main/java/io/micronaut/openapi/view/OpenApiViewConfig.java @@ -351,7 +351,7 @@ private void render(AbstractViewConfig cfg, Path outputDir, String templateName, template = cfg.render(template, context); template = replacePlaceHolder(template, "specURL", getSpecURL(cfg, context), ""); - template = replacePlaceHolder(template, "title", getTitle(), ""); + template = replacePlaceHolder(template, "title", title, ""); if (!Files.exists(outputDir)) { Files.createDirectories(outputDir); } diff --git a/openapi/src/main/java/io/micronaut/openapi/visitor/AbstractOpenApiVisitor.java b/openapi/src/main/java/io/micronaut/openapi/visitor/AbstractOpenApiVisitor.java index 2cacb0f80a..c9b1d15b66 100644 --- a/openapi/src/main/java/io/micronaut/openapi/visitor/AbstractOpenApiVisitor.java +++ b/openapi/src/main/java/io/micronaut/openapi/visitor/AbstractOpenApiVisitor.java @@ -1978,8 +1978,6 @@ private Schema getSchemaDefinition(OpenAPI openAPI, if (schema != null) { processSuperTypes(schema, schemaName, type, definingElement, openAPI, mediaTypes, schemas, context, jsonViewClass); } - } catch (JsonProcessingException e) { - context.warn("Error reading Swagger Parameter for element [" + type + "]: " + e.getMessage(), type); } finally { inProgressSchemas.remove(schemaName); } @@ -2176,13 +2174,11 @@ private void processClassValues(Schema schemaToBind, Map readSchema(AnnotationValue schemaValue, OpenAPI openAPI, VisitorContext context, @Nullable Element type, Map typeArgs, List mediaTypes, - @Nullable ClassElement jsonViewClass) throws JsonProcessingException { + @Nullable ClassElement jsonViewClass) { Map values = schemaValue.getValues() .entrySet() .stream() @@ -2361,7 +2357,7 @@ private String addTypeArgsAnnotations(String memberName, Object annValue) { var annName = aValue.getAnnotationName(); var values = ((Map) aValue.getValues()); var endPos = annName.contains("$") ? annName.lastIndexOf('$') : annName.length(); - result.append(annName.substring(annName.lastIndexOf('.') + 1, endPos)); + result.append(annName, annName.lastIndexOf('.') + 1, endPos); if (CollectionUtils.isNotEmpty(values)) { result.append('_'); for (var entry : values.entrySet()) { diff --git a/openapi/src/main/java/io/micronaut/openapi/visitor/ContextProperty.java b/openapi/src/main/java/io/micronaut/openapi/visitor/ContextProperty.java index d51f2a7cf2..c08bcae8f8 100644 --- a/openapi/src/main/java/io/micronaut/openapi/visitor/ContextProperty.java +++ b/openapi/src/main/java/io/micronaut/openapi/visitor/ContextProperty.java @@ -103,5 +103,5 @@ public interface ContextProperty { /** * Calculated class output directory path. */ - String MICRONAUT_INTERNAL_CLASSPATH_OUTPUT = "micronaut.internal.classpath.ouptut"; + String MICRONAUT_INTERNAL_CLASSPATH_OUTPUT = "micronaut.internal.classpath.output"; } diff --git a/openapi/src/main/java/io/micronaut/openapi/visitor/ContextUtils.java b/openapi/src/main/java/io/micronaut/openapi/visitor/ContextUtils.java index 996699baec..926df9d099 100644 --- a/openapi/src/main/java/io/micronaut/openapi/visitor/ContextUtils.java +++ b/openapi/src/main/java/io/micronaut/openapi/visitor/ContextUtils.java @@ -92,7 +92,7 @@ public static GeneratedFile visitMetaInfFile(String path, VisitorContext context count++; } } - // now this is classesOutputDir, parent of META-INF direcory + // now this is classesOutputDir, parent of META-INF directory generatedFilePath = generatedFilePath.getParent(); context.put(MICRONAUT_INTERNAL_CLASSPATH_OUTPUT, generatedFilePath); diff --git a/openapi/src/main/java/io/micronaut/openapi/visitor/Endpoint.java b/openapi/src/main/java/io/micronaut/openapi/visitor/Endpoint.java index e1f8d588aa..a222433672 100644 --- a/openapi/src/main/java/io/micronaut/openapi/visitor/Endpoint.java +++ b/openapi/src/main/java/io/micronaut/openapi/visitor/Endpoint.java @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.List; -import java.util.Optional; import io.micronaut.inject.ast.ClassElement; import io.swagger.v3.oas.models.security.SecurityRequirement; @@ -31,7 +30,7 @@ */ class Endpoint { - private Optional element; + private ClassElement element; private List tags = Collections.emptyList(); private List servers = Collections.emptyList(); private List securityRequirements = Collections.emptyList(); @@ -41,7 +40,7 @@ class Endpoint { * * @param element A ClassElement, */ - void setClassElement(Optional element) { + void setClassElement(ClassElement element) { this.element = element; } @@ -59,7 +58,7 @@ void setTags(List tags) { * * @return A ClassElement. */ - Optional getClassElement() { + ClassElement getClassElement() { return element; } diff --git a/openapi/src/main/java/io/micronaut/openapi/visitor/EndpointsConfiguration.java b/openapi/src/main/java/io/micronaut/openapi/visitor/EndpointsConfiguration.java index 7fcd19cd38..234b8b3786 100644 --- a/openapi/src/main/java/io/micronaut/openapi/visitor/EndpointsConfiguration.java +++ b/openapi/src/main/java/io/micronaut/openapi/visitor/EndpointsConfiguration.java @@ -90,7 +90,7 @@ public class EndpointsConfiguration { case "security-requirements" -> endpoint.setSecurityRequirements(parseSecurityRequirements(entry.getValue(), context)); case "servers" -> endpoint.setServers(parseServers(entry.getValue(), context)); case "tags" -> endpoint.setTags(parseTags(entry.getValue())); - case "class" -> endpoint.setClassElement(context.getClassElement(entry.getValue())); + case "class" -> endpoint.setClassElement(context.getClassElement(entry.getValue()).orElse(null)); default -> context.warn("Unknown value " + entryType, null); } }); diff --git a/openapi/src/main/java/io/micronaut/openapi/visitor/OpenApiApplicationVisitor.java b/openapi/src/main/java/io/micronaut/openapi/visitor/OpenApiApplicationVisitor.java index 1fe4ad7339..f8abd9e20e 100644 --- a/openapi/src/main/java/io/micronaut/openapi/visitor/OpenApiApplicationVisitor.java +++ b/openapi/src/main/java/io/micronaut/openapi/visitor/OpenApiApplicationVisitor.java @@ -569,7 +569,7 @@ private void addOperation(EndpointInfo endpointInfo, OpenAPI openApi) { } private OpenAPI addOpenApiInfo(String group, String version, OpenAPI openApi, Map, - OpenApiInfo> openApiInfoMap, VisitorContext context) { + OpenApiInfo> openApiInfoMap, VisitorContext context) { GroupProperties groupProperties = getGroupProperties(group, context); boolean hasGroupProperties = groupProperties != null; @@ -1091,21 +1091,19 @@ private void writeYamlToFile(Map, OpenApiInfo> openApiInfos Utils.setTestJsonReference(writer.toString()); } } else { - @SuppressWarnings("OptionalGetWithoutIsPresent") - Path specPath = specFile; - context.info("Writing OpenAPI file to destination: " + specPath); + context.info("Writing OpenAPI file to destination: " + specFile); viewsDestDirs = getViewsDestDir(getDefaultFilePath(openApiInfo.getFilename(), context), context); context.info("Writing OpenAPI views to destination: " + viewsDestDirs); final Path viewsDestDirsFinal = viewsDestDirs; var classesOutputPath = ContextUtils.getClassesOutputPath(context); if (classesOutputPath != null) { - // add relative paths for the specPath, and its parent META-INF/swagger + // add relative paths for the specFile, and its parent META-INF/swagger // so that micronaut-graal visitor knows about them - context.addGeneratedResource(classesOutputPath.relativize(specPath).toString()); - context.addGeneratedResource(classesOutputPath.relativize(specPath.getParent()).toString()); + context.addGeneratedResource(classesOutputPath.relativize(specFile).toString()); + context.addGeneratedResource(classesOutputPath.relativize(specFile.getParent()).toString()); context.addGeneratedResource(classesOutputPath.relativize(viewsDestDirsFinal).toString()); } - openApiInfo.setSpecFilePath(specPath.getFileName().toString()); + openApiInfo.setSpecFilePath(specFile.getFileName().toString()); if (isAdocModuleInClassPath && isGlobalAdocEnabled && openApiInfo.isAdocEnabled()) { var adocProperties = getAdocProperties(openApiInfo, openApiInfos.size() == 1, context); @@ -1141,21 +1139,23 @@ private Writer getFileWriter(Path specFile) throws IOException { private void processEndpoints(VisitorContext context) { EndpointsConfiguration endpointsCfg = endpointsConfiguration(context); if (endpointsCfg.isEnabled() && CollectionUtils.isNotEmpty(endpointsCfg.getEndpoints())) { - OpenApiEndpointVisitor visitor = new OpenApiEndpointVisitor(true); - endpointsCfg.getEndpoints().values().stream() - .filter(endpoint -> endpoint.getClassElement().isPresent()) - .forEach(endpoint -> { - ClassElement classEl = endpoint.getClassElement().get(); - context.put(MICRONAUT_INTERNAL_OPENAPI_ENDPOINT_CLASS_TAGS, endpoint.getTags()); - context.put(MICRONAUT_INTERNAL_OPENAPI_ENDPOINT_SERVERS, endpoint.getServers()); - context.put(MICRONAUT_INTERNAL_OPENAPI_ENDPOINT_SECURITY_REQUIREMENTS, endpoint.getSecurityRequirements()); - visitor.visitClass(classEl, context); - for (MethodElement methodEl : classEl.getEnclosedElements(ElementQuery.ALL_METHODS - .modifiers(mods -> !mods.contains(ElementModifier.STATIC) && !mods.contains(ElementModifier.PRIVATE)) - .named(name -> !name.contains("$")))) { - visitor.visitMethod(methodEl, context); - } - }); + var visitor = new OpenApiEndpointVisitor(true); + for (var endpoint : endpointsCfg.getEndpoints().values()) { + ClassElement classEl = endpoint.getClassElement(); + if (classEl == null) { + continue; + } + context.put(MICRONAUT_INTERNAL_OPENAPI_ENDPOINT_CLASS_TAGS, endpoint.getTags()); + context.put(MICRONAUT_INTERNAL_OPENAPI_ENDPOINT_SERVERS, endpoint.getServers()); + context.put(MICRONAUT_INTERNAL_OPENAPI_ENDPOINT_SECURITY_REQUIREMENTS, endpoint.getSecurityRequirements()); + visitor.visitClass(classEl, context); + for (MethodElement methodEl : classEl.getEnclosedElements(ElementQuery.ALL_METHODS + .modifiers(mods -> !mods.contains(ElementModifier.STATIC) && !mods.contains(ElementModifier.PRIVATE)) + .named(name -> !name.contains("$")))) { + visitor.visitMethod(methodEl, context); + } + + } } } diff --git a/openapi/src/test/groovy/io/micronaut/openapi/JAXBElement.java b/openapi/src/test/groovy/io/micronaut/openapi/JAXBElement.java index ae156121a5..88d72e363c 100644 --- a/openapi/src/test/groovy/io/micronaut/openapi/JAXBElement.java +++ b/openapi/src/test/groovy/io/micronaut/openapi/JAXBElement.java @@ -1,5 +1,6 @@ package io.micronaut.openapi; +import java.io.Serial; import java.io.Serializable; import javax.xml.namespace.QName; @@ -9,6 +10,9 @@ */ public class JAXBElement implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + /** * xml element tag name */ @@ -30,7 +34,7 @@ public class JAXBElement implements Serializable { /** * true iff the xml element instance has xsi:nil="true". */ - protected boolean nil = false; + protected boolean nil; /** * Designates global scope for an xml element. @@ -169,6 +173,4 @@ public boolean isTypeSubstituted() { } return value.getClass() != declaredType; } - - private static final long serialVersionUID = 1L; } diff --git a/openapi/src/test/groovy/io/micronaut/openapi/ObjectId.java b/openapi/src/test/groovy/io/micronaut/openapi/ObjectId.java index cb7b626432..b8bbafe46a 100644 --- a/openapi/src/test/groovy/io/micronaut/openapi/ObjectId.java +++ b/openapi/src/test/groovy/io/micronaut/openapi/ObjectId.java @@ -2,6 +2,7 @@ import java.io.InvalidObjectException; import java.io.ObjectInputStream; +import java.io.Serial; import java.io.Serializable; import java.nio.ByteBuffer; import java.security.SecureRandom; @@ -15,6 +16,7 @@ public final class ObjectId implements Comparable, Serializable { // unused, as this class uses a proxy for serialization + @Serial private static final long serialVersionUID = 1L; private static final int OBJECT_ID_LENGTH = 12; @@ -26,9 +28,10 @@ public final class ObjectId implements Comparable, Serializable { private static final AtomicInteger NEXT_COUNTER = new AtomicInteger(new SecureRandom().nextInt()); - private static final char[] HEX_CHARS = new char[]{ + private static final char[] HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' + }; /** * The timestamp @@ -280,6 +283,7 @@ public String toString() { return toHexString(); } + @Serial private void readObject(final ObjectInputStream stream) throws InvalidObjectException { throw new InvalidObjectException("Proxy required"); } @@ -305,6 +309,7 @@ private static class SerializationProxy implements Serializable { bytes = objectId.toByteArray(); } + @Serial private Object readResolve() { return new ObjectId(bytes); } diff --git a/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiApplicationVisitorSpec.groovy b/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiApplicationVisitorSpec.groovy index efeb762035..e133748d0d 100644 --- a/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiApplicationVisitorSpec.groovy +++ b/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiApplicationVisitorSpec.groovy @@ -112,7 +112,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; description = "desc 0", externalDocs = @ExternalDocumentation( description = "docs desc0", - url = "http://externaldoc.com", + url = "https://externaldoc.com", extensions = { @Extension( name = "extdocs.custom1", @@ -153,7 +153,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; }, externalDocs = @ExternalDocumentation( description = "definition docs desc", - url = "http://externaldoc.com", + url = "https://externaldoc.com", extensions = { @Extension( name = "extdocs.custom1", @@ -297,7 +297,7 @@ class MyBean {} openAPI.tags.get(0).name == 'Tag 0' openAPI.tags.get(0).description == 'desc 0' openAPI.tags.get(0).externalDocs.description == 'docs desc0' - openAPI.tags.get(0).externalDocs.url == 'http://externaldoc.com' + openAPI.tags.get(0).externalDocs.url == 'https://externaldoc.com' openAPI.tags.get(0).externalDocs.extensions.size() == 2 openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom1'.prop11 == 'prop11Val' openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom1'.prop12 == 'prop12Val' @@ -320,7 +320,7 @@ class MyBean {} openAPI.tags.get(3).name == 'Tag 3' openAPI.externalDocs.description == 'definition docs desc' - openAPI.externalDocs.url == 'http://externaldoc.com' + openAPI.externalDocs.url == 'https://externaldoc.com' openAPI.externalDocs.extensions.size() == 2 openAPI.externalDocs.extensions.'x-extdocs.custom1'.prop11 == 'prop11Val' openAPI.externalDocs.extensions.'x-extdocs.custom1'.prop12 == 'prop12Val' diff --git a/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiDuplicateElementsSpec.groovy b/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiDuplicateElementsSpec.groovy index cef8f6e319..98f592c071 100644 --- a/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiDuplicateElementsSpec.groovy +++ b/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiDuplicateElementsSpec.groovy @@ -69,9 +69,9 @@ paths: - write_pets - read_pets servers: - - url: http://petstore.swagger.io/v2 - - url: http://petstore.swagger.io/v2 - - url: http://petstore.swagger.io/v2 + - url: https://petstore.swagger.io/v2 + - url: https://petstore.swagger.io/v2 + - url: https://petstore.swagger.io/v2 components: schemas: Pet: diff --git a/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiOperationTagsSpec.groovy b/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiOperationTagsSpec.groovy index 1f4f1a5ad0..7d6fc4aba5 100644 --- a/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiOperationTagsSpec.groovy +++ b/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiOperationTagsSpec.groovy @@ -31,7 +31,7 @@ class OpenApiController { description = "desc 0", externalDocs = @ExternalDocumentation( description = "docs desc0", - url = "http://externaldoc.com", + url = "https://externaldoc.com", extensions = { @Extension( name = "extdocs.custom1", @@ -100,7 +100,7 @@ class MyBean {} openAPI.tags.get(0).description == 'desc 0' openAPI.tags.get(0).externalDocs openAPI.tags.get(0).externalDocs.description == "docs desc0" - openAPI.tags.get(0).externalDocs.url == "http://externaldoc.com" + openAPI.tags.get(0).externalDocs.url == "https://externaldoc.com" openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom1'.'prop11' == 'prop11Val' openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom1'.'prop12' == 'prop12Val' openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom2'.'prop21' == 'prop21Val' @@ -146,7 +146,7 @@ class OpenApiController { description = "desc 0", externalDocs = @ExternalDocumentation( description = "docs desc0", - url = "http://externaldoc.com", + url = "https://externaldoc.com", extensions = { @Extension( name = "extdocs.custom1", @@ -214,7 +214,7 @@ class MyBean {} openAPI.tags.get(0).description == 'desc 0' openAPI.tags.get(0).externalDocs openAPI.tags.get(0).externalDocs.description == "docs desc0" - openAPI.tags.get(0).externalDocs.url == "http://externaldoc.com" + openAPI.tags.get(0).externalDocs.url == "https://externaldoc.com" openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom1'.'prop11' == 'prop11Val' openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom1'.'prop12' == 'prop12Val' openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom2'.'prop21' == 'prop21Val' @@ -255,7 +255,7 @@ import io.swagger.v3.oas.annotations.tags.Tags; description = "desc 0", externalDocs = @ExternalDocumentation( description = "docs desc0", - url = "http://externaldoc.com", + url = "https://externaldoc.com", extensions = { @Extension( name = "extdocs.custom1", @@ -304,7 +304,7 @@ class OpenApiController { description = "desc 0", externalDocs = @ExternalDocumentation( description = "docs desc0", - url = "http://externaldoc.com", + url = "https://externaldoc.com", extensions = { @Extension( name = "extdocs.custom1", @@ -377,7 +377,7 @@ class MyBean {} openAPI.tags.get(0).description == 'desc 0' openAPI.tags.get(0).externalDocs openAPI.tags.get(0).externalDocs.description == "docs desc0" - openAPI.tags.get(0).externalDocs.url == "http://externaldoc.com" + openAPI.tags.get(0).externalDocs.url == "https://externaldoc.com" openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom1'.'prop11' == 'prop11Val' openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom1'.'prop12' == 'prop12Val' openAPI.tags.get(0).externalDocs.extensions.'x-extdocs.custom2'.'prop21' == 'prop21Val' @@ -401,7 +401,7 @@ class MyBean {} openAPI.tags.get(3).description == 'desc 0' openAPI.tags.get(3).externalDocs openAPI.tags.get(3).externalDocs.description == "docs desc0" - openAPI.tags.get(3).externalDocs.url == "http://externaldoc.com" + openAPI.tags.get(3).externalDocs.url == "https://externaldoc.com" openAPI.tags.get(3).externalDocs.extensions.'x-extdocs.custom1'.'prop11' == 'prop11Val' openAPI.tags.get(3).externalDocs.extensions.'x-extdocs.custom1'.'prop12' == 'prop12Val' openAPI.tags.get(3).externalDocs.extensions.'x-extdocs.custom2'.'prop21' == 'prop21Val' diff --git a/src/main/docs/guide/gettingStarted.adoc b/src/main/docs/guide/gettingStarted.adoc index e15f3cb421..1f038940fd 100644 --- a/src/main/docs/guide/gettingStarted.adoc +++ b/src/main/docs/guide/gettingStarted.adoc @@ -11,10 +11,11 @@ dependency:micronaut-openapi-annotations[scope="compileOnly", groupId="io.micron NOTE: Also, do not forget that for the correct operation of the annotation processor, the correct parameter names in the controllers are required, therefore it is recommended that all libraries from which you plan to add controllers be compiled with the `-parameters` flag. For example like this (with gradle build): -```groovy +[source,groovy] +---- tasks.withType(JavaCompile).configureEach { options.compilerArgs = [ '-parameters' ] } -``` +---- diff --git a/src/main/docs/guide/kotlin.adoc b/src/main/docs/guide/kotlin.adoc index 9a08934576..f5dc3c66c3 100644 --- a/src/main/docs/guide/kotlin.adoc +++ b/src/main/docs/guide/kotlin.adoc @@ -3,10 +3,10 @@ the project directory through the annotation processor setting `micronaut.openap .Gradle [source,groovy] -``` +---- kapt { arguments { arg("micronaut.openapi.project.dir", projectDir.toString()) } } -``` +---- diff --git a/src/main/docs/guide/openApiViews/rapidoc.adoc b/src/main/docs/guide/openApiViews/rapidoc.adoc index 22795101c3..0e6f77fd83 100644 --- a/src/main/docs/guide/openApiViews/rapidoc.adoc +++ b/src/main/docs/guide/openApiViews/rapidoc.adoc @@ -4,7 +4,7 @@ The views will be generated to the `META-INF/swagger/views/rapidoc` directory of | `rapidoc.enabled` | `true` or `false` When 'true' the RapiDoc view is generated. | `rapidoc.js.url` | Override path to use to find the js file. Path must contain a file named rapidoc-min.js. The value can be a URL path like: "https://unpkg.com/rapidoc/dist/". Must contain trailing slash. | `rapidoc.spec.url` | Override path in swagger file path line. If you don't set, then value will be `/swagger/`. You can use the placeholder `${filename}` it will be replaced with the final name of the generated swagger file. -| `rapidoc.copy-resources` | Copy or not local JS and CSS resources. Set to `false` if you are using external resources (eg https://unpkg.com/rapidoc/dist/). Default `true` +| `rapidoc.copy-resources` | Copy or not local JS and CSS resources. Set to `false` if you are using external resources (e.g. https://unpkg.com/rapidoc/dist/). Default `true` | `rapidoc.style` | | `rapidoc.sort-tags` | | `rapidoc.sort-endpoints-by` | diff --git a/src/main/docs/guide/openApiViews/rapipdf.adoc b/src/main/docs/guide/openApiViews/rapipdf.adoc index 2d45a2a27a..513821a033 100644 --- a/src/main/docs/guide/openApiViews/rapipdf.adoc +++ b/src/main/docs/guide/openApiViews/rapipdf.adoc @@ -6,7 +6,7 @@ RapiPdf supports the following options: | `rapipdf.enabled` | `true` or `false`, | `rapipdf.js.url` | Override path to use to find the js file. Path must contain a file named rapdipdf-min.js. The value can be a URL path like: "https://unpkg.com/rapipdf/dist/". Must contain trailing slash., | `rapipdf.spec.url` | Override path in swagger file path line. If you don't set, then value will be `/swagger/`. You can use the placeholder `${filename}` it will be replaced with the final name of the generated swagger file. -| `rapipdf.copy-resources` | Copy or not local JS and CSS resources. Set to `false` if you are using external resources (eg https://unpkg.com/rapipdf/dist/). Default `true` +| `rapipdf.copy-resources` | Copy or not local JS and CSS resources. Set to `false` if you are using external resources (e.g. https://unpkg.com/rapipdf/dist/). Default `true` | `rapipdf.include-api-details` | `rapipdf.pdf-title` | `rapipdf.include-api-list` diff --git a/src/main/docs/guide/openApiViews/redoc.adoc b/src/main/docs/guide/openApiViews/redoc.adoc index 4f364a5950..1707e8ab4f 100644 --- a/src/main/docs/guide/openApiViews/redoc.adoc +++ b/src/main/docs/guide/openApiViews/redoc.adoc @@ -6,7 +6,7 @@ The views will be generated to the `META-INF/swagger/views/redoc` directory of y | `redoc.enabled` | `true` or `false` When 'true' the Redoc view is generated. | `redoc.js.url` | Override path to use to find the js file. Path must contain a file named redoc.standalone.js. The value can be a URL path like: "https://unpkg.com/redoc/bundles/". Must contain trailing slash., | `redoc.spec.url` | Override path in swagger file path line. If you don't set, then value will be `/swagger/`. You can use the placeholder `${filename}` it will be replaced with the final name of the generated swagger file. -| `redoc.copy-resources` | Copy or not local JS and CSS resources. Set to `false` if you are using external resources (eg https://unpkg.com/redoc/bundles/). Default `true` +| `redoc.copy-resources` | Copy or not local JS and CSS resources. Set to `false` if you are using external resources (e.g. https://unpkg.com/redoc/bundles/). Default `true` | `redoc.expand-single-schema-field` | | `redoc.expand-default-server-variables` | | `redoc.menu-toggle` | diff --git a/src/main/docs/guide/openApiViews/swaggerui.adoc b/src/main/docs/guide/openApiViews/swaggerui.adoc index 95b1648715..0969d87121 100644 --- a/src/main/docs/guide/openApiViews/swaggerui.adoc +++ b/src/main/docs/guide/openApiViews/swaggerui.adoc @@ -6,10 +6,10 @@ The views will be generated to the `META-INF/swagger/views/swagger-ui` directory | `swagger-ui.enabled` | `true` or `false` When 'true' the Swagger-ui view is generated. | `swagger-ui.js.url` | Override path to use to find the js file. Path must contain a files named swagger-ui.css, swagger-ui-bundle.js, swagger-ui-standalone-present.js. The value can be a URL path like: "https://unpkg.com/swagger-ui-dist/". Must contain trailing slash., | `swagger-ui.spec.url` | Override path in swagger file path line. If you don't set, then value will be `/swagger/`. You can use the placeholder `${filename}` it will be replaced with the final name of the generated swagger file. -| `swagger-ui.copy-resources` | Copy or not local JS and CSS resources. Set to `false` if you are using external resources (eg https://unpkg.com/swagger-ui-dist/). Default `true` +| `swagger-ui.copy-resources` | Copy or not local JS and CSS resources. Set to `false` if you are using external resources (e.g. https://unpkg.com/swagger-ui-dist/). Default `true` | `swagger-ui.theme` | `DEFAULT` or `MATERIAL` or `FEELING_BLUE` `FLATTOP` `MONOKAI` `MUTED` `NEWSPAPER` `OUTLINE` `DARK` `DARK2`. The theme of swagger-ui to use. These are case-insensitive. Default is `DEFAULT`. See https://github.com/ostranme/swagger-ui-themes[Swagger UI Themes]. | `swagger-ui.theme.url` | Override path to use to find the theme CSS file., -| `swagger-ui.copy-theme` | Copy or not local theme CSS resources. Set to `false` if you are using external resources (eg https://swagger-theme.com/flattop.css). Default `true` +| `swagger-ui.copy-theme` | Copy or not local theme CSS resources. Set to `false` if you are using external resources (e.g. https://swagger-theme.com/flattop.css). Default `true` | `swagger-ui.displayOperationId` | | `swagger-ui.oauth2RedirectUrl` | | `swagger-ui.showMutatedRequest` | diff --git a/src/main/docs/guide/openApiViews/swaggerui/oauth2.adoc b/src/main/docs/guide/openApiViews/swaggerui/oauth2.adoc index ee6f336c84..37bb085dc5 100644 --- a/src/main/docs/guide/openApiViews/swaggerui/oauth2.adoc +++ b/src/main/docs/guide/openApiViews/swaggerui/oauth2.adoc @@ -59,7 +59,7 @@ public class Application { } ---- -And the appropriate `@SecurityRequirement` on controllers,. eg: +And the appropriate `@SecurityRequirement` on controllers e.g.: [source,java] ---- diff --git a/test-suite-java-client-generator/petstore.json b/test-suite-java-client-generator/petstore.json index 29a3bd355f..0939db19d2 100644 --- a/test-suite-java-client-generator/petstore.json +++ b/test-suite-java-client-generator/petstore.json @@ -812,7 +812,7 @@ }, "petstore_auth": { "type": "oauth2", - "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", + "authorizationUrl": "https://petstore.swagger.io/api/oauth/dialog", "flow": "implicit", "scopes": { "write:pets": "modify pets in your account", diff --git a/test-suite-kotlin-kapt-client-generator/petstore.json b/test-suite-kotlin-kapt-client-generator/petstore.json index 76d2850d2a..db56969e6f 100644 --- a/test-suite-kotlin-kapt-client-generator/petstore.json +++ b/test-suite-kotlin-kapt-client-generator/petstore.json @@ -812,7 +812,7 @@ }, "petstore_auth": { "type": "oauth2", - "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", + "authorizationUrl": "https://petstore.swagger.io/api/oauth/dialog", "flow": "implicit", "scopes": { "write:pets": "modify pets in your account", diff --git a/test-suite-kotlin-kapt-server-generator/src/main/kotlin/io/micronaut/openapi/test/api/ResponseBodyController.kt b/test-suite-kotlin-kapt-server-generator/src/main/kotlin/io/micronaut/openapi/test/api/ResponseBodyController.kt index 76c52b734e..c06828ed52 100644 --- a/test-suite-kotlin-kapt-server-generator/src/main/kotlin/io/micronaut/openapi/test/api/ResponseBodyController.kt +++ b/test-suite-kotlin-kapt-server-generator/src/main/kotlin/io/micronaut/openapi/test/api/ResponseBodyController.kt @@ -84,12 +84,12 @@ open class ResponseBodyController : ResponseBodyApi { ) @JvmField - val DATE_TIME_INSTANCE = OffsetDateTime.parse("2022-12-04T11:35:00.784Z") + val DATE_TIME_INSTANCE: ZonedDateTime = OffsetDateTime.parse("2022-12-04T11:35:00.784Z") .atZoneSameInstant(ZoneId.of("America/Toronto")) val DATE_MODEL_INSTANCE = DateModel(LocalDate.of(2023, 6, 27), DATE_TIME_INSTANCE) const val LAST_MODIFIED_STRING = "2023-01-24T10:15:59.100+06:00" - val LAST_MODIFIED_DATE = ZonedDateTime.parse(LAST_MODIFIED_STRING) + val LAST_MODIFIED_DATE: ZonedDateTime = ZonedDateTime.parse(LAST_MODIFIED_STRING) } } diff --git a/test-suite-kotlin-ksp-client-generator/petstore.json b/test-suite-kotlin-ksp-client-generator/petstore.json index 76d2850d2a..db56969e6f 100644 --- a/test-suite-kotlin-ksp-client-generator/petstore.json +++ b/test-suite-kotlin-ksp-client-generator/petstore.json @@ -812,7 +812,7 @@ }, "petstore_auth": { "type": "oauth2", - "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", + "authorizationUrl": "https://petstore.swagger.io/api/oauth/dialog", "flow": "implicit", "scopes": { "write:pets": "modify pets in your account", diff --git a/test-suite-kotlin-ksp-server-generator/src/main/kotlin/io/micronaut/openapi/test/api/ResponseBodyController.kt b/test-suite-kotlin-ksp-server-generator/src/main/kotlin/io/micronaut/openapi/test/api/ResponseBodyController.kt index 76c52b734e..c06828ed52 100644 --- a/test-suite-kotlin-ksp-server-generator/src/main/kotlin/io/micronaut/openapi/test/api/ResponseBodyController.kt +++ b/test-suite-kotlin-ksp-server-generator/src/main/kotlin/io/micronaut/openapi/test/api/ResponseBodyController.kt @@ -84,12 +84,12 @@ open class ResponseBodyController : ResponseBodyApi { ) @JvmField - val DATE_TIME_INSTANCE = OffsetDateTime.parse("2022-12-04T11:35:00.784Z") + val DATE_TIME_INSTANCE: ZonedDateTime = OffsetDateTime.parse("2022-12-04T11:35:00.784Z") .atZoneSameInstant(ZoneId.of("America/Toronto")) val DATE_MODEL_INSTANCE = DateModel(LocalDate.of(2023, 6, 27), DATE_TIME_INSTANCE) const val LAST_MODIFIED_STRING = "2023-01-24T10:15:59.100+06:00" - val LAST_MODIFIED_DATE = ZonedDateTime.parse(LAST_MODIFIED_STRING) + val LAST_MODIFIED_DATE: ZonedDateTime = ZonedDateTime.parse(LAST_MODIFIED_STRING) } } From d450214781667d5019660b4df28bb179c49e2cfd Mon Sep 17 00:00:00 2001 From: altro3 Date: Wed, 29 Nov 2023 01:37:16 +0700 Subject: [PATCH 2/2] Update libs.versions.toml --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ccf4f738cd..baf3ce9b72 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,7 +7,7 @@ managed-parboiled = "1.4.1" managed-freemarker = "2.3.32" managed-pegdown = "1.6.0" -kotlin = "1.9.20" +kotlin = "1.9.21" ksp = "1.9.20-1.0.14" jspecify = "0.3.0" jdt-annotation = "2.2.700"