Skip to content

Commit ecf796e

Browse files
Fixes
1 parent 3eb4324 commit ecf796e

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautJavaCodegen.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,10 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
664664
for (var param : op.allParams) {
665665
processGenericAnnotations(param);
666666
}
667-
processGenericAnnotations(op.returnProperty);
668-
op.returnType = op.returnProperty.vendorExtensions.get("typeWithEnumWithGenericAnnotations").toString();
667+
if (op.returnProperty != null) {
668+
processGenericAnnotations(op.returnProperty);
669+
op.returnType = op.returnProperty.vendorExtensions.get("typeWithEnumWithGenericAnnotations").toString();
670+
}
669671
}
670672

671673
return objs;
@@ -690,7 +692,8 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
690692

691693
if (op.isResponseFile) {
692694
op.returnType = typeMapping.get("responseFile");
693-
op.returnProperty.dataType = op.returnProperty.datatypeWithEnum = op.returnType;
695+
op.returnProperty.dataType = op.returnType;
696+
op.returnProperty.datatypeWithEnum = op.returnType;
694697
op.imports.add(op.returnType);
695698
}
696699

@@ -814,7 +817,8 @@ private void wrapOperationReturnType(CodegenOperation op, String wrapperType, bo
814817
newReturnType.dataType = typeName + '<' + originalReturnType + '>';
815818
newReturnType.items = op.returnProperty;
816819
}
817-
newReturnType.containerTypeMapped = newReturnType.containerType = typeName;
820+
newReturnType.containerTypeMapped = typeName;
821+
newReturnType.containerType = typeName;
818822
op.vendorExtensions.put("originalReturnType", originalReturnType);
819823

820824
op.returnType = newReturnType.dataType;
@@ -934,8 +938,6 @@ private void processGenericAnnotations(String dataType, String dataTypeWithEnum,
934938
typeWithGenericAnnotations = "Map<String, " + genericAnnotations + itemsProp.vendorExtensions.get("typeWithGenericAnnotations") + ">";
935939
typeWithEnumWithGenericAnnotations = "Map<String, " + genericAnnotations + itemsProp.vendorExtensions.get("typeWithEnumWithGenericAnnotations") + ">";
936940
} else if (containerType != null) {
937-
System.out.println("Container: " + containerType);
938-
System.out.println("Items: " + itemsProp);
939941
var genericAnnotations = genericAnnotations(itemsProp);
940942
processGenericAnnotations(itemsProp);
941943
typeWithGenericAnnotations = containerType + "<" + genericAnnotations + itemsProp.vendorExtensions.get("typeWithGenericAnnotations") + ">";

openapi-generator/src/test/java/io/micronaut/openapi/generator/MicronautServerCodegenTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void doGenerateMonoWrapHttpResponse() {
207207
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.MODELS, CodegenConstants.APIS);
208208

209209
String apiPath = outputPath + "src/main/java/org/openapitools/api/";
210-
assertFileContains(apiPath + "PetApi.java", "Mono<HttpResponse<Pet>>");
210+
assertFileContains(apiPath + "PetApi.java", "Mono<HttpResponse<@Valid Pet>>");
211211
}
212212

213213
@Test
@@ -219,8 +219,8 @@ void doGenerateMono() {
219219
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.MODELS, CodegenConstants.APIS);
220220

221221
String apiPath = outputPath + "src/main/java/org/openapitools/api/";
222-
assertFileContains(apiPath + "PetApi.java", "Mono<Pet>");
223-
assertFileNotContains(apiPath + "PetApi.java", "Flux<Pet>");
222+
assertFileContains(apiPath + "PetApi.java", "Mono<@Valid Pet>");
223+
assertFileNotContains(apiPath + "PetApi.java", "Flux<@Valid Pet>");
224224
assertFileNotContains(apiPath + "PetApi.java", "HttpResponse");
225225
}
226226

@@ -233,8 +233,8 @@ void doGenerateMonoAndFlux() {
233233
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.MODELS, CodegenConstants.APIS);
234234

235235
String apiPath = outputPath + "src/main/java/org/openapitools/api/";
236-
assertFileContains(apiPath + "PetApi.java", "Mono<Pet>");
237-
assertFileContains(apiPath + "PetApi.java", "Flux<Pet>");
236+
assertFileContains(apiPath + "PetApi.java", "Mono<@Valid Pet>");
237+
assertFileContains(apiPath + "PetApi.java", "Flux<@Valid Pet>");
238238
assertFileNotContains(apiPath + "PetApi.java", "HttpResponse");
239239
}
240240

@@ -246,7 +246,7 @@ void doGenerateWrapHttpResponse() {
246246
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.MODELS, CodegenConstants.APIS);
247247

248248
String apiPath = outputPath + "src/main/java/org/openapitools/api/";
249-
assertFileContains(apiPath + "PetApi.java", "HttpResponse<Pet>");
249+
assertFileContains(apiPath + "PetApi.java", "HttpResponse<@Valid Pet>");
250250
assertFileNotContains(apiPath + "PetApi.java", "Mono");
251251
}
252252

0 commit comments

Comments
 (0)