Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2573,26 +2573,17 @@ public int compare(CodegenProperty one, CodegenProperty another) {
}

// process 'additionalProperties'
if (schema.getAdditionalProperties() == null) {
if (disallowAdditionalPropertiesIfNotPresent) {
m.isAdditionalPropertiesTrue = false;
} else {
m.isAdditionalPropertiesTrue = true;
CodegenProperty cp = fromProperty("", new Schema());
m.setAdditionalProperties(cp);
}
} else if (schema.getAdditionalProperties() instanceof Boolean) {
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
m.isAdditionalPropertiesTrue = true;
CodegenProperty cp = fromProperty("", new Schema());
m.setAdditionalProperties(cp);
} else {
m.isAdditionalPropertiesTrue = false;
}
setAddProps(schema, m);
// additionalProperties == True means that empty object will be used
// per the openapi spec, if additionalProperties is omitted it is defaulted to empty object
// so if we do that, set isAdditionalPropertiesTrue to True
// if an explicit schema is passed in to additionalProperties, set isAdditionalPropertiesTrue to False
if (schema.getAdditionalProperties() == null && !disallowAdditionalPropertiesIfNotPresent) {
m.isAdditionalPropertiesTrue = true;
} else if (schema.getAdditionalProperties() instanceof Boolean && Boolean.TRUE.equals(schema.getAdditionalProperties())) {
m.isAdditionalPropertiesTrue = true;
} else {
m.isAdditionalPropertiesTrue = false;
CodegenProperty cp = fromProperty("", (Schema) schema.getAdditionalProperties());
m.setAdditionalProperties(cp);
}

// post process model properties
Expand Down Expand Up @@ -3037,6 +3028,7 @@ public String getterAndSetterCapitalize(String name) {
* the (String name, Schema p) arguments.
* Any subsequent processing of the CodegenModel return value must be idempotent
* for a given (String name, Schema schema).
* Pass in null for the name to not use the schemaCodegenPropertyCache
*
* @param name name of the property
* @param p OAS property schema
Expand All @@ -3048,11 +3040,16 @@ public CodegenProperty fromProperty(String name, Schema p) {
return null;
}
LOGGER.debug("debugging fromProperty for " + name + " : " + p);
boolean nullName = (name == null);
NamedSchema ns = new NamedSchema(name, p);
CodegenProperty cpc = schemaCodegenPropertyCache.get(ns);
if (cpc != null) {
LOGGER.debug("Cached fromProperty for " + name + " : " + p.getName());
return cpc;
if (!nullName) {
CodegenProperty cpc = schemaCodegenPropertyCache.get(ns);
if (cpc != null) {
LOGGER.debug("Cached fromProperty for " + name + " : " + p.getName());
return cpc;
}
} else {
name = "";
}
// unalias schema
p = unaliasSchema(p, importMapping);
Expand Down Expand Up @@ -3376,7 +3373,9 @@ public CodegenProperty fromProperty(String name, Schema p) {

addVarsRequiredVarsAdditionaProps(p, property);
LOGGER.debug("debugging from property return: " + property);
schemaCodegenPropertyCache.put(ns, property);
if (!nullName) {
schemaCodegenPropertyCache.put(ns, property);
}
return property;
}

Expand Down Expand Up @@ -6162,6 +6161,25 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
return codegenParameter;
}

private void setAddProps(Schema schema, IJsonSchemaValidationProperties property){
Schema usedSchema = new Schema();
if (schema.getAdditionalProperties() == null) {
if (!disallowAdditionalPropertiesIfNotPresent) {
CodegenProperty cp = fromProperty(null, usedSchema);
property.setAdditionalProperties(cp);
}
} else if (schema.getAdditionalProperties() instanceof Boolean) {
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
CodegenProperty cp = fromProperty(null, usedSchema);
property.setAdditionalProperties(cp);
}
} else {
usedSchema = (Schema) schema.getAdditionalProperties();
CodegenProperty cp = fromProperty(null, usedSchema);
property.setAdditionalProperties(cp);
}
}

private void addVarsRequiredVarsAdditionaProps(Schema schema, IJsonSchemaValidationProperties property){
if (!"object".equals(schema.getType())) {
return;
Expand All @@ -6178,20 +6196,7 @@ private void addVarsRequiredVarsAdditionaProps(Schema schema, IJsonSchemaValidat
.filter(p -> Boolean.TRUE.equals(p.required)).collect(Collectors.toList());
property.setRequiredVars(requireCpVars);
}
if (schema.getAdditionalProperties() == null) {
if (!disallowAdditionalPropertiesIfNotPresent) {
CodegenProperty cp = fromProperty("", new Schema());
property.setAdditionalProperties(cp);
}
} else if (schema.getAdditionalProperties() instanceof Boolean) {
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
CodegenProperty cp = fromProperty("", new Schema());
property.setAdditionalProperties(cp);
}
} else {
CodegenProperty cp = fromProperty("", (Schema) schema.getAdditionalProperties());
property.setAdditionalProperties(cp);
}
setAddProps(schema, property);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ export interface EnumArrays {
arrayEnum?: Array<EnumArraysArrayEnumEnum>;
}

/**
* @export
* @enum {string}
*/
export enum EnumArraysJustSymbolEnum {
GreaterThanOrEqualTo = '>=',
Dollar = '$'
}/**
* @export
* @enum {string}
*/
export enum EnumArraysArrayEnumEnum {
Fish = 'fish',
Crab = 'crab'
}

export function EnumArraysFromJSON(json: any): EnumArrays {
return EnumArraysFromJSONTyped(json, false);
}
Expand Down Expand Up @@ -62,21 +78,4 @@ export function EnumArraysToJSON(value?: EnumArrays | null): any {
};
}

/**
* @export
* @enum {string}
*/
export enum EnumArraysJustSymbolEnum {
GreaterThanOrEqualTo = '>=',
Dollar = '$'
}
/**
* @export
* @enum {string}
*/
export enum EnumArraysArrayEnumEnum {
Fish = 'fish',
Crab = 'crab'
}


Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,38 @@ export interface EnumTest {
outerEnumIntegerDefaultValue?: OuterEnumIntegerDefaultValue;
}

/**
* @export
* @enum {string}
*/
export enum EnumTestEnumStringEnum {
Upper = 'UPPER',
Lower = 'lower',
Empty = ''
}/**
* @export
* @enum {string}
*/
export enum EnumTestEnumStringRequiredEnum {
Upper = 'UPPER',
Lower = 'lower',
Empty = ''
}/**
* @export
* @enum {string}
*/
export enum EnumTestEnumIntegerEnum {
NUMBER_1 = 1,
NUMBER_MINUS_1 = -1
}/**
* @export
* @enum {string}
*/
export enum EnumTestEnumNumberEnum {
NUMBER_1_DOT_1 = 1.1,
NUMBER_MINUS_1_DOT_2 = -1.2
}

export function EnumTestFromJSON(json: any): EnumTest {
return EnumTestFromJSONTyped(json, false);
}
Expand Down Expand Up @@ -129,39 +161,4 @@ export function EnumTestToJSON(value?: EnumTest | null): any {
};
}

/**
* @export
* @enum {string}
*/
export enum EnumTestEnumStringEnum {
Upper = 'UPPER',
Lower = 'lower',
Empty = ''
}
/**
* @export
* @enum {string}
*/
export enum EnumTestEnumStringRequiredEnum {
Upper = 'UPPER',
Lower = 'lower',
Empty = ''
}
/**
* @export
* @enum {string}
*/
export enum EnumTestEnumIntegerEnum {
NUMBER_1 = 1,
NUMBER_MINUS_1 = -1
}
/**
* @export
* @enum {string}
*/
export enum EnumTestEnumNumberEnum {
NUMBER_1_DOT_1 = 1.1,
NUMBER_MINUS_1_DOT_2 = -1.2
}


Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ export interface InlineObject2 {
enumFormString?: InlineObject2EnumFormStringEnum;
}

/**
* @export
* @enum {string}
*/
export enum InlineObject2EnumFormStringArrayEnum {
GreaterThan = '>',
Dollar = '$'
}/**
* @export
* @enum {string}
*/
export enum InlineObject2EnumFormStringEnum {
Abc = '_abc',
Efg = '-efg',
Xyz = '(xyz)'
}

export function InlineObject2FromJSON(json: any): InlineObject2 {
return InlineObject2FromJSONTyped(json, false);
}
Expand Down Expand Up @@ -62,22 +79,4 @@ export function InlineObject2ToJSON(value?: InlineObject2 | null): any {
};
}

/**
* @export
* @enum {string}
*/
export enum InlineObject2EnumFormStringArrayEnum {
GreaterThan = '>',
Dollar = '$'
}
/**
* @export
* @enum {string}
*/
export enum InlineObject2EnumFormStringEnum {
Abc = '_abc',
Efg = '-efg',
Xyz = '(xyz)'
}


Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ export interface MapTest {
indirectMap?: { [key: string]: boolean; };
}

/**
* @export
* @enum {string}
*/
export enum MapTestMapOfEnumStringEnum {
Upper = 'UPPER',
Lower = 'lower'
}

export function MapTestFromJSON(json: any): MapTest {
return MapTestFromJSONTyped(json, false);
}
Expand Down Expand Up @@ -78,13 +87,4 @@ export function MapTestToJSON(value?: MapTest | null): any {
};
}

/**
* @export
* @enum {string}
*/
export enum MapTestMapOfEnumStringEnum {
Upper = 'UPPER',
Lower = 'lower'
}


Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ export interface Order {
complete?: boolean;
}

/**
* @export
* @enum {string}
*/
export enum OrderStatusEnum {
Placed = 'placed',
Approved = 'approved',
Delivered = 'delivered'
}

export function OrderFromJSON(json: any): Order {
return OrderFromJSONTyped(json, false);
}
Expand Down Expand Up @@ -94,14 +104,4 @@ export function OrderToJSON(value?: Order | null): any {
};
}

/**
* @export
* @enum {string}
*/
export enum OrderStatusEnum {
Placed = 'placed',
Approved = 'approved',
Delivered = 'delivered'
}


Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ export interface Pet {
status?: PetStatusEnum;
}

/**
* @export
* @enum {string}
*/
export enum PetStatusEnum {
Available = 'available',
Pending = 'pending',
Sold = 'sold'
}

export function PetFromJSON(json: any): Pet {
return PetFromJSONTyped(json, false);
}
Expand Down Expand Up @@ -105,14 +115,4 @@ export function PetToJSON(value?: Pet | null): any {
};
}

/**
* @export
* @enum {string}
*/
export enum PetStatusEnum {
Available = 'available',
Pending = 'pending',
Sold = 'sold'
}


Loading