@@ -87,33 +87,32 @@ function renderDeserialize({
8787 ! ( prop . property instanceof ConstrainedDictionaryModel ) ||
8888 prop . property . serializationType === 'normal'
8989 ) ;
90- const corePropsRead = coreProps
91- . map ( ( prop ) => {
92- const propertyAccessor = pascalCase ( prop . propertyName ) ;
93- let toValue = `jo["${ prop . unconstrainedPropertyName } "].ToObject<${ prop . property . type } >(serializer)` ;
94- if (
95- prop . property instanceof ConstrainedReferenceModel &&
96- prop . property . ref instanceof ConstrainedEnumModel
97- ) {
98- toValue = `${ prop . property . name } Extensions.To${ prop . property . name } (jo["${
99- prop . unconstrainedPropertyName
100- } "].ToString())${ prop . required ? '.Value' : '' } `;
101- }
10290
103- if (
104- options ?. enforceRequired !== undefined &&
105- options ?. enforceRequired &&
106- prop . required
107- ) {
108- return `if(jo["${ prop . unconstrainedPropertyName } "] is null){
91+ const corePropsRead = coreProps . map ( ( prop ) => {
92+ const propertyAccessor = pascalCase ( prop . propertyName ) ;
93+ let toValue = `jo["${ prop . unconstrainedPropertyName } "].ToObject<${ prop . property . type } >(serializer)` ;
94+ if (
95+ prop . property instanceof ConstrainedReferenceModel &&
96+ prop . property . ref instanceof ConstrainedEnumModel
97+ ) {
98+ toValue = `${ prop . property . name } Extensions.To${ prop . property . name } (jo["${
99+ prop . unconstrainedPropertyName
100+ } "].ToString())${ prop . required ? '.Value' : '' } `;
101+ }
102+
103+ if (
104+ options ?. enforceRequired !== undefined &&
105+ options ?. enforceRequired &&
106+ prop . required
107+ ) {
108+ return `if(jo["${ prop . unconstrainedPropertyName } "] is null){
109109 throw new JsonSerializationException("Required property '${ prop . unconstrainedPropertyName } ' is missing");
110110}
111-
112111value.${ propertyAccessor } = ${ toValue } ;
113112` ;
114- }
113+ }
115114
116- return `if(jo["${ prop . unconstrainedPropertyName } "] != null) {
115+ return `if(jo["${ prop . unconstrainedPropertyName } "] != null) {
117116 value.${ propertyAccessor } = ${ toValue } ;
118117}` ;
119118 } )
0 commit comments