Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openapi generator 7.0.1 #1181

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs-examples/example-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ dependencies {
testRuntimeOnly(mnLogging.logback.classic)
}

kapt {
arguments {
arg("micronaut.openapi.project.dir", projectDir.toString())
}
}

test {
useJUnitPlatform()

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
projectVersion=6.0.0-SNAPSHOT
projectGroup=io.micronaut.openapi
micronautDocsVersion=2.0.0
groovyVersion=4.0.13
groovyVersion=4.0.15
spockVersion=2.3-groovy-4.0

title=OpenAPI/Swagger Support
Expand Down
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
managed-swagger = "2.2.15"
managed-swagger = "2.2.16"
managed-javadoc-parser = "0.3.1"
managed-jsoup = "1.16.1"
managed-html2md-converter = "0.64.8"
Expand All @@ -9,23 +9,24 @@ jspecify = "0.3.0"
jdt-annotation = "2.2.700"
android-annotation = "1.7.0"
spotbugs-annotations = "4.7.3"
openapi-generator = "7.0.0"
openapi-generator = "7.0.1"
swagger-parser = "1.0.67"
swagger-parser-v3 = "2.1.16"
javaparser = "3.25.5"
commons-codec = "1.16.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

commons-codec is not necessary or used is it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sdelamo It is used by openapi-generator, not remembered directly or through swagger-parser. In any case, the old version has a vulnerability. This fix will help remove this vulnerability from micronaut-openapi

Copy link
Contributor

Choose a reason for hiding this comment

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

do you know about this? @melix

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@melix ping


micronaut = "4.1.2"
micronaut = "4.1.6"
micronaut-security = "4.1.0"
micronaut-serde = "2.2.4"
micronaut-rxjava2 = "2.0.1"
micronaut-rxjava3 = "3.0.1"
micronaut-gradle-plugin = "4.1.1"
micronaut-groovy = "4.0.1"
micronaut-validation = "4.0.3"
micronaut-data = "4.1.2"
micronaut-data = "4.1.3"
micronaut-test = "4.0.2"
micronaut-kotlin = "4.0.2"
micronaut-platform = "4.0.5"
micronaut-platform = "4.1.2"
micronaut-logging = "1.1.2"

[libraries]
Expand Down Expand Up @@ -56,8 +57,6 @@ managed-jsoup = { module = "org.jsoup:jsoup", version.ref = "managed-jsoup" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" }
jackson-datatype-jsr310 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" }
jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml" }
assertj = { module = "org.assertj:assertj-core" }
kotlinx-coroutines-reactive = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactive" }
kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor" }

kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
Expand All @@ -67,6 +66,7 @@ spotbugs-annotations = { module = "com.github.spotbugs:spotbugs-annotations", ve
jdt-annotation = { module = "org.eclipse.jdt:org.eclipse.jdt.annotation", version.ref = "jdt-annotation" }
android-annotation = { module = "androidx.annotation:annotation", version.ref = "android-annotation" }
javaparser = { module = "com.github.javaparser:javaparser-symbol-solver-core", version.ref = "javaparser" }
commons-codec = { module = "commons-codec:commons-codec", version.ref = "commons-codec" }

openapi-generator = { module = "org.openapitools:openapi-generator", version.ref = "openapi-generator" }
swagger-parser = { module = "io.swagger:swagger-parser", version.ref = "swagger-parser" }
Expand Down
1 change: 1 addition & 0 deletions openapi-generator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
}
}
api libs.openapi.generator
implementation libs.commons.codec

testImplementation mnTest.micronaut.test.junit5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,10 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
}
op.consumes = op.consumes == null ? null : op.consumes.stream()
.filter(contentType -> !CONTENT_TYPE_ANY.equals(contentType.get("mediaType")))
.collect(Collectors.toList());
.toList();
op.produces = op.produces == null ? null : op.produces.stream()
.filter(contentType -> !CONTENT_TYPE_ANY.equals(contentType.get("mediaType")))
.collect(Collectors.toList());
.toList();

// is only default "application/json" media type
if (op.consumes == null
Expand Down Expand Up @@ -888,7 +888,9 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
model.parentVars = model.getParentModel().allVars;
}

List<CodegenProperty> requiredVars = model.vars.stream().filter(v -> v.required).collect(Collectors.toList());
List<CodegenProperty> requiredVars = model.vars.stream()
.filter(v -> v.required)
.toList();

model.vendorExtensions.put("withMultipleVars", model.vars.size() > 1);
model.vendorExtensions.put("requiredVarsWithoutDiscriminator", requiredVarsWithoutDiscriminator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static void assertFileExists(String file) {
} else {
message += Arrays.stream(contents)
.map(f -> f.toString().substring(parent.toString().length() + 1))
.collect(Collectors.toList());
.toList();
}
message += ".";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,11 @@ void doNotGenerateRequiredPropertiesInConstructor() {
}

@Test
@Disabled("Feature is not fully implemented in OpenAPI generator 6.x. Will be fixed in openapi-generator 7.0.0")
void testExtraAnnotations() {

JavaMicronautServerCodegen codegen = new JavaMicronautServerCodegen();
String outputPath = generateFiles(codegen, "src/test/resources/3_0/issue_11772.yml", CodegenConstants.MODELS);

TestUtils.assertExtraAnnotationFiles(outputPath + "/src/main/java/org/openapitools/model");

}

@Test
Expand Down
1 change: 0 additions & 1 deletion openapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ dependencies {
testImplementation(libs.jdt.annotation)
testImplementation(libs.android.annotation)
testImplementation(libs.spotbugs.annotations)
testImplementation(libs.kotlinx.coroutines.reactive)
testImplementation(libs.kotlinx.coroutines.reactor)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.xml.datatype.XMLGregorianCalendar;
Expand Down Expand Up @@ -251,10 +250,11 @@ List<SecurityRequirement> readSecurityRequirements(Element element) {
}

List<SecurityRequirement> readSecurityRequirements(List<AnnotationValue<io.swagger.v3.oas.annotations.security.SecurityRequirement>> annotations) {
return annotations
.stream()
.map(ConvertUtils::mapToSecurityRequirement)
.collect(Collectors.toList());
var result = new ArrayList<SecurityRequirement>(annotations.size());
for (var ann : annotations) {
result.add(ConvertUtils.mapToSecurityRequirement(ann));
}
return result;
}

/**
Expand Down Expand Up @@ -1804,7 +1804,7 @@ private void bindSchemaForComposite(VisitorContext context, Map<CharSequence, Ob
schemaToValueMap(schemaMap, schema);
}
return schemaMap;
}).collect(Collectors.toList());
}).toList();
valueMap.put(key, namesToSchemas);
}

Expand Down Expand Up @@ -2254,7 +2254,7 @@ private List<Schema<?>> namesToSchemas(OpenAPI openAPI, VisitorContext context,
}

return Stream.empty();
}).collect(Collectors.toList());
}).toList();
}

private String computeDefaultSchemaName(Element definingElement, Element type, Map<String, ClassElement> typeArgs, VisitorContext context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.micronaut.context.ApplicationContextConfiguration;
Expand Down Expand Up @@ -791,7 +790,7 @@ public static List<String> getActiveEnvs(VisitorContext context) {
.filter(StringUtils::isNotEmpty)
.flatMap(s -> Arrays.stream(s.split(",")))
.map(String::trim)
.collect(Collectors.toList());
.toList();
} else {
activeEnvs = new ArrayList<>();
}
Expand Down
Loading
Loading