Skip to content

Commit

Permalink
Fix kotlin codegen with useAuth=true
Browse files Browse the repository at this point in the history
  • Loading branch information
scprek committed Jul 31, 2024
1 parent 2eeb3f2 commit 5c82796
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def openapiGenerate = tasks.register("generateOpenApi", OpenApiGeneratorTask) {
clientPath = true
ksp = false
useOneOfInterfaces = false
auth = true
classpath.from(configurations.openapiGenerator)
openApiDefinition.convention(layout.projectDirectory.file("petstore.json"))
outputDirectory.convention(layout.buildDirectory.dir("generated/openapi"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public abstract class OpenApiGeneratorTask extends DefaultTask {
@Input
public abstract Property<String> getClientId();

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

@OutputDirectory
public abstract DirectoryProperty getOutputDirectory();

Expand Down Expand Up @@ -154,6 +157,7 @@ public void execute() throws IOException {
args.add(getApiNameSuffix().getOrElse(""));
args.add(getModelNamePrefix().getOrElse(""));
args.add(getModelNameSuffix().getOrElse(""));
args.add(Boolean.toString(getAuth().get()));
javaexec.args(args);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static void main(String[] args) throws URISyntaxException {
String apiSuffix = args[14];
String modelPrefix = args[15];
String modelSuffix = args[16];
var auth = Boolean.parseBoolean(args[17]);

var builder = MicronautCodeGeneratorEntryPoint.builder()
.withDefinitionFile(definitionFile)
Expand Down Expand Up @@ -108,7 +109,7 @@ public static void main(String[] args) throws URISyntaxException {
// commented out because currently this would prevent the test project from compiling
// because we generate both abstract classes _and_ dummy implementations
.withGenerateImplementationFiles(false)
.withAuthentication(false)
.withAuthentication(auth)
.withKsp(ksp)
.withGeneratedAnnotation(generatedAnnotation)
);
Expand All @@ -119,7 +120,7 @@ public static void main(String[] args) throws URISyntaxException {
// commented out because currently this would prevent the test project from compiling
// because we generate both abstract classes _and_ dummy implementations
.withGenerateImplementationFiles(false)
.withAuthentication(false)
.withAuthentication(auth)
.withGeneratedAnnotation(generatedAnnotation)
);
}
Expand All @@ -129,6 +130,7 @@ public static void main(String[] args) throws URISyntaxException {
clientOptions
.withGeneratedAnnotation(generatedAnnotation)
.withKsp(ksp)
.withAuthorization(auth)
.withClientPath(clientPath)
.withClientId(clientId)
);
Expand All @@ -137,6 +139,7 @@ public static void main(String[] args) throws URISyntaxException {
clientOptions
.withGeneratedAnnotation(generatedAnnotation)
.withClientPath(clientPath)
.withAuthorization(auth)
.withClientId(clientId)
);
}
Expand Down

0 comments on commit 5c82796

Please sign in to comment.