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

Micronaut openapi 6.12.2 #1021

Merged
merged 1 commit into from
Aug 23, 2024
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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tomlj = "1.1.1"
micronaut-platform = "4.4.2" # This is the platform version, used in our tests
micronaut-aot = "2.4.0"
micronaut-testresources = "2.5.4"
micronaut-openapi = "6.11.0"
micronaut-openapi = "6.12.2"

[libraries]
# Core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ public void server(String name, Provider<RegularFile> definition, Action<? super

private void configureCommonExtensionDefaults(OpenApiSpec spec) {
spec.getApiPackageName().convention("io.micronaut.openapi.api");
spec.getInvokerPackageName().convention("io.micronaut.openapi.invoker");
spec.getInvokerPackageName().convention("io.micronaut.openapi");
spec.getModelPackageName().convention("io.micronaut.openapi.model");
spec.getUseBeanValidation().convention(true);
spec.getUseOneOfInterfaces().convention(true);
spec.getUseOptional().convention(false);
spec.getUseReactive().convention(true);
spec.getLombok().convention(false);
Expand All @@ -126,25 +127,25 @@ private void configureCommonExtensionDefaults(OpenApiSpec spec) {
spec.getDateTimeFormat().convention("ZONED_DATETIME");
spec.getLang().convention("java");
withJava(() -> {
var compileOnlyDeps = project.getConfigurations().getByName("compileOnly").getDependencies();
if ("java".equalsIgnoreCase(spec.getLang().get())) {
compileOnlyDeps.addAllLater(spec.getLombok().map(lombok -> {
if (Boolean.TRUE.equals(lombok)) {
return List.of(project.getDependencies().create("org.projectlombok:lombok"));
}
return List.of();
}));
}
compileOnlyDeps.add(project.getDependencies().create("io.micronaut.openapi:micronaut-openapi"));

var implDeps = project.getConfigurations().getByName("implementation").getDependencies();
implDeps.addAllLater(spec.getUseReactive().map(reactive -> {
if (Boolean.TRUE.equals(reactive)) {
return List.of(project.getDependencies().create("io.projectreactor:reactor-core"));
var compileOnlyDeps = project.getConfigurations().getByName("compileOnly").getDependencies();
if ("java".equalsIgnoreCase(spec.getLang().get())) {
compileOnlyDeps.addAllLater(spec.getLombok().map(lombok -> {
if (Boolean.TRUE.equals(lombok)) {
return List.of(project.getDependencies().create("org.projectlombok:lombok"));
}
return List.of();
}));
}
compileOnlyDeps.add(project.getDependencies().create("io.micronaut.openapi:micronaut-openapi"));

var implDeps = project.getConfigurations().getByName("implementation").getDependencies();
implDeps.addAllLater(spec.getUseReactive().map(reactive -> {
if (Boolean.TRUE.equals(reactive)) {
return List.of(project.getDependencies().create("io.projectreactor:reactor-core"));
}
return List.of();
}));
}
);
}

Expand All @@ -155,9 +156,10 @@ private void configureCommonProperties(String name, AbstractOpenApiGenerator<?,
task.getInvokerPackageName().convention(openApiSpec.getInvokerPackageName());
task.getModelPackageName().convention(openApiSpec.getModelPackageName());
task.getOutputDirectory().convention(
project.getLayout().getBuildDirectory().dir("generated/openapi/" + task.getName())
project.getLayout().getBuildDirectory().dir("generated/openapi/" + task.getName())
);
task.getUseBeanValidation().convention(openApiSpec.getUseBeanValidation());
task.getUseOneOfInterfaces().convention(openApiSpec.getUseOneOfInterfaces());
task.getUseOptional().convention(openApiSpec.getUseOptional());
task.getUseReactive().convention(openApiSpec.getUseReactive());
task.getDefinitionFile().convention(definitionFile);
Expand Down Expand Up @@ -229,12 +231,12 @@ public void client(String name, Provider<RegularFile> definition, Action<? super
});
});
withJava(() -> {
var implDeps = project.getConfigurations().getByName("implementation").getDependencies();
implDeps.add(project.getDependencies().create("io.micronaut:micronaut-http-client-core"));
implDeps.add(project.getDependencies().create("io.micronaut.validation:micronaut-validation"));
var annProcessor = project.getConfigurations().getByName("annotationProcessor").getDependencies();
annProcessor.add(project.getDependencies().create("io.micronaut.validation:micronaut-validation-processor"));
}
var implDeps = project.getConfigurations().getByName("implementation").getDependencies();
implDeps.add(project.getDependencies().create("io.micronaut:micronaut-http-client-core"));
implDeps.add(project.getDependencies().create("io.micronaut.validation:micronaut-validation"));
var annProcessor = project.getConfigurations().getByName("annotationProcessor").getDependencies();
annProcessor.add(project.getDependencies().create("io.micronaut.validation:micronaut-validation-processor"));
}
);
} else {
throwDuplicateEntryFor(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public interface OpenApiSpec {

Property<Boolean> getUseBeanValidation();

Property<Boolean> getUseOneOfInterfaces();

Property<Boolean> getUseOptional();

Property<Boolean> getUseReactive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public abstract class AbstractOpenApiGenerator<W extends AbstractOpenApiWorkActi
@Input
public abstract Property<Boolean> getUseBeanValidation();

@Input
public abstract Property<Boolean> getUseOneOfInterfaces();

@Input
public abstract Property<Boolean> getUseOptional();

Expand Down Expand Up @@ -157,43 +160,44 @@ public abstract class AbstractOpenApiGenerator<W extends AbstractOpenApiWorkActi
@TaskAction
public final void execute() {
getWorkerExecutor().classLoaderIsolation(spec -> spec.getClasspath().from(getClasspath()))
.submit(getWorkerAction(), params -> {
params.getLang().set(getLang());
params.getApiPackageName().set(getApiPackageName());
params.getInvokerPackageName().set(getInvokerPackageName());
params.getSerializationFramework().set(getSerializationFramework());
params.getModelPackageName().set(getModelPackageName());
params.getUseBeanValidation().set(getUseBeanValidation());
params.getUseOptional().set(getUseOptional());
params.getUseReactive().set(getUseReactive());
params.getDefinitionFile().set(getDefinitionFile());
params.getOutputDirectory().set(getOutputDirectory());
params.getOutputKinds().set(getOutputKinds());
params.getAlwaysUseGenerateHttpResponse().set(getAlwaysUseGenerateHttpResponse());
params.getGenerateHttpResponseWhereRequired().set(getGenerateHttpResponseWhereRequired());
params.getDateTimeFormat().set(getDateTimeFormat());
params.getParameterMappings().set(getParameterMappings());
params.getResponseBodyMappings().set(getResponseBodyMappings());
params.getFluxForArrays().set(getFluxForArrays());
params.getGeneratedAnnotation().set(getGeneratedAnnotation());
params.getLombok().set(getLombok());
params.getKsp().set(getKsp());

params.getSchemaMapping().set(getSchemaMapping());
params.getImportMapping().set(getImportMapping());
params.getNameMapping().set(getNameMapping());
params.getTypeMapping().set(getTypeMapping());
params.getEnumNameMapping().set(getEnumNameMapping());
params.getModelNameMapping().set(getModelNameMapping());
params.getInlineSchemaNameMapping().set(getInlineSchemaNameMapping());
params.getInlineSchemaOption().set(getInlineSchemaOption());
params.getOpenapiNormalizer().set(getOpenapiNormalizer());
params.getApiNamePrefix().set(getApiNamePrefix().orElse(""));
params.getApiNameSuffix().set(getApiNameSuffix().orElse(""));
params.getModelNamePrefix().set(getModelNamePrefix().orElse(""));
params.getModelNameSuffix().set(getModelNameSuffix().orElse(""));

configureWorkerParameters(params);
});
.submit(getWorkerAction(), params -> {
params.getLang().set(getLang());
params.getApiPackageName().set(getApiPackageName());
params.getInvokerPackageName().set(getInvokerPackageName());
params.getSerializationFramework().set(getSerializationFramework());
params.getModelPackageName().set(getModelPackageName());
params.getUseBeanValidation().set(getUseBeanValidation());
params.getUseOneOfInterfaces().set(getUseOneOfInterfaces());
params.getUseOptional().set(getUseOptional());
params.getUseReactive().set(getUseReactive());
params.getDefinitionFile().set(getDefinitionFile());
params.getOutputDirectory().set(getOutputDirectory());
params.getOutputKinds().set(getOutputKinds());
params.getAlwaysUseGenerateHttpResponse().set(getAlwaysUseGenerateHttpResponse());
params.getGenerateHttpResponseWhereRequired().set(getGenerateHttpResponseWhereRequired());
params.getDateTimeFormat().set(getDateTimeFormat());
params.getParameterMappings().set(getParameterMappings());
params.getResponseBodyMappings().set(getResponseBodyMappings());
params.getFluxForArrays().set(getFluxForArrays());
params.getGeneratedAnnotation().set(getGeneratedAnnotation());
params.getLombok().set(getLombok());
params.getKsp().set(getKsp());

params.getSchemaMapping().set(getSchemaMapping());
params.getImportMapping().set(getImportMapping());
params.getNameMapping().set(getNameMapping());
params.getTypeMapping().set(getTypeMapping());
params.getEnumNameMapping().set(getEnumNameMapping());
params.getModelNameMapping().set(getModelNameMapping());
params.getInlineSchemaNameMapping().set(getInlineSchemaNameMapping());
params.getInlineSchemaOption().set(getInlineSchemaOption());
params.getOpenapiNormalizer().set(getOpenapiNormalizer());
params.getApiNamePrefix().set(getApiNamePrefix().orElse(""));
params.getApiNameSuffix().set(getApiNameSuffix().orElse(""));
params.getModelNamePrefix().set(getModelNamePrefix().orElse(""));
params.getModelNameSuffix().set(getModelNameSuffix().orElse(""));

configureWorkerParameters(params);
});
}
}
Loading
Loading