@arrirpc/codegen-swift 0.78.0 → 0.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.cjs +30 -30
- package/dist/index.mjs +30 -30
- package/package.json +2 -2
package/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Arri Swift Codegen
|
2
2
|
|
3
|
+
_Please note: The generated code does not yet support `swift-tools-version 6` or greater. Please track the status of this issue [here](https://github.com/modiimedia/arri/issues/167). In the meantime please set your `swift-tools-version` to `5.10` or lower._
|
4
|
+
|
3
5
|
## Setup
|
4
6
|
|
5
7
|
### 1) Add the Swift client generator to your arri config
|
package/dist/index.cjs
CHANGED
@@ -8,7 +8,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
8
8
|
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
9
9
|
|
10
10
|
function isNullableType(schema, context) {
|
11
|
-
return schema.
|
11
|
+
return schema.isNullable === true || context.isOptional === true;
|
12
12
|
}
|
13
13
|
function validTypeName(input) {
|
14
14
|
const formatted = codegenUtils.removeDisallowedChars(
|
@@ -128,7 +128,7 @@ ${leading}@available(*, deprecated)
|
|
128
128
|
function swiftAnyFromSchema(schema, context) {
|
129
129
|
const isNullable = isNullableType(schema, context);
|
130
130
|
let defaultValue = "JSON()";
|
131
|
-
if (schema.
|
131
|
+
if (schema.isNullable) {
|
132
132
|
defaultValue = 'JSON(parseJSON: "null")';
|
133
133
|
} else if (context.isOptional) {
|
134
134
|
defaultValue = "";
|
@@ -192,7 +192,7 @@ function swiftArrayFromSchema(schema, context) {
|
|
192
192
|
${mainContent}
|
193
193
|
}`;
|
194
194
|
}
|
195
|
-
if (schema.
|
195
|
+
if (schema.isNullable) {
|
196
196
|
return ` if ${input}.array != nil {
|
197
197
|
${mainContent}
|
198
198
|
}`;
|
@@ -208,7 +208,7 @@ ${mainContent}
|
|
208
208
|
${subType.toJsonTemplate(`__element`, target)}
|
209
209
|
}
|
210
210
|
${target} += "]"`;
|
211
|
-
if (schema.
|
211
|
+
if (schema.isNullable) {
|
212
212
|
return ` if ${input} != nil {
|
213
213
|
${mainContent}
|
214
214
|
} else {
|
@@ -269,7 +269,7 @@ function swiftObjectFromSchema(schema, context) {
|
|
269
269
|
${target} = ${prefixedTypeName}(json: ${input})
|
270
270
|
}`;
|
271
271
|
}
|
272
|
-
if (schema.
|
272
|
+
if (schema.isNullable) {
|
273
273
|
return ` if ${input}.dictionary != nil {
|
274
274
|
${target} = ${prefixedTypeName}(json: ${input})
|
275
275
|
}`;
|
@@ -280,7 +280,7 @@ function swiftObjectFromSchema(schema, context) {
|
|
280
280
|
if (context.isOptional) {
|
281
281
|
return ` ${target} += ${input}!.toJSONString()`;
|
282
282
|
}
|
283
|
-
if (schema.
|
283
|
+
if (schema.isNullable) {
|
284
284
|
return ` if ${input} != nil {
|
285
285
|
${target} += ${input}!.toJSONString()
|
286
286
|
} else {
|
@@ -567,7 +567,7 @@ function swiftTaggedUnionFromSchema(schema, context) {
|
|
567
567
|
${target} = ${prefixedTypeName}(json: ${input})
|
568
568
|
}`;
|
569
569
|
}
|
570
|
-
if (schema.
|
570
|
+
if (schema.isNullable) {
|
571
571
|
return ` if ${input}.dictionary != nil {
|
572
572
|
${target} = ${prefixedTypeName}(json: ${input})
|
573
573
|
}`;
|
@@ -578,7 +578,7 @@ function swiftTaggedUnionFromSchema(schema, context) {
|
|
578
578
|
if (context.isOptional) {
|
579
579
|
return ` ${target} += ${input}!.toJSONString()`;
|
580
580
|
}
|
581
|
-
if (schema.
|
581
|
+
if (schema.isNullable) {
|
582
582
|
return ` if ${input} != nil {
|
583
583
|
${target} += ${input}!.toJSONString()
|
584
584
|
} else {
|
@@ -734,7 +734,7 @@ function swiftEnumFromSchema(schema, context) {
|
|
734
734
|
${target} = ${prefixedTypeName}(serialValue: ${input}.string ?? "")
|
735
735
|
}`;
|
736
736
|
}
|
737
|
-
if (schema.
|
737
|
+
if (schema.isNullable) {
|
738
738
|
return ` if ${input}.string != nil {
|
739
739
|
${target} = ${prefixedTypeName}(serialValue: ${input}.string ?? "")
|
740
740
|
}`;
|
@@ -745,7 +745,7 @@ function swiftEnumFromSchema(schema, context) {
|
|
745
745
|
if (context.isOptional) {
|
746
746
|
return ` ${target} += "\\"\\(${input}!.serialValue())\\""`;
|
747
747
|
}
|
748
|
-
if (schema.
|
748
|
+
if (schema.isNullable) {
|
749
749
|
return ` if ${input} != nil {
|
750
750
|
${target} += "\\"\\(${input}!.serialValue())\\""
|
751
751
|
} else {
|
@@ -760,7 +760,7 @@ function swiftEnumFromSchema(schema, context) {
|
|
760
760
|
${target}.append(URLQueryItem(name: "${key}", value: ${input}!.serialValue()))
|
761
761
|
}`;
|
762
762
|
}
|
763
|
-
if (schema.
|
763
|
+
if (schema.isNullable) {
|
764
764
|
return ` if ${input} != nil {
|
765
765
|
${target}.append(URLQueryItem(name: "${key}", value: ${input}!.serialValue()))
|
766
766
|
} else {
|
@@ -819,7 +819,7 @@ function swiftStringFromSchema(schema, context) {
|
|
819
819
|
${target} = ${input}.string
|
820
820
|
}`;
|
821
821
|
}
|
822
|
-
if (schema.
|
822
|
+
if (schema.isNullable) {
|
823
823
|
return ` if ${input}.string != nil {
|
824
824
|
${target} = ${input}.string
|
825
825
|
}`;
|
@@ -830,7 +830,7 @@ function swiftStringFromSchema(schema, context) {
|
|
830
830
|
if (context.isOptional) {
|
831
831
|
return ` ${target} += serializeString(input: ${input}!)`;
|
832
832
|
}
|
833
|
-
if (schema.
|
833
|
+
if (schema.isNullable) {
|
834
834
|
return ` if ${input} != nil {
|
835
835
|
${target} += serializeString(input: ${input}!)
|
836
836
|
} else {
|
@@ -845,7 +845,7 @@ function swiftStringFromSchema(schema, context) {
|
|
845
845
|
${target}.append(URLQueryItem(name: "${key}", value: ${input}!))
|
846
846
|
}`;
|
847
847
|
}
|
848
|
-
if (schema.
|
848
|
+
if (schema.isNullable) {
|
849
849
|
return ` if ${input} != nil {
|
850
850
|
${target}.append(URLQueryItem(name: "${key}", value: ${input}!))
|
851
851
|
} else {
|
@@ -873,7 +873,7 @@ function swiftBooleanFromSchema(schema, context) {
|
|
873
873
|
${target} = ${input}.bool
|
874
874
|
}`;
|
875
875
|
}
|
876
|
-
if (schema.
|
876
|
+
if (schema.isNullable) {
|
877
877
|
return ` if ${input}.bool != nil {
|
878
878
|
${target} = ${input}.bool
|
879
879
|
}`;
|
@@ -884,7 +884,7 @@ function swiftBooleanFromSchema(schema, context) {
|
|
884
884
|
if (context.isOptional) {
|
885
885
|
return `${target} += "\\(${input}!)"`;
|
886
886
|
}
|
887
|
-
if (schema.
|
887
|
+
if (schema.isNullable) {
|
888
888
|
return ` if ${input} != nil {
|
889
889
|
${target} += "\\(${input}!)"
|
890
890
|
} else {
|
@@ -899,7 +899,7 @@ function swiftBooleanFromSchema(schema, context) {
|
|
899
899
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
900
900
|
}`;
|
901
901
|
}
|
902
|
-
if (schema.
|
902
|
+
if (schema.isNullable) {
|
903
903
|
return ` if ${input} != nil {
|
904
904
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
905
905
|
} else {
|
@@ -927,7 +927,7 @@ function swiftTimestampFromSchema(schema, context) {
|
|
927
927
|
${target} = parseDate(${input}.string ?? "") ?? Date()
|
928
928
|
}`;
|
929
929
|
}
|
930
|
-
if (schema.
|
930
|
+
if (schema.isNullable) {
|
931
931
|
return ` if ${input}.string != nil {
|
932
932
|
${target} = parseDate(${input}.string ?? "") ?? Date()
|
933
933
|
}`;
|
@@ -938,7 +938,7 @@ function swiftTimestampFromSchema(schema, context) {
|
|
938
938
|
if (context.isOptional) {
|
939
939
|
return ` ${target} += serializeDate(${input}!)`;
|
940
940
|
}
|
941
|
-
if (schema.
|
941
|
+
if (schema.isNullable) {
|
942
942
|
return ` if ${input} != nil {
|
943
943
|
${target} += serializeDate(${input}!)
|
944
944
|
} else {
|
@@ -953,7 +953,7 @@ function swiftTimestampFromSchema(schema, context) {
|
|
953
953
|
${target}.append(URLQueryItem(name: "${key}", value: serializeDate(${input}!, withQuotes: false)))
|
954
954
|
}`;
|
955
955
|
}
|
956
|
-
if (schema.
|
956
|
+
if (schema.isNullable) {
|
957
957
|
return ` if ${input} != nil {
|
958
958
|
${target}.append(URLQueryItem(name: "${key}", value: serializeDate(${input}!, withQuotes: false)))
|
959
959
|
} else {
|
@@ -979,7 +979,7 @@ function swiftNumberFromSchema(schema, context, typeName, jsonAccessor, defaultV
|
|
979
979
|
${target} = ${input}.${jsonAccessor}
|
980
980
|
}`;
|
981
981
|
}
|
982
|
-
if (schema.
|
982
|
+
if (schema.isNullable) {
|
983
983
|
return ` if ${input}.${jsonAccessor} != nil {
|
984
984
|
${target} = ${input}.${jsonAccessor}
|
985
985
|
}`;
|
@@ -990,7 +990,7 @@ function swiftNumberFromSchema(schema, context, typeName, jsonAccessor, defaultV
|
|
990
990
|
if (context.isOptional) {
|
991
991
|
return ` ${target} += "\\(${input}!)"`;
|
992
992
|
}
|
993
|
-
if (schema.
|
993
|
+
if (schema.isNullable) {
|
994
994
|
return ` if ${input} != nil {
|
995
995
|
${target} += "\\(${input}!)"
|
996
996
|
} else {
|
@@ -1005,7 +1005,7 @@ function swiftNumberFromSchema(schema, context, typeName, jsonAccessor, defaultV
|
|
1005
1005
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
1006
1006
|
}`;
|
1007
1007
|
}
|
1008
|
-
if (schema.
|
1008
|
+
if (schema.isNullable) {
|
1009
1009
|
return ` if ${input} != nil {
|
1010
1010
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
1011
1011
|
} else {
|
@@ -1031,7 +1031,7 @@ function swiftLargeIntFromSchema(schema, context, typeName) {
|
|
1031
1031
|
${target} = ${typeName}(${input}.string ?? "0")
|
1032
1032
|
}`;
|
1033
1033
|
}
|
1034
|
-
if (schema.
|
1034
|
+
if (schema.isNullable) {
|
1035
1035
|
return ` if ${input}.string != nil {
|
1036
1036
|
${target} = ${typeName}(${input}.string ?? "0")
|
1037
1037
|
}`;
|
@@ -1042,7 +1042,7 @@ function swiftLargeIntFromSchema(schema, context, typeName) {
|
|
1042
1042
|
if (context.isOptional) {
|
1043
1043
|
return ` ${target} += "\\"\\(${input}!)\\""`;
|
1044
1044
|
}
|
1045
|
-
if (schema.
|
1045
|
+
if (schema.isNullable) {
|
1046
1046
|
return ` if ${input} != nil {
|
1047
1047
|
${target} += "\\"\\(${input}!)\\""
|
1048
1048
|
} else {
|
@@ -1057,7 +1057,7 @@ function swiftLargeIntFromSchema(schema, context, typeName) {
|
|
1057
1057
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
1058
1058
|
}`;
|
1059
1059
|
}
|
1060
|
-
if (schema.
|
1060
|
+
if (schema.isNullable) {
|
1061
1061
|
return ` if ${input} != nil {
|
1062
1062
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
1063
1063
|
} else {
|
@@ -1274,7 +1274,7 @@ function swiftDictionaryFromSchema(schema, context) {
|
|
1274
1274
|
${mainContent}
|
1275
1275
|
}`;
|
1276
1276
|
}
|
1277
|
-
if (schema.
|
1277
|
+
if (schema.isNullable) {
|
1278
1278
|
return ` if ${input}.dictionary != nil {
|
1279
1279
|
${mainContent}
|
1280
1280
|
}`;
|
@@ -1291,7 +1291,7 @@ ${mainContent}
|
|
1291
1291
|
${subType.toJsonTemplate("__value", target)}
|
1292
1292
|
}
|
1293
1293
|
${target} += "}"`;
|
1294
|
-
if (schema.
|
1294
|
+
if (schema.isNullable) {
|
1295
1295
|
return `if ${input} != nil {
|
1296
1296
|
${mainContent}
|
1297
1297
|
} else {
|
@@ -1352,7 +1352,7 @@ function swiftRefFromSchema(schema, context) {
|
|
1352
1352
|
${target} = ${prefixedTypeName}(json: ${input})
|
1353
1353
|
}`;
|
1354
1354
|
}
|
1355
|
-
if (schema.
|
1355
|
+
if (schema.isNullable) {
|
1356
1356
|
return `if ${input}.dictionary != nil {
|
1357
1357
|
${target} = ${prefixedTypeName}(json: ${input})
|
1358
1358
|
}`;
|
@@ -1361,7 +1361,7 @@ function swiftRefFromSchema(schema, context) {
|
|
1361
1361
|
},
|
1362
1362
|
toJsonTemplate(input, target) {
|
1363
1363
|
const mainContent = `${target} += ${input}${isNullable ? "!" : ""}.toJSONString()`;
|
1364
|
-
if (schema.
|
1364
|
+
if (schema.isNullable) {
|
1365
1365
|
return `if ${input} != nil {
|
1366
1366
|
${mainContent}
|
1367
1367
|
} else {
|
package/dist/index.mjs
CHANGED
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
2
2
|
import { removeDisallowedChars, camelCase, stringStartsWithNumber, pascalCase, isSchemaFormRef, isServiceDefinition, isRpcDefinition, defineGeneratorPlugin, unflattenProcedures, isSchemaFormType, isSchemaFormEnum, isSchemaFormProperties, isSchemaFormElements, isSchemaFormValues, isSchemaFormDiscriminator } from '@arrirpc/codegen-utils';
|
3
3
|
|
4
4
|
function isNullableType(schema, context) {
|
5
|
-
return schema.
|
5
|
+
return schema.isNullable === true || context.isOptional === true;
|
6
6
|
}
|
7
7
|
function validTypeName(input) {
|
8
8
|
const formatted = removeDisallowedChars(
|
@@ -122,7 +122,7 @@ ${leading}@available(*, deprecated)
|
|
122
122
|
function swiftAnyFromSchema(schema, context) {
|
123
123
|
const isNullable = isNullableType(schema, context);
|
124
124
|
let defaultValue = "JSON()";
|
125
|
-
if (schema.
|
125
|
+
if (schema.isNullable) {
|
126
126
|
defaultValue = 'JSON(parseJSON: "null")';
|
127
127
|
} else if (context.isOptional) {
|
128
128
|
defaultValue = "";
|
@@ -186,7 +186,7 @@ function swiftArrayFromSchema(schema, context) {
|
|
186
186
|
${mainContent}
|
187
187
|
}`;
|
188
188
|
}
|
189
|
-
if (schema.
|
189
|
+
if (schema.isNullable) {
|
190
190
|
return ` if ${input}.array != nil {
|
191
191
|
${mainContent}
|
192
192
|
}`;
|
@@ -202,7 +202,7 @@ ${mainContent}
|
|
202
202
|
${subType.toJsonTemplate(`__element`, target)}
|
203
203
|
}
|
204
204
|
${target} += "]"`;
|
205
|
-
if (schema.
|
205
|
+
if (schema.isNullable) {
|
206
206
|
return ` if ${input} != nil {
|
207
207
|
${mainContent}
|
208
208
|
} else {
|
@@ -263,7 +263,7 @@ function swiftObjectFromSchema(schema, context) {
|
|
263
263
|
${target} = ${prefixedTypeName}(json: ${input})
|
264
264
|
}`;
|
265
265
|
}
|
266
|
-
if (schema.
|
266
|
+
if (schema.isNullable) {
|
267
267
|
return ` if ${input}.dictionary != nil {
|
268
268
|
${target} = ${prefixedTypeName}(json: ${input})
|
269
269
|
}`;
|
@@ -274,7 +274,7 @@ function swiftObjectFromSchema(schema, context) {
|
|
274
274
|
if (context.isOptional) {
|
275
275
|
return ` ${target} += ${input}!.toJSONString()`;
|
276
276
|
}
|
277
|
-
if (schema.
|
277
|
+
if (schema.isNullable) {
|
278
278
|
return ` if ${input} != nil {
|
279
279
|
${target} += ${input}!.toJSONString()
|
280
280
|
} else {
|
@@ -561,7 +561,7 @@ function swiftTaggedUnionFromSchema(schema, context) {
|
|
561
561
|
${target} = ${prefixedTypeName}(json: ${input})
|
562
562
|
}`;
|
563
563
|
}
|
564
|
-
if (schema.
|
564
|
+
if (schema.isNullable) {
|
565
565
|
return ` if ${input}.dictionary != nil {
|
566
566
|
${target} = ${prefixedTypeName}(json: ${input})
|
567
567
|
}`;
|
@@ -572,7 +572,7 @@ function swiftTaggedUnionFromSchema(schema, context) {
|
|
572
572
|
if (context.isOptional) {
|
573
573
|
return ` ${target} += ${input}!.toJSONString()`;
|
574
574
|
}
|
575
|
-
if (schema.
|
575
|
+
if (schema.isNullable) {
|
576
576
|
return ` if ${input} != nil {
|
577
577
|
${target} += ${input}!.toJSONString()
|
578
578
|
} else {
|
@@ -728,7 +728,7 @@ function swiftEnumFromSchema(schema, context) {
|
|
728
728
|
${target} = ${prefixedTypeName}(serialValue: ${input}.string ?? "")
|
729
729
|
}`;
|
730
730
|
}
|
731
|
-
if (schema.
|
731
|
+
if (schema.isNullable) {
|
732
732
|
return ` if ${input}.string != nil {
|
733
733
|
${target} = ${prefixedTypeName}(serialValue: ${input}.string ?? "")
|
734
734
|
}`;
|
@@ -739,7 +739,7 @@ function swiftEnumFromSchema(schema, context) {
|
|
739
739
|
if (context.isOptional) {
|
740
740
|
return ` ${target} += "\\"\\(${input}!.serialValue())\\""`;
|
741
741
|
}
|
742
|
-
if (schema.
|
742
|
+
if (schema.isNullable) {
|
743
743
|
return ` if ${input} != nil {
|
744
744
|
${target} += "\\"\\(${input}!.serialValue())\\""
|
745
745
|
} else {
|
@@ -754,7 +754,7 @@ function swiftEnumFromSchema(schema, context) {
|
|
754
754
|
${target}.append(URLQueryItem(name: "${key}", value: ${input}!.serialValue()))
|
755
755
|
}`;
|
756
756
|
}
|
757
|
-
if (schema.
|
757
|
+
if (schema.isNullable) {
|
758
758
|
return ` if ${input} != nil {
|
759
759
|
${target}.append(URLQueryItem(name: "${key}", value: ${input}!.serialValue()))
|
760
760
|
} else {
|
@@ -813,7 +813,7 @@ function swiftStringFromSchema(schema, context) {
|
|
813
813
|
${target} = ${input}.string
|
814
814
|
}`;
|
815
815
|
}
|
816
|
-
if (schema.
|
816
|
+
if (schema.isNullable) {
|
817
817
|
return ` if ${input}.string != nil {
|
818
818
|
${target} = ${input}.string
|
819
819
|
}`;
|
@@ -824,7 +824,7 @@ function swiftStringFromSchema(schema, context) {
|
|
824
824
|
if (context.isOptional) {
|
825
825
|
return ` ${target} += serializeString(input: ${input}!)`;
|
826
826
|
}
|
827
|
-
if (schema.
|
827
|
+
if (schema.isNullable) {
|
828
828
|
return ` if ${input} != nil {
|
829
829
|
${target} += serializeString(input: ${input}!)
|
830
830
|
} else {
|
@@ -839,7 +839,7 @@ function swiftStringFromSchema(schema, context) {
|
|
839
839
|
${target}.append(URLQueryItem(name: "${key}", value: ${input}!))
|
840
840
|
}`;
|
841
841
|
}
|
842
|
-
if (schema.
|
842
|
+
if (schema.isNullable) {
|
843
843
|
return ` if ${input} != nil {
|
844
844
|
${target}.append(URLQueryItem(name: "${key}", value: ${input}!))
|
845
845
|
} else {
|
@@ -867,7 +867,7 @@ function swiftBooleanFromSchema(schema, context) {
|
|
867
867
|
${target} = ${input}.bool
|
868
868
|
}`;
|
869
869
|
}
|
870
|
-
if (schema.
|
870
|
+
if (schema.isNullable) {
|
871
871
|
return ` if ${input}.bool != nil {
|
872
872
|
${target} = ${input}.bool
|
873
873
|
}`;
|
@@ -878,7 +878,7 @@ function swiftBooleanFromSchema(schema, context) {
|
|
878
878
|
if (context.isOptional) {
|
879
879
|
return `${target} += "\\(${input}!)"`;
|
880
880
|
}
|
881
|
-
if (schema.
|
881
|
+
if (schema.isNullable) {
|
882
882
|
return ` if ${input} != nil {
|
883
883
|
${target} += "\\(${input}!)"
|
884
884
|
} else {
|
@@ -893,7 +893,7 @@ function swiftBooleanFromSchema(schema, context) {
|
|
893
893
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
894
894
|
}`;
|
895
895
|
}
|
896
|
-
if (schema.
|
896
|
+
if (schema.isNullable) {
|
897
897
|
return ` if ${input} != nil {
|
898
898
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
899
899
|
} else {
|
@@ -921,7 +921,7 @@ function swiftTimestampFromSchema(schema, context) {
|
|
921
921
|
${target} = parseDate(${input}.string ?? "") ?? Date()
|
922
922
|
}`;
|
923
923
|
}
|
924
|
-
if (schema.
|
924
|
+
if (schema.isNullable) {
|
925
925
|
return ` if ${input}.string != nil {
|
926
926
|
${target} = parseDate(${input}.string ?? "") ?? Date()
|
927
927
|
}`;
|
@@ -932,7 +932,7 @@ function swiftTimestampFromSchema(schema, context) {
|
|
932
932
|
if (context.isOptional) {
|
933
933
|
return ` ${target} += serializeDate(${input}!)`;
|
934
934
|
}
|
935
|
-
if (schema.
|
935
|
+
if (schema.isNullable) {
|
936
936
|
return ` if ${input} != nil {
|
937
937
|
${target} += serializeDate(${input}!)
|
938
938
|
} else {
|
@@ -947,7 +947,7 @@ function swiftTimestampFromSchema(schema, context) {
|
|
947
947
|
${target}.append(URLQueryItem(name: "${key}", value: serializeDate(${input}!, withQuotes: false)))
|
948
948
|
}`;
|
949
949
|
}
|
950
|
-
if (schema.
|
950
|
+
if (schema.isNullable) {
|
951
951
|
return ` if ${input} != nil {
|
952
952
|
${target}.append(URLQueryItem(name: "${key}", value: serializeDate(${input}!, withQuotes: false)))
|
953
953
|
} else {
|
@@ -973,7 +973,7 @@ function swiftNumberFromSchema(schema, context, typeName, jsonAccessor, defaultV
|
|
973
973
|
${target} = ${input}.${jsonAccessor}
|
974
974
|
}`;
|
975
975
|
}
|
976
|
-
if (schema.
|
976
|
+
if (schema.isNullable) {
|
977
977
|
return ` if ${input}.${jsonAccessor} != nil {
|
978
978
|
${target} = ${input}.${jsonAccessor}
|
979
979
|
}`;
|
@@ -984,7 +984,7 @@ function swiftNumberFromSchema(schema, context, typeName, jsonAccessor, defaultV
|
|
984
984
|
if (context.isOptional) {
|
985
985
|
return ` ${target} += "\\(${input}!)"`;
|
986
986
|
}
|
987
|
-
if (schema.
|
987
|
+
if (schema.isNullable) {
|
988
988
|
return ` if ${input} != nil {
|
989
989
|
${target} += "\\(${input}!)"
|
990
990
|
} else {
|
@@ -999,7 +999,7 @@ function swiftNumberFromSchema(schema, context, typeName, jsonAccessor, defaultV
|
|
999
999
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
1000
1000
|
}`;
|
1001
1001
|
}
|
1002
|
-
if (schema.
|
1002
|
+
if (schema.isNullable) {
|
1003
1003
|
return ` if ${input} != nil {
|
1004
1004
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
1005
1005
|
} else {
|
@@ -1025,7 +1025,7 @@ function swiftLargeIntFromSchema(schema, context, typeName) {
|
|
1025
1025
|
${target} = ${typeName}(${input}.string ?? "0")
|
1026
1026
|
}`;
|
1027
1027
|
}
|
1028
|
-
if (schema.
|
1028
|
+
if (schema.isNullable) {
|
1029
1029
|
return ` if ${input}.string != nil {
|
1030
1030
|
${target} = ${typeName}(${input}.string ?? "0")
|
1031
1031
|
}`;
|
@@ -1036,7 +1036,7 @@ function swiftLargeIntFromSchema(schema, context, typeName) {
|
|
1036
1036
|
if (context.isOptional) {
|
1037
1037
|
return ` ${target} += "\\"\\(${input}!)\\""`;
|
1038
1038
|
}
|
1039
|
-
if (schema.
|
1039
|
+
if (schema.isNullable) {
|
1040
1040
|
return ` if ${input} != nil {
|
1041
1041
|
${target} += "\\"\\(${input}!)\\""
|
1042
1042
|
} else {
|
@@ -1051,7 +1051,7 @@ function swiftLargeIntFromSchema(schema, context, typeName) {
|
|
1051
1051
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
1052
1052
|
}`;
|
1053
1053
|
}
|
1054
|
-
if (schema.
|
1054
|
+
if (schema.isNullable) {
|
1055
1055
|
return ` if ${input} != nil {
|
1056
1056
|
${target}.append(URLQueryItem(name: "${key}", value: "\\(${input}!)"))
|
1057
1057
|
} else {
|
@@ -1268,7 +1268,7 @@ function swiftDictionaryFromSchema(schema, context) {
|
|
1268
1268
|
${mainContent}
|
1269
1269
|
}`;
|
1270
1270
|
}
|
1271
|
-
if (schema.
|
1271
|
+
if (schema.isNullable) {
|
1272
1272
|
return ` if ${input}.dictionary != nil {
|
1273
1273
|
${mainContent}
|
1274
1274
|
}`;
|
@@ -1285,7 +1285,7 @@ ${mainContent}
|
|
1285
1285
|
${subType.toJsonTemplate("__value", target)}
|
1286
1286
|
}
|
1287
1287
|
${target} += "}"`;
|
1288
|
-
if (schema.
|
1288
|
+
if (schema.isNullable) {
|
1289
1289
|
return `if ${input} != nil {
|
1290
1290
|
${mainContent}
|
1291
1291
|
} else {
|
@@ -1346,7 +1346,7 @@ function swiftRefFromSchema(schema, context) {
|
|
1346
1346
|
${target} = ${prefixedTypeName}(json: ${input})
|
1347
1347
|
}`;
|
1348
1348
|
}
|
1349
|
-
if (schema.
|
1349
|
+
if (schema.isNullable) {
|
1350
1350
|
return `if ${input}.dictionary != nil {
|
1351
1351
|
${target} = ${prefixedTypeName}(json: ${input})
|
1352
1352
|
}`;
|
@@ -1355,7 +1355,7 @@ function swiftRefFromSchema(schema, context) {
|
|
1355
1355
|
},
|
1356
1356
|
toJsonTemplate(input, target) {
|
1357
1357
|
const mainContent = `${target} += ${input}${isNullable ? "!" : ""}.toJSONString()`;
|
1358
|
-
if (schema.
|
1358
|
+
if (schema.isNullable) {
|
1359
1359
|
return `if ${input} != nil {
|
1360
1360
|
${mainContent}
|
1361
1361
|
} else {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arrirpc/codegen-swift",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.79.0",
|
4
4
|
"type": "module",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": {
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"dist"
|
23
23
|
],
|
24
24
|
"dependencies": {
|
25
|
-
"@arrirpc/codegen-utils": "0.
|
25
|
+
"@arrirpc/codegen-utils": "0.79.0"
|
26
26
|
},
|
27
27
|
"devDependencies": {}
|
28
28
|
}
|