Skip to content

Commit

Permalink
Micronaut openapi 6.12.4
Browse files Browse the repository at this point in the history
  • Loading branch information
altro3 committed Sep 17, 2024
1 parent c9398f5 commit bd95c48
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 1 deletion.
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.6.0" # This is the platform version, used in our tests
micronaut-aot = "2.4.0"
micronaut-testresources = "2.5.4"
micronaut-openapi = "6.12.2"
micronaut-openapi = "6.12.3"

[libraries]
# Core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,15 @@ private void configureCommonProperties(String name, AbstractOpenApiGenerator<?,
task.getModelNamePrefix().convention(openApiSpec.getModelNamePrefix());
task.getModelNameSuffix().convention(openApiSpec.getModelNameSuffix());

task.getUseEnumCaseInsensitive().convention(openApiSpec.getUseEnumCaseInsensitive());
task.getGenerateSwaggerAnnotations().convention(openApiSpec.getGenerateSwaggerAnnotations());
task.getImplicitHeaders().convention(openApiSpec.getImplicitHeaders());
task.getImplicitHeadersRegex().convention(openApiSpec.getImplicitHeadersRegex());

task.getAdditionalEnumTypeAnnotations().convention(openApiSpec.getAdditionalEnumTypeAnnotations());
task.getAdditionalModelTypeAnnotations().convention(openApiSpec.getAdditionalModelTypeAnnotations());
task.getAdditionalOneOfTypeAnnotations().convention(openApiSpec.getAdditionalOneOfTypeAnnotations());
task.getAdditionalProperties().convention(openApiSpec.getAdditionalProperties());
}

private void withJavaSourceSets(Consumer<? super SourceSetContainer> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,19 @@ public interface OpenApiSpec {

Property<String> getModelNameSuffix();

Property<Boolean> getUseEnumCaseInsensitive();

Property<Boolean> getGenerateSwaggerAnnotations();

Property<Boolean> getImplicitHeaders();

Property<String> getImplicitHeadersRegex();

ListProperty<String> getAdditionalEnumTypeAnnotations();

ListProperty<String> getAdditionalModelTypeAnnotations();

ListProperty<String> getAdditionalOneOfTypeAnnotations();

MapProperty<String, Object> getAdditionalProperties();
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public abstract class AbstractOpenApiGenerator<W extends AbstractOpenApiWorkActi
@Input
public abstract Property<String> getModelNameSuffix();

@Optional
@Input
public abstract Property<Boolean> getUseEnumCaseInsensitive();

@Optional
@Input
public abstract Property<Boolean> getGenerateSwaggerAnnotations();
Expand All @@ -158,6 +162,22 @@ public abstract class AbstractOpenApiGenerator<W extends AbstractOpenApiWorkActi
@Input
public abstract Property<String> getImplicitHeadersRegex();

@Optional
@Input
public abstract ListProperty<String> getAdditionalEnumTypeAnnotations();

@Optional
@Input
public abstract ListProperty<String> getAdditionalModelTypeAnnotations();

@Optional
@Input
public abstract ListProperty<String> getAdditionalOneOfTypeAnnotations();

@Optional
@Input
public abstract MapProperty<String, Object> getAdditionalProperties();

@OutputDirectory
public abstract DirectoryProperty getOutputDirectory();

Expand Down Expand Up @@ -209,10 +229,16 @@ public final void execute() {
params.getModelNamePrefix().set(getModelNamePrefix().orElse(""));
params.getModelNameSuffix().set(getModelNameSuffix().orElse(""));

params.getUseEnumCaseInsensitive().set(getUseEnumCaseInsensitive());
params.getGenerateSwaggerAnnotations().set(getGenerateSwaggerAnnotations());
params.getImplicitHeaders().set(getImplicitHeaders());
params.getImplicitHeadersRegex().set(getImplicitHeadersRegex().orElse(""));

params.getAdditionalEnumTypeAnnotations().set(getAdditionalEnumTypeAnnotations());
params.getAdditionalModelTypeAnnotations().set(getAdditionalModelTypeAnnotations());
params.getAdditionalOneOfTypeAnnotations().set(getAdditionalOneOfTypeAnnotations());
params.getAdditionalProperties().set(getAdditionalProperties());

configureWorkerParameters(params);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,21 @@ interface OpenApiParameters extends WorkParameters {

Property<String> getModelNameSuffix();

Property<Boolean> getUseEnumCaseInsensitive();

Property<Boolean> getGenerateSwaggerAnnotations();

Property<Boolean> getImplicitHeaders();

Property<String> getImplicitHeadersRegex();

ListProperty<String> getAdditionalEnumTypeAnnotations();

ListProperty<String> getAdditionalModelTypeAnnotations();

ListProperty<String> getAdditionalOneOfTypeAnnotations();

MapProperty<String, Object> getAdditionalProperties();
}

protected abstract void configureBuilder(MicronautCodeGeneratorBuilder builder);
Expand Down Expand Up @@ -179,6 +189,11 @@ public void execute() {
.withGenerateSwaggerAnnotations(parameters.getGenerateSwaggerAnnotations().get())
.withImplicitHeaders(parameters.getImplicitHeaders().get())
.withImplicitHeadersRegex(parameters.getImplicitHeadersRegex().orElse("").get())
.withUseEnumCaseInsensitive(parameters.getUseEnumCaseInsensitive().get())
.withAdditionalEnumTypeAnnotations(parameters.getAdditionalEnumTypeAnnotations().get())
.withAdditionalModelTypeAnnotations(parameters.getAdditionalModelTypeAnnotations().get())
.withAdditionalOneOfTypeAnnotations(parameters.getAdditionalOneOfTypeAnnotations().get())
.withAdditionalProperties(parameters.getAdditionalProperties().get())
);

configureBuilder(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class OpenApiClientGeneratorSpec extends AbstractOpenApiGeneratorSpec {
clientId = "my-client"
generateSwaggerAnnotations = true
implicitHeadersRegex = ".*"
useEnumCaseInsensitive = ".*"
}
}
}
Expand Down

0 comments on commit bd95c48

Please sign in to comment.