Skip to content

Commit

Permalink
OpenApi Generator 7.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
altro3 committed Oct 10, 2024
1 parent 6d5c15f commit a83be2c
Show file tree
Hide file tree
Showing 6 changed files with 826 additions and 506 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jspecify = "1.0.0"
jdt-annotation = "2.3.0"
android-annotation = "1.8.2"
spotbugs-annotations = "4.8.6"
openapi-generator = "7.8.0"
openapi-generator = "7.9.0"
swagger-parser = "1.0.71"
swagger-parser-v3 = "2.1.22"
javaparser = "3.26.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public abstract class AbstractMicronautJavaCodegen<T extends GeneratorOptionsBui
public static final String OPT_GENERATE_SWAGGER_ANNOTATIONS_TRUE = "true";
public static final String OPT_GENERATE_SWAGGER_ANNOTATIONS_FALSE = "false";
public static final String OPT_GENERATE_OPERATION_ONLY_FOR_FIRST_TAG = "generateOperationOnlyForFirstTag";
public static final String OPT_SKIP_SORTING_OPERATIONS = "skipSortingOperations";
public static final String CONTENT_TYPE_APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
public static final String CONTENT_TYPE_APPLICATION_JSON = "application/json";
public static final String CONTENT_TYPE_MULTIPART_FORM_DATA = "multipart/form-data";
Expand Down Expand Up @@ -551,6 +552,8 @@ public void processOpts() {
writePropertyBack(USE_JAKARTA_EE, useJakartaEe);
writePropertyBack(JAVAX_PACKAGE, useJakartaEe ? "jakarta" : "javax");

convertPropertyToBooleanAndWriteBack(OPT_SKIP_SORTING_OPERATIONS, this::setSkipSortingOperations);

maybeSetTestTool();
writePropertyBack(OPT_TEST, testTool);
if (testTool.equals(OPT_TEST_JUNIT)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ private void configureOptions() {
javaCodeGen.setSerializationLibrary(options.serializationLibraryKind.name());
javaCodeGen.setGenerateSwaggerAnnotations(options.generateSwaggerAnnotations);
javaCodeGen.setDateTimeLibrary(options.dateTimeFormat.name());

javaCodeGen.setSortParamsByRequiredFlag(options.sortParamsByRequiredFlag);
javaCodeGen.setSkipOperationExample(options.skipOperationExample);
javaCodeGen.setSkipSortingOperations(options.skipSortingOperations);
javaCodeGen.setRemoveOperationIdPrefixDelimiter(options.removeOperationIdPrefixDelimiter);
javaCodeGen.setRemoveOperationIdPrefixCount(options.removeOperationIdPrefixCount);
javaCodeGen.setSortModelPropertiesByRequiredFlag(options.sortModelPropertiesByRequiredFlag);
javaCodeGen.setEnsureUniqueParams(options.ensureUniqueParams);
javaCodeGen.setAllowUnicodeIdentifiers(options.allowUnicodeIdentifiers);
javaCodeGen.setPrependFormOrBodyParameters(options.prependFormOrBodyParameters);

configureJavaServerOptions();
configureJavaClientOptions();
} else if (options.lang == GeneratorLanguage.KOTLIN && codeGenerator instanceof AbstractMicronautKotlinCodegen<?> kotlinCodeGen) {
Expand Down Expand Up @@ -294,6 +305,17 @@ private void configureOptions() {
kotlinCodeGen.setTestTool(options.testFramework.value);
kotlinCodeGen.setSerializationLibrary(options.serializationLibraryKind.name());
kotlinCodeGen.setDateTimeLibrary(options.dateTimeFormat.name());

kotlinCodeGen.setSortParamsByRequiredFlag(options.sortParamsByRequiredFlag);
kotlinCodeGen.setSkipOperationExample(options.skipOperationExample);
kotlinCodeGen.setSkipSortingOperations(options.skipSortingOperations);
kotlinCodeGen.setRemoveOperationIdPrefixDelimiter(options.removeOperationIdPrefixDelimiter);
kotlinCodeGen.setRemoveOperationIdPrefixCount(options.removeOperationIdPrefixCount);
kotlinCodeGen.setSortModelPropertiesByRequiredFlag(options.sortModelPropertiesByRequiredFlag);
kotlinCodeGen.setEnsureUniqueParams(options.ensureUniqueParams);
kotlinCodeGen.setAllowUnicodeIdentifiers(options.allowUnicodeIdentifiers);
kotlinCodeGen.setPrependFormOrBodyParameters(options.prependFormOrBodyParameters);

configureKotlinServerOptions();
configureKotlinClientOptions();
}
Expand Down Expand Up @@ -572,6 +594,16 @@ private static class DefaultOptionsBuilder implements MicronautCodeGeneratorOpti
private List<String> additionalOneOfTypeAnnotations;
private Map<String, Object> additionalProperties;

boolean sortParamsByRequiredFlag = true;
boolean skipOperationExample;
boolean skipSortingOperations;
String removeOperationIdPrefixDelimiter;
int removeOperationIdPrefixCount;
boolean sortModelPropertiesByRequiredFlag = true;
boolean ensureUniqueParams = true;
boolean allowUnicodeIdentifiers = true;
boolean prependFormOrBodyParameters;

@Override
public MicronautCodeGeneratorOptionsBuilder withLang(GeneratorLanguage lang) {
this.lang = lang;
Expand Down Expand Up @@ -800,6 +832,60 @@ public MicronautCodeGeneratorOptionsBuilder withUseJakartaEe(boolean useJakartaE
return this;
}

@Override
public MicronautCodeGeneratorOptionsBuilder withSortParamsByRequiredFlag(boolean sortParamsByRequiredFlag) {
this.sortParamsByRequiredFlag = sortParamsByRequiredFlag;
return this;
}

@Override
public MicronautCodeGeneratorOptionsBuilder withSkipOperationExample(boolean skipOperationExample) {
this.skipOperationExample = skipOperationExample;
return this;
}

@Override
public MicronautCodeGeneratorOptionsBuilder withSkipSortingOperations(boolean skipSortingOperations) {
this.skipSortingOperations = skipSortingOperations;
return this;
}

@Override
public MicronautCodeGeneratorOptionsBuilder withRemoveOperationIdPrefixDelimiter(String removeOperationIdPrefixDelimiter) {
this.removeOperationIdPrefixDelimiter = removeOperationIdPrefixDelimiter;
return this;
}

@Override
public MicronautCodeGeneratorOptionsBuilder withRemoveOperationIdPrefixCount(int removeOperationIdPrefixCount) {
this.removeOperationIdPrefixCount = removeOperationIdPrefixCount;
return this;
}

@Override
public MicronautCodeGeneratorOptionsBuilder withSortModelPropertiesByRequiredFlag(boolean sortModelPropertiesByRequiredFlag) {
this.sortModelPropertiesByRequiredFlag = sortModelPropertiesByRequiredFlag;
return this;
}

@Override
public MicronautCodeGeneratorOptionsBuilder withEnsureUniqueParams(boolean ensureUniqueParams) {
this.ensureUniqueParams = ensureUniqueParams;
return this;
}

@Override
public MicronautCodeGeneratorOptionsBuilder withAllowUnicodeIdentifiers(boolean allowUnicodeIdentifiers) {
this.allowUnicodeIdentifiers = allowUnicodeIdentifiers;
return this;
}

@Override
public MicronautCodeGeneratorOptionsBuilder withPrependFormOrBodyParameters(boolean prependFormOrBodyParameters) {
this.prependFormOrBodyParameters = prependFormOrBodyParameters;
return this;
}

private Options build() {
return new Options(
lang,
Expand Down Expand Up @@ -842,7 +928,17 @@ private Options build() {
additionalEnumTypeAnnotations,
additionalModelTypeAnnotations,
additionalOneOfTypeAnnotations,
additionalProperties
additionalProperties,

sortParamsByRequiredFlag,
skipOperationExample,
skipSortingOperations,
removeOperationIdPrefixDelimiter,
removeOperationIdPrefixCount,
sortModelPropertiesByRequiredFlag,
ensureUniqueParams,
allowUnicodeIdentifiers,
prependFormOrBodyParameters
);
}
}
Expand Down Expand Up @@ -905,7 +1001,17 @@ private record Options(
List<String> additionalEnumTypeAnnotations,
List<String> additionalModelTypeAnnotations,
List<String> additionalOneOfTypeAnnotations,
Map<String, Object> additionalProperties
Map<String, Object> additionalProperties,

boolean sortParamsByRequiredFlag,
boolean skipOperationExample,
boolean skipSortingOperations,
String removeOperationIdPrefixDelimiter,
int removeOperationIdPrefixCount,
boolean sortModelPropertiesByRequiredFlag,
boolean ensureUniqueParams,
boolean allowUnicodeIdentifiers,
boolean prependFormOrBodyParameters
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,83 @@ public interface MicronautCodeGeneratorOptionsBuilder {
*/
MicronautCodeGeneratorOptionsBuilder withUseJakartaEe(boolean useJakartaEe);

/**
* Sort method arguments to place required parameters before optional parameters.
* Default: true
*
* @param sortParamsByRequiredFlag Sort method arguments to place required parameters before optional parameters
*
* @return this builder
*/
MicronautCodeGeneratorOptionsBuilder withSortParamsByRequiredFlag(boolean sortParamsByRequiredFlag);

/**
* Skip examples defined in operations to avoid out of memory errors.
* Default: false
*
* @param skipOperationExample Skip examples defined in operations to avoid out of memory errors.
*
* @return this builder
*/
MicronautCodeGeneratorOptionsBuilder withSkipOperationExample(boolean skipOperationExample);

/**
* Skip sorting operations.
* Default: false
*
* @param skipSortingOperations Skip sorting operations
* @return this builder
*/
MicronautCodeGeneratorOptionsBuilder withSkipSortingOperations(boolean skipSortingOperations);

/**
* Character to use as a delimiter for the prefix. Default: '_'
*
* @param removeOperationIdPrefixDelimiter Character to use as a delimiter for the prefix. Default: '_'
* @return this builder
*/
MicronautCodeGeneratorOptionsBuilder withRemoveOperationIdPrefixDelimiter(String removeOperationIdPrefixDelimiter);

/**
* Count of delimiter for the prefix. Use -1 for last Default: 1
*
* @param removeOperationIdPrefixCount Count of delimiter for the prefix. Use -1 for last Default: 1
* @return this builder
*/
MicronautCodeGeneratorOptionsBuilder withRemoveOperationIdPrefixCount(int removeOperationIdPrefixCount);

/**
* Sort model properties to place required parameters before optional parameters.
*
* @param sortModelPropertiesByRequiredFlag Sort model properties to place required parameters before optional parameters.
* @return this builder
*/
MicronautCodeGeneratorOptionsBuilder withSortModelPropertiesByRequiredFlag(boolean sortModelPropertiesByRequiredFlag);

/**
* Whether to ensure parameter names are unique in an operation (rename parameters that are not).
*
* @param ensureUniqueParams Whether to ensure parameter names are unique in an operation (rename parameters that are not).
* @return this builder
*/
MicronautCodeGeneratorOptionsBuilder withEnsureUniqueParams(boolean ensureUniqueParams);

/**
* boolean, toggles whether Unicode identifiers are allowed in names or not, default is false
*
* @param allowUnicodeIdentifiers toggles whether Unicode identifiers are allowed in names or not, default is false
* @return this builder
*/
MicronautCodeGeneratorOptionsBuilder withAllowUnicodeIdentifiers(boolean allowUnicodeIdentifiers);

/**
* Add form or body parameters to the beginning of the parameter list.
*
* @param prependFormOrBodyParameters Add form or body parameters to the beginning of the parameter list.
* @return this builder
*/
MicronautCodeGeneratorOptionsBuilder withPrependFormOrBodyParameters(boolean prependFormOrBodyParameters);

/**
* The possible date-time formatting configurations.
*/
Expand Down
Loading

0 comments on commit a83be2c

Please sign in to comment.