mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-05 22:46:09 +00:00
Add new option to customize inline model naming convention (#12562)
* temp fix
* add support to customize inline schema naming convention
* Revert "temp fix"
This reverts commit e3bca56bfb.
* minor fix, add tests
* update description
This commit is contained in:
@@ -51,6 +51,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private final Map<String, Object> additionalProperties;
|
||||
private final Map<String, String> importMappings;
|
||||
private final Map<String, String> inlineSchemaNameMappings;
|
||||
private final Map<String, String> inlineSchemaNameDefaults;
|
||||
private final Set<String> languageSpecificPrimitives;
|
||||
private final Map<String, String> reservedWordsMappings;
|
||||
private final Map<String, String> serverVariables;
|
||||
@@ -244,6 +245,15 @@ public final class GeneratorSettings implements Serializable {
|
||||
return inlineSchemaNameMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets inline schema name defaults between an inline schema naming convention and the default values.
|
||||
*
|
||||
* @return the inline schema name defaults
|
||||
*/
|
||||
public Map<String, String> getInlineSchemaNameDefaults() {
|
||||
return inlineSchemaNameDefaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets language specific primitives. These are in addition to the "base" primitives defined in a generator.
|
||||
* <p>
|
||||
@@ -360,6 +370,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
typeMappings = Collections.unmodifiableMap(builder.typeMappings);
|
||||
importMappings = Collections.unmodifiableMap(builder.importMappings);
|
||||
inlineSchemaNameMappings = Collections.unmodifiableMap(builder.inlineSchemaNameMappings);
|
||||
inlineSchemaNameDefaults = Collections.unmodifiableMap(builder.inlineSchemaNameDefaults);
|
||||
languageSpecificPrimitives = Collections.unmodifiableSet(builder.languageSpecificPrimitives);
|
||||
reservedWordsMappings = Collections.unmodifiableMap(builder.reservedWordsMappings);
|
||||
serverVariables = Collections.unmodifiableMap(builder.serverVariables);
|
||||
@@ -431,6 +442,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
additionalProperties = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
importMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
inlineSchemaNameMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
inlineSchemaNameDefaults = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
languageSpecificPrimitives = Collections.unmodifiableSet(new HashSet<>(0));
|
||||
reservedWordsMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
serverVariables = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
@@ -485,6 +497,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
if (copy.getInlineSchemaNameMappings() != null) {
|
||||
builder.inlineSchemaNameMappings.putAll(copy.getInlineSchemaNameMappings());
|
||||
}
|
||||
if (copy.getInlineSchemaNameDefaults() != null) {
|
||||
builder.inlineSchemaNameDefaults.putAll(copy.getInlineSchemaNameDefaults());
|
||||
}
|
||||
if (copy.getLanguageSpecificPrimitives() != null) {
|
||||
builder.languageSpecificPrimitives.addAll(copy.getLanguageSpecificPrimitives());
|
||||
}
|
||||
@@ -525,6 +540,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private Map<String, Object> additionalProperties;
|
||||
private Map<String, String> importMappings;
|
||||
private Map<String, String> inlineSchemaNameMappings;
|
||||
private Map<String, String> inlineSchemaNameDefaults;
|
||||
private Set<String> languageSpecificPrimitives;
|
||||
private Map<String, String> reservedWordsMappings;
|
||||
private Map<String, String> serverVariables;
|
||||
@@ -543,6 +559,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
additionalProperties = new HashMap<>();
|
||||
importMappings = new HashMap<>();
|
||||
inlineSchemaNameMappings = new HashMap<>();
|
||||
inlineSchemaNameDefaults = new HashMap<>();
|
||||
languageSpecificPrimitives = new HashSet<>();
|
||||
reservedWordsMappings = new HashMap<>();
|
||||
serverVariables = new HashMap<>();
|
||||
@@ -785,6 +802,32 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code inlineSchemaNameDefaults} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param inlineSchemaNameDefaults the {@code inlineSchemaNameDefaults} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withInlineSchemaNameDefaults(Map<String, String> inlineSchemaNameDefaults) {
|
||||
this.inlineSchemaNameDefaults = inlineSchemaNameDefaults;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single {@code inlineSchemaNameDefaults} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key Default naming convention
|
||||
* @param value The value
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withInlineSchemaNameDefault(String key, String value) {
|
||||
if (this.inlineSchemaNameDefaults == null) {
|
||||
this.inlineSchemaNameDefaults = new HashMap<>();
|
||||
}
|
||||
this.inlineSchemaNameDefaults.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code inlineSchemaNameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -799,8 +842,8 @@ public final class GeneratorSettings implements Serializable {
|
||||
/**
|
||||
* Sets a single {@code inlineSchemaNameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key A key for some import mapping
|
||||
* @param value The value of some import mapping
|
||||
* @param key A key for the inline schema mapping
|
||||
* @param value The value of inline schema mapping
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withInlineSchemaNameMapping(String key, String value) {
|
||||
@@ -997,6 +1040,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
Objects.equals(getAdditionalProperties(), that.getAdditionalProperties()) &&
|
||||
Objects.equals(getImportMappings(), that.getImportMappings()) &&
|
||||
Objects.equals(getInlineSchemaNameMappings(), that.getInlineSchemaNameMappings()) &&
|
||||
Objects.equals(getInlineSchemaNameDefaults(), that.getInlineSchemaNameDefaults()) &&
|
||||
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
|
||||
Objects.equals(getReservedWordsMappings(), that.getReservedWordsMappings()) &&
|
||||
Objects.equals(getGitHost(), that.getGitHost()) &&
|
||||
@@ -1026,6 +1070,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
getAdditionalProperties(),
|
||||
getImportMappings(),
|
||||
getInlineSchemaNameMappings(),
|
||||
getInlineSchemaNameDefaults(),
|
||||
getLanguageSpecificPrimitives(),
|
||||
getReservedWordsMappings(),
|
||||
getGitHost(),
|
||||
|
||||
Reference in New Issue
Block a user