forked from loafle/openapi-generator-original
Add hasReadOnly property to CodegenModel (#17942)
* add hasReadOnly property to CodegenModel * add for CodegenModel subclasses
This commit is contained in:
@@ -110,7 +110,14 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
* Indicates the OAS schema specifies "deprecated: true".
|
||||
*/
|
||||
public boolean isDeprecated;
|
||||
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
|
||||
/**
|
||||
* Indicates the type has at least one read-only property.
|
||||
*/
|
||||
public boolean hasReadOnly;
|
||||
/**
|
||||
* Indicates the all properties of the type are read-only.
|
||||
*/
|
||||
public boolean hasOnlyReadOnly = true;
|
||||
public ExternalDocumentation externalDocumentation;
|
||||
|
||||
public Map<String, Object> vendorExtensions = new HashMap<>();
|
||||
@@ -1122,6 +1129,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
hasChildren == that.hasChildren &&
|
||||
isMap == that.isMap &&
|
||||
isDeprecated == that.isDeprecated &&
|
||||
hasReadOnly == that.hasReadOnly &&
|
||||
hasOnlyReadOnly == that.hasOnlyReadOnly &&
|
||||
isNull == that.isNull &&
|
||||
hasValidation == that.hasValidation &&
|
||||
@@ -1213,7 +1221,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
getVars(), getAllVars(), getNonNullableVars(), getRequiredVars(), getOptionalVars(), getReadOnlyVars(), getReadWriteVars(),
|
||||
getParentVars(), getAllowableValues(), getMandatory(), getAllMandatory(), getImports(), hasVars,
|
||||
isEmptyVars(), hasMoreModels, hasEnums, isEnum, isNullable, hasRequired, hasOptional, isArray,
|
||||
hasChildren, isMap, isDeprecated, hasOnlyReadOnly, getExternalDocumentation(), getVendorExtensions(),
|
||||
hasChildren, isMap, isDeprecated, hasReadOnly, hasOnlyReadOnly, getExternalDocumentation(), getVendorExtensions(),
|
||||
getAdditionalPropertiesType(), getMaxProperties(), getMinProperties(), getUniqueItems(), getMaxItems(),
|
||||
getMinItems(), getMaxLength(), getMinLength(), getExclusiveMinimum(), getExclusiveMaximum(), getMinimum(),
|
||||
getMaximum(), getPattern(), getMultipleOf(), getItems(), getAdditionalProperties(), getIsModel(),
|
||||
@@ -1289,6 +1297,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
sb.append(", hasChildren=").append(hasChildren);
|
||||
sb.append(", isMap=").append(isMap);
|
||||
sb.append(", isDeprecated=").append(isDeprecated);
|
||||
sb.append(", hasReadOnly=").append(hasReadOnly);
|
||||
sb.append(", hasOnlyReadOnly=").append(hasOnlyReadOnly);
|
||||
sb.append(", externalDocumentation=").append(externalDocumentation);
|
||||
sb.append(", vendorExtensions=").append(vendorExtensions);
|
||||
|
||||
@@ -5938,6 +5938,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
Map<String, Schema> allProperties, List<String> allRequired) {
|
||||
|
||||
m.hasRequired = false;
|
||||
m.hasReadOnly = false;
|
||||
if (properties != null && !properties.isEmpty()) {
|
||||
m.hasVars = true;
|
||||
|
||||
@@ -6063,6 +6064,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// if readonly, add to readOnlyVars (list of properties)
|
||||
if (Boolean.TRUE.equals(cp.isReadOnly)) {
|
||||
cm.readOnlyVars.add(cp);
|
||||
cm.hasReadOnly = true;
|
||||
} else { // else add to readWriteVars (list of properties)
|
||||
// duplicated properties will be removed by removeAllDuplicatedProperty later
|
||||
cm.readWriteVars.add(cp);
|
||||
|
||||
@@ -965,6 +965,7 @@ public class ElixirClientCodegen extends DefaultCodegen {
|
||||
this.isEnum = cm.isEnum;
|
||||
this.hasRequired = cm.hasRequired;
|
||||
this.hasOptional = cm.hasOptional;
|
||||
this.hasReadOnly = cm.hasReadOnly;
|
||||
this.isArray = cm.isArray;
|
||||
this.hasChildren = cm.hasChildren;
|
||||
this.hasOnlyReadOnly = cm.hasOnlyReadOnly;
|
||||
|
||||
@@ -489,6 +489,7 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
|
||||
this.isEnum = cm.isEnum;
|
||||
this.hasRequired = cm.hasRequired;
|
||||
this.hasOptional = cm.hasOptional;
|
||||
this.hasReadOnly = cm.hasReadOnly;
|
||||
this.isArray = cm.isArray;
|
||||
this.hasChildren = cm.hasChildren;
|
||||
this.hasOnlyReadOnly = cm.hasOnlyReadOnly;
|
||||
|
||||
@@ -1454,6 +1454,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.allVars = cm.allVars;
|
||||
this.requiredVars = cm.requiredVars;
|
||||
this.optionalVars = cm.optionalVars;
|
||||
this.hasReadOnly = cm.hasReadOnly;
|
||||
this.readOnlyVars = cm.readOnlyVars;
|
||||
this.readWriteVars = cm.readWriteVars;
|
||||
this.parentVars = cm.parentVars;
|
||||
|
||||
Reference in New Issue
Block a user