From 96e94dbbb5a8e2e6f64b2ee4e19abfd980c154ab Mon Sep 17 00:00:00 2001 From: jonaslagoni Date: Tue, 28 Jan 2025 09:28:16 +0100 Subject: [PATCH] fix lint --- .../presets/NewtonsoftSerializerPreset.ts | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/generators/csharp/presets/NewtonsoftSerializerPreset.ts b/src/generators/csharp/presets/NewtonsoftSerializerPreset.ts index bad6cea505..e4bef052b8 100644 --- a/src/generators/csharp/presets/NewtonsoftSerializerPreset.ts +++ b/src/generators/csharp/presets/NewtonsoftSerializerPreset.ts @@ -88,31 +88,32 @@ function renderDeserialize({ prop.property.serializationType === 'normal' ); - const corePropsRead = coreProps.map((prop) => { - const propertyAccessor = pascalCase(prop.propertyName); - let toValue = `jo["${prop.unconstrainedPropertyName}"].ToObject<${prop.property.type}>(serializer)`; - if ( - prop.property instanceof ConstrainedReferenceModel && - prop.property.ref instanceof ConstrainedEnumModel - ) { - toValue = `${prop.property.name}Extensions.To${prop.property.name}(jo["${ - prop.unconstrainedPropertyName - }"].ToString())${prop.required ? '.Value' : ''}`; - } + const corePropsRead = coreProps + .map((prop) => { + const propertyAccessor = pascalCase(prop.propertyName); + let toValue = `jo["${prop.unconstrainedPropertyName}"].ToObject<${prop.property.type}>(serializer)`; + if ( + prop.property instanceof ConstrainedReferenceModel && + prop.property.ref instanceof ConstrainedEnumModel + ) { + toValue = `${prop.property.name}Extensions.To${prop.property.name}(jo["${ + prop.unconstrainedPropertyName + }"].ToString())${prop.required ? '.Value' : ''}`; + } - if ( - options?.enforceRequired !== undefined && - options?.enforceRequired && - prop.required - ) { - return `if(jo["${prop.unconstrainedPropertyName}"] is null){ + if ( + options?.enforceRequired !== undefined && + options?.enforceRequired && + prop.required + ) { + return `if(jo["${prop.unconstrainedPropertyName}"] is null){ throw new JsonSerializationException("Required property '${prop.unconstrainedPropertyName}' is missing"); } value.${propertyAccessor} = ${toValue}; `; - } + } - return `if(jo["${prop.unconstrainedPropertyName}"] != null) { + return `if(jo["${prop.unconstrainedPropertyName}"] != null) { value.${propertyAccessor} = ${toValue}; }`; })