Skip to content

Commit 7d5f4ff

Browse files
author
andrewwilsonnew
committed
fixup processOpts
1 parent 8657f1c commit 7d5f4ff

1 file changed

Lines changed: 15 additions & 44 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinMiskServerCodegen.java

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public class KotlinMiskServerCodegen extends AbstractKotlinCodegen implements Be
8484
@Setter protected String actionRequestContentType = "@RequestContentType";
8585
@Setter protected String actionRequestContentTypePrefix = "MediaTypes";
8686
@Setter protected String testingModule = moduleClassName;
87+
@Setter protected String testingModuleName;
8788

8889
@Override
8990
public CodegenType getTag() {
@@ -184,56 +185,21 @@ public KotlinMiskServerCodegen() {
184185
public void processOpts() {
185186
super.processOpts();
186187

187-
if (additionalProperties.containsKey(MODULE_CLASS_NAME)) {
188-
setModuleClassName((String) additionalProperties.get(MODULE_CLASS_NAME));
189-
}
190-
writePropertyBack(MODULE_CLASS_NAME, moduleClassName);
191-
192-
if (additionalProperties.containsKey(ACTION_PATH_PREFIX)) {
193-
setActionPathPrefix((String) additionalProperties.get(ACTION_PATH_PREFIX));
194-
}
195-
writePropertyBack(ACTION_PATH_PREFIX, actionPathPrefix);
196-
197188
convertPropertyToTypeAndWriteBack(ACTION_ANNOTATIONS,
198189
it -> Arrays.asList(it.split(";")), this::setActionAnnotations);
199190

200191
convertPropertyToTypeAndWriteBack(ACTION_IMPORTS,
201192
it -> Arrays.asList(it.split(";")), this::setActionImports);
202193

203-
if (additionalProperties.containsKey(ACTION_PARENT_CLASS)) {
204-
setActionParentClass((String) additionalProperties.get(ACTION_PARENT_CLASS));
205-
}
206-
writePropertyBack(ACTION_PARENT_CLASS, actionParentClass);
207-
208-
if (additionalProperties.containsKey(ACTION_REQUEST_CONTENT_TYPE)) {
209-
setActionRequestContentType((String) additionalProperties.get(ACTION_REQUEST_CONTENT_TYPE));
210-
}
211-
writePropertyBack(ACTION_REQUEST_CONTENT_TYPE, actionRequestContentType);
212-
213-
if (additionalProperties.containsKey(ACTION_REQUEST_CONTENT_TYPE_PREFIX)) {
214-
setActionRequestContentTypePrefix((String) additionalProperties.get(ACTION_REQUEST_CONTENT_TYPE_PREFIX));
215-
}
216-
writePropertyBack(ACTION_REQUEST_CONTENT_TYPE_PREFIX, actionRequestContentTypePrefix);
217-
218-
if (additionalProperties.containsKey(TESTING_MODULE)) {
219-
setTestingModule((String) additionalProperties.get(TESTING_MODULE));
220-
}
221-
writePropertyBack(TESTING_MODULE, testingModule);
222-
223-
if (additionalProperties.containsKey(USE_BEANVALIDATION)) {
224-
this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION));
225-
}
226-
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
227-
228-
if (additionalProperties.containsKey(GENERATE_STUB_IMPL_CLASSES)) {
229-
setGenerateStubImplClasses(convertPropertyToBoolean(GENERATE_STUB_IMPL_CLASSES));
230-
}
231-
writePropertyBack(GENERATE_STUB_IMPL_CLASSES, generateStubImplClasses);
232-
233-
if (additionalProperties.containsKey(ADD_MODEL_MOSHI_JSON_ANNOTATION)) {
234-
setAddModelMoshiJsonAnnotation(convertPropertyToBoolean(ADD_MODEL_MOSHI_JSON_ANNOTATION));
235-
}
236-
writePropertyBack(ADD_MODEL_MOSHI_JSON_ANNOTATION, addModelMoshiJsonAnnotation);
194+
convertPropertyToStringAndWriteBack(MODULE_CLASS_NAME, this::setModuleClassName);
195+
convertPropertyToStringAndWriteBack(ACTION_PATH_PREFIX, this::setActionPathPrefix);
196+
convertPropertyToStringAndWriteBack(ACTION_PARENT_CLASS, this::setActionParentClass);
197+
convertPropertyToStringAndWriteBack(ACTION_REQUEST_CONTENT_TYPE, this::setActionRequestContentType);
198+
convertPropertyToStringAndWriteBack(ACTION_REQUEST_CONTENT_TYPE_PREFIX, this::setActionRequestContentTypePrefix);
199+
convertPropertyToStringAndWriteBack(TESTING_MODULE, this::setTestingModule);
200+
convertPropertyToBooleanAndWriteBack(USE_BEANVALIDATION, this::setUseBeanValidation);
201+
convertPropertyToBooleanAndWriteBack(GENERATE_STUB_IMPL_CLASSES, this::setGenerateStubImplClasses);
202+
convertPropertyToBooleanAndWriteBack(ADD_MODEL_MOSHI_JSON_ANNOTATION, this::setAddModelMoshiJsonAnnotation);
237203

238204
applyJakartaPackage();
239205

@@ -281,6 +247,11 @@ private String mapMediaType(String mediaType) {
281247
return MEDIA_MAPPING.getOrDefault(mediaType, "APPLICATION_OCTETSTREAM /* @todo(unknown) -> " + mediaType + " */ ");
282248
}
283249

250+
public String getTestingModuleName() {
251+
System.out.println("***" + testingModule.substring(testingModule.lastIndexOf(".")));
252+
return testingModule.substring(testingModule.lastIndexOf("."));
253+
}
254+
284255
private final static Map<String, String> MEDIA_MAPPING = getMappings();
285256

286257
private static Map<String, String> getMappings() {

0 commit comments

Comments
 (0)