typia 13.1.19 → 13.2.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/lib/executable/FileSystemIdentity.d.ts +23 -0
- package/lib/executable/FileSystemIdentity.js +30 -0
- package/lib/executable/FileSystemIdentity.js.map +1 -1
- package/lib/executable/FileSystemIdentity.mjs +4 -0
- package/lib/executable/FileSystemIdentity.mjs.map +1 -1
- package/lib/executable/TypiaGenerateWizard.js +15 -9
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard.mjs +11 -7
- package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
- package/lib/internal/_ProtobufReader.d.ts +18 -3
- package/lib/internal/_ProtobufReader.js +39 -11
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +37 -10
- package/lib/internal/_ProtobufReader.mjs.map +1 -1
- package/lib/internal/_jsonStringifyArray.d.ts +1 -0
- package/lib/internal/_jsonStringifyArray.js +48 -0
- package/lib/internal/_jsonStringifyArray.js.map +1 -0
- package/lib/internal/_jsonStringifyArray.mjs +40 -0
- package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
- package/lib/internal/_jsonStringifyElement.d.ts +1 -0
- package/lib/internal/_jsonStringifyElement.js +23 -0
- package/lib/internal/_jsonStringifyElement.js.map +1 -0
- package/lib/internal/_jsonStringifyElement.mjs +23 -0
- package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
- package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
- package/lib/internal/_jsonStringifyProperty.js +31 -0
- package/lib/internal/_jsonStringifyProperty.js.map +1 -0
- package/lib/internal/_jsonStringifyProperty.mjs +31 -0
- package/lib/internal/_jsonStringifyProperty.mjs.map +1 -0
- package/lib/internal/_llmApplicationFinalize.js +1 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.js +24 -1
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +20 -2
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDate.d.ts +3 -6
- package/lib/internal/_randomFormatDate.js +2 -10
- package/lib/internal/_randomFormatDate.js.map +1 -1
- package/lib/internal/_randomFormatDate.mjs +2 -6
- package/lib/internal/_randomFormatDate.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.d.ts +3 -6
- package/lib/internal/_randomFormatDatetime.js +25 -8
- package/lib/internal/_randomFormatDatetime.js.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +17 -7
- package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
- package/lib/internal/_randomFormatDuration.js +23 -15
- package/lib/internal/_randomFormatDuration.js.map +1 -1
- package/lib/internal/_randomFormatDuration.mjs +23 -15
- package/lib/internal/_randomFormatDuration.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv4.js +31 -1
- package/lib/internal/_randomFormatIpv4.js.map +1 -1
- package/lib/internal/_randomFormatIpv4.mjs +23 -2
- package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv6.js +57 -1
- package/lib/internal/_randomFormatIpv6.js.map +1 -1
- package/lib/internal/_randomFormatIpv6.mjs +45 -2
- package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.js +14 -2
- package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.mjs +13 -3
- package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.js +14 -1
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +14 -2
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.js +19 -5
- package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -6
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.js +33 -7
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +37 -5
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.d.ts +41 -10
- package/lib/internal/_randomStringLength.js +49 -13
- package/lib/internal/_randomStringLength.js.map +1 -1
- package/lib/internal/_randomStringLength.mjs +48 -13
- package/lib/internal/_randomStringLength.mjs.map +1 -1
- package/lib/internal/private/__notationRename.js.map +1 -1
- package/lib/internal/private/__notationRename.mjs.map +1 -1
- package/lib/internal/private/__randomComposition.d.ts +23 -0
- package/lib/internal/private/__randomComposition.js +48 -0
- package/lib/internal/private/__randomComposition.js.map +1 -0
- package/lib/internal/private/__randomComposition.mjs +54 -0
- package/lib/internal/private/__randomComposition.mjs.map +1 -0
- package/lib/internal/private/__randomEpoch.d.ts +19 -0
- package/lib/internal/private/__randomEpoch.js +31 -0
- package/lib/internal/private/__randomEpoch.js.map +1 -0
- package/lib/internal/private/__randomEpoch.mjs +28 -0
- package/lib/internal/private/__randomEpoch.mjs.map +1 -0
- package/native/cmd/ttsc-typia/build.go +3 -0
- package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
- package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
- package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
- package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
- package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
- package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
- package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
- package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
- package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
- package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
- package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
- package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
- package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
- package/native/cmd/ttsc-typia/transform.go +23 -0
- package/native/cmd/ttsc-typia/transform_helpers_test.go +77 -2
- package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
- package/native/core/factories/ProtobufFactory.go +6 -1
- package/native/core/factories/internal/metadata/MetadataHelper.go +185 -30
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +25 -0
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +1 -1
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +103 -23
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +3 -7
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +32 -14
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +3 -7
- package/native/core/programmers/compare/CompareEqualProgrammer.go +27 -13
- package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
- package/native/core/programmers/helpers/StringifyJoinder.go +129 -50
- package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -120
- package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
- package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
- package/native/core/programmers/iterate/json_schema_object.go +49 -7
- package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader.go +34 -1
- package/native/core/programmers/iterate/template_runtime_pattern.go +11 -0
- package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +9 -1
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +1 -1
- package/native/core/schemas/metadata/MetadataCollection.go +0 -9
- package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
- package/native/core/schemas/metadata/MetadataObjectType.go +7 -18
- package/native/go.mod +4 -4
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
- package/package.json +3 -7
- package/src/executable/FileSystemIdentity.ts +33 -0
- package/src/executable/TypiaGenerateWizard.ts +18 -12
- package/src/internal/_ProtobufReader.ts +40 -11
- package/src/internal/_jsonStringifyArray.ts +50 -0
- package/src/internal/_jsonStringifyElement.ts +19 -0
- package/src/internal/_jsonStringifyProperty.ts +30 -0
- package/src/internal/_llmApplicationFinalize.ts +6 -1
- package/src/internal/_randomFormatByte.ts +30 -3
- package/src/internal/_randomFormatDate.ts +4 -20
- package/src/internal/_randomFormatDatetime.ts +34 -20
- package/src/internal/_randomFormatDuration.ts +19 -4
- package/src/internal/_randomFormatIpv4.ts +43 -3
- package/src/internal/_randomFormatIpv6.ts +67 -3
- package/src/internal/_randomFormatJsonPointer.ts +23 -3
- package/src/internal/_randomFormatRegex.ts +21 -3
- package/src/internal/_randomFormatRelativeJsonPointer.ts +23 -10
- package/src/internal/_randomFormatTime.ts +45 -12
- package/src/internal/_randomPattern.ts +4 -1
- package/src/internal/_randomStringLength.ts +61 -17
- package/src/internal/private/__notationRename.ts +1 -4
- package/src/internal/private/__randomComposition.ts +50 -0
- package/src/internal/private/__randomEpoch.ts +34 -0
- package/native/adapter/visit.go +0 -173
- package/native/adapter/visit_property_chain_edges_test.go +0 -129
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
- package/native/core/programmers/iterate/check_union_array_like.go +0 -422
- package/native/core/programmers/iterate/prune_object_properties.go +0 -105
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
- package/native/core/programmers/iterate/stringify_native.go +0 -14
- package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
- package/native/core/schemas/metadata/MetadataApplication.go +0 -41
|
@@ -4,12 +4,10 @@
|
|
|
4
4
|
package iterate
|
|
5
5
|
|
|
6
6
|
import (
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
"math/big"
|
|
8
|
+
"testing"
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
nativehelpers "github.com/samchon/typia/packages/typia/native/core/programmers/helpers"
|
|
12
|
-
nativemetadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
|
|
10
|
+
nativemetadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
|
|
13
11
|
)
|
|
14
12
|
|
|
15
13
|
// TestIterateUtilityCoverage exercises schema and stringify helpers.
|
|
@@ -25,278 +23,241 @@ import (
|
|
|
25
23
|
// 4. Build prune and native stringify statements for object metadata.
|
|
26
24
|
// 5. Build full JSON schema station outputs for empty, any, native, and union metadata.
|
|
27
25
|
func TestIterateUtilityCoverage(t *testing.T) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
26
|
+
schema := json_schema_jsDocTags(JsonSchema{}, []nativemetadata.IJsDocTagInfo{
|
|
27
|
+
{Name: "x-enabled", Text: []nativemetadata.IJsDocTagInfo_IText{{Kind: "text", Text: "true"}}},
|
|
28
|
+
{Name: "x-count", Text: []nativemetadata.IJsDocTagInfo_IText{{Kind: "text", Text: "3.5"}}},
|
|
29
|
+
{Name: "x-null", Text: []nativemetadata.IJsDocTagInfo_IText{{Kind: "text", Text: "null"}}},
|
|
30
|
+
{Name: "description", Text: []nativemetadata.IJsDocTagInfo_IText{{Kind: "text", Text: "ignored"}}},
|
|
31
|
+
})
|
|
32
|
+
if schema["x-enabled"] != true || schema["x-count"] != 3.5 {
|
|
33
|
+
t.Fatal("JSDoc tag casting failed")
|
|
34
|
+
}
|
|
35
|
+
if _, ok := json_schema_jsDocTags_value(nativemetadata.IJsDocTagInfo{Name: "x-empty"}); ok {
|
|
36
|
+
t.Fatal("empty JSDoc tag should not produce a value")
|
|
37
|
+
}
|
|
38
|
+
if json_schema_jsDocTags_cast("false") != false ||
|
|
39
|
+
json_schema_jsDocTags_cast("text") != "text" {
|
|
40
|
+
t.Fatal("JSDoc tag scalar casting mismatch")
|
|
41
|
+
}
|
|
42
|
+
fallbackDescription := "fallback"
|
|
43
|
+
if title := json_schema_title(struct {
|
|
44
|
+
description *string
|
|
45
|
+
jsDocTags []nativemetadata.IJsDocTagInfo
|
|
46
|
+
}{
|
|
47
|
+
jsDocTags: []nativemetadata.IJsDocTagInfo{
|
|
48
|
+
{Name: "description", Text: []nativemetadata.IJsDocTagInfo_IText{{Text: "ignored"}}},
|
|
49
|
+
{Name: "title", Text: []nativemetadata.IJsDocTagInfo_IText{{Text: "Line\r\n"}, {Text: "Two"}}},
|
|
50
|
+
},
|
|
51
|
+
}); title == nil || *title != "Line\nTwo" {
|
|
52
|
+
t.Fatal("JSON schema title helper failed")
|
|
53
|
+
}
|
|
54
|
+
if description := json_schema_description(struct {
|
|
55
|
+
description *string
|
|
56
|
+
jsDocTags []nativemetadata.IJsDocTagInfo
|
|
57
|
+
}{
|
|
58
|
+
description: &fallbackDescription,
|
|
59
|
+
jsDocTags: []nativemetadata.IJsDocTagInfo{
|
|
60
|
+
{Name: "description", Text: []nativemetadata.IJsDocTagInfo_IText{{Text: "Doc\r\nText"}}},
|
|
61
|
+
},
|
|
62
|
+
}); description == nil || *description != "Doc\nText" {
|
|
63
|
+
t.Fatal("JSON schema description helper failed")
|
|
64
|
+
}
|
|
65
|
+
if description := json_schema_description(struct {
|
|
66
|
+
description *string
|
|
67
|
+
jsDocTags []nativemetadata.IJsDocTagInfo
|
|
68
|
+
}{description: &fallbackDescription}); description != &fallbackDescription {
|
|
69
|
+
t.Fatal("JSON schema description fallback failed")
|
|
70
|
+
}
|
|
71
|
+
bigValue := big.NewInt(12)
|
|
72
|
+
if json_schema_constant_value(*bigValue) != float64(12) ||
|
|
73
|
+
json_schema_constant_value(bigValue) != float64(12) {
|
|
74
|
+
t.Fatal("JSON schema bigint constant conversion failed")
|
|
75
|
+
}
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
77
|
+
literal := iterateLiteral("fixed")
|
|
78
|
+
stringMeta := iterateAtomic("string")
|
|
79
|
+
constantDescription := "constant"
|
|
80
|
+
constantSchemas := json_schema_constant(nativemetadata.MetadataConstant_create(nativemetadata.MetadataConstant{
|
|
81
|
+
Type: "bigint",
|
|
82
|
+
Values: []*nativemetadata.MetadataConstantValue{
|
|
83
|
+
nativemetadata.MetadataConstantValue_create(nativemetadata.MetadataConstantValue{
|
|
84
|
+
Value: big.NewInt(13),
|
|
85
|
+
Description: &constantDescription,
|
|
86
|
+
JsDocTags: []nativemetadata.IJsDocTagInfo{
|
|
87
|
+
{Name: "title", Text: []nativemetadata.IJsDocTagInfo_IText{{Text: "Big"}}},
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
}))
|
|
92
|
+
if len(constantSchemas) != 1 || constantSchemas[0]["const"] != float64(13) {
|
|
93
|
+
t.Fatal("JSON schema constant export failed")
|
|
94
|
+
}
|
|
95
|
+
dateMeta := nativemetadata.MetadataSchema_initialize()
|
|
96
|
+
dateMeta.Natives = append(dateMeta.Natives, nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "Date"}))
|
|
97
|
+
arrayDate := nativemetadata.MetadataSchema_initialize()
|
|
98
|
+
arrayDate.Arrays = append(arrayDate.Arrays, nativemetadata.MetadataArray_create(nativemetadata.MetadataArray{
|
|
99
|
+
Type: nativemetadata.MetadataArrayType_create(nativemetadata.MetadataArrayType{
|
|
100
|
+
Name: "Date[]",
|
|
101
|
+
Value: dateMeta,
|
|
102
|
+
Nullables: []bool{},
|
|
103
|
+
}),
|
|
104
|
+
}))
|
|
105
|
+
aliasDate := nativemetadata.MetadataSchema_initialize()
|
|
106
|
+
aliasDate.Aliases = append(aliasDate.Aliases, nativemetadata.MetadataAlias_create(nativemetadata.MetadataAlias{
|
|
107
|
+
Type: nativemetadata.MetadataAliasType_create(nativemetadata.MetadataAliasType{Name: "AliasDate", Value: arrayDate}),
|
|
108
|
+
}))
|
|
109
|
+
if !json_schema_escaped_is_date(map[*nativemetadata.MetadataSchema]bool{}, aliasDate) ||
|
|
110
|
+
json_schema_escaped_is_date(map[*nativemetadata.MetadataSchema]bool{aliasDate: true}, aliasDate) {
|
|
111
|
+
t.Fatal("JSON schema escaped date recursion failed")
|
|
112
|
+
}
|
|
113
|
+
if len(json_schema_escaped(struct {
|
|
114
|
+
components *OpenApi_IComponents
|
|
115
|
+
escaped *nativemetadata.MetadataEscaped
|
|
116
|
+
}{
|
|
117
|
+
components: &OpenApi_IComponents{},
|
|
118
|
+
escaped: nativemetadata.MetadataEscaped_create(nativemetadata.MetadataEscaped{
|
|
119
|
+
Original: dateMeta,
|
|
120
|
+
Returns: stringMeta,
|
|
121
|
+
}),
|
|
122
|
+
})) == 0 {
|
|
123
|
+
t.Fatal("JSON schema escaped export returned empty schemas")
|
|
124
|
+
}
|
|
125
|
+
taggedTemplate := nativemetadata.MetadataTemplate_create(nativemetadata.MetadataTemplate{
|
|
126
|
+
Row: []*nativemetadata.MetadataSchema{literal, stringMeta},
|
|
127
|
+
Tags: [][]nativemetadata.IMetadataTypeTag{{
|
|
128
|
+
{Name: "MinLength<1>", Kind: "minLength", Schema: map[string]any{"minLength": 1}},
|
|
129
|
+
}},
|
|
130
|
+
})
|
|
131
|
+
templateMeta := nativemetadata.MetadataSchema_initialize()
|
|
132
|
+
templateMeta.Templates = append(templateMeta.Templates,
|
|
133
|
+
nativemetadata.MetadataTemplate_create(nativemetadata.MetadataTemplate{Row: []*nativemetadata.MetadataSchema{literal, stringMeta}}),
|
|
134
|
+
taggedTemplate,
|
|
135
|
+
)
|
|
136
|
+
if len(json_schema_templates(templateMeta)) != 2 ||
|
|
137
|
+
json_schema_template_isPure(taggedTemplate.Tags) {
|
|
138
|
+
t.Fatal("template schema helper returned unexpected result")
|
|
139
|
+
}
|
|
142
140
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
141
|
+
components := &OpenApi_IComponents{}
|
|
142
|
+
if len(Json_schema_native_export(Json_schema_native_export_props{
|
|
143
|
+
Components: components,
|
|
144
|
+
Native: nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "Blob"}),
|
|
145
|
+
})) == 0 {
|
|
146
|
+
t.Fatal("binary native schema export returned empty result")
|
|
147
|
+
}
|
|
148
|
+
if len(Json_schema_native_export(Json_schema_native_export_props{
|
|
149
|
+
Components: components,
|
|
150
|
+
Native: nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "CustomNative"}),
|
|
151
|
+
})) == 0 || components.Schemas["CustomNative"] == nil {
|
|
152
|
+
t.Fatal("component native schema export failed")
|
|
153
|
+
}
|
|
154
|
+
if !json_schema_station_has_atomic(stringMeta, "string") || lowerAscii("ABC-x") != "abc-x" {
|
|
155
|
+
t.Fatal("station atomic or lowercase helper mismatch")
|
|
156
|
+
}
|
|
157
|
+
anyMeta := nativemetadata.MetadataSchema_create(nativemetadata.MetadataSchema{Any: true, Required: true})
|
|
158
|
+
if Json_schema_station(Json_schema_station_props{
|
|
159
|
+
BlockNever: false,
|
|
160
|
+
Components: components,
|
|
161
|
+
Attribute: JsonSchema{"title": "Any"},
|
|
162
|
+
Metadata: anyMeta,
|
|
163
|
+
})["type"] != nil {
|
|
164
|
+
t.Fatal("any station should synthesize nil type")
|
|
165
|
+
}
|
|
166
|
+
if Json_schema_station(Json_schema_station_props{
|
|
167
|
+
BlockNever: true,
|
|
168
|
+
Components: components,
|
|
169
|
+
Metadata: nativemetadata.MetadataSchema_initialize(),
|
|
170
|
+
}) != nil {
|
|
171
|
+
t.Fatal("blockNever station should return nil for empty metadata")
|
|
172
|
+
}
|
|
173
|
+
if Json_schema_station(Json_schema_station_props{
|
|
174
|
+
BlockNever: false,
|
|
175
|
+
Components: components,
|
|
176
|
+
Metadata: nativemetadata.MetadataSchema_initialize(),
|
|
177
|
+
})["type"] != nil {
|
|
178
|
+
t.Fatal("empty station should synthesize nil type")
|
|
179
|
+
}
|
|
180
|
+
nativeMeta := nativemetadata.MetadataSchema_initialize()
|
|
181
|
+
nativeMeta.Natives = append(nativeMeta.Natives,
|
|
182
|
+
nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "Boolean"}),
|
|
183
|
+
nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "BigInt"}),
|
|
184
|
+
nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "Number"}),
|
|
185
|
+
nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "String"}),
|
|
186
|
+
nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "Date"}),
|
|
187
|
+
)
|
|
188
|
+
if Json_schema_station(Json_schema_station_props{
|
|
189
|
+
Components: components,
|
|
190
|
+
Metadata: nativeMeta,
|
|
191
|
+
}) == nil {
|
|
192
|
+
t.Fatal("native station should produce a schema")
|
|
193
|
+
}
|
|
194
|
+
nativeSkipMeta := iterateAtomic("string")
|
|
195
|
+
nativeSkipMeta.Natives = append(nativeSkipMeta.Natives, nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "String"}))
|
|
196
|
+
if Json_schema_station(Json_schema_station_props{
|
|
197
|
+
Components: components,
|
|
198
|
+
Metadata: nativeSkipMeta,
|
|
199
|
+
}) == nil {
|
|
200
|
+
t.Fatal("native station should skip duplicated atomic native")
|
|
201
|
+
}
|
|
202
|
+
stationObject := nativemetadata.MetadataObjectType_create(nativemetadata.MetadataObjectType{
|
|
203
|
+
Name: "StationObject",
|
|
204
|
+
Properties: []*nativemetadata.MetadataProperty{
|
|
205
|
+
nativemetadata.MetadataProperty_create(nativemetadata.MetadataProperty{Key: literal, Value: stringMeta}),
|
|
206
|
+
},
|
|
207
|
+
})
|
|
208
|
+
stationArray := nativemetadata.MetadataArray_create(nativemetadata.MetadataArray{
|
|
209
|
+
Type: nativemetadata.MetadataArrayType_create(nativemetadata.MetadataArrayType{Name: "StationArray", Value: stringMeta}),
|
|
210
|
+
})
|
|
211
|
+
stationTuple := nativemetadata.MetadataTuple_create(nativemetadata.MetadataTuple{
|
|
212
|
+
Type: nativemetadata.MetadataTupleType_create(nativemetadata.MetadataTupleType{Name: "StationTuple", Elements: []*nativemetadata.MetadataSchema{stringMeta}}),
|
|
213
|
+
})
|
|
214
|
+
stationMeta := nativemetadata.MetadataSchema_initialize()
|
|
215
|
+
stationMeta.Nullable = true
|
|
216
|
+
stationMeta.Escaped = nativemetadata.MetadataEscaped_create(nativemetadata.MetadataEscaped{Original: dateMeta, Returns: stringMeta})
|
|
217
|
+
stationMeta.Templates = append(stationMeta.Templates, taggedTemplate)
|
|
218
|
+
stationMeta.Constants = append(stationMeta.Constants, nativemetadata.MetadataConstant_create(nativemetadata.MetadataConstant{
|
|
219
|
+
Type: "boolean",
|
|
220
|
+
Values: []*nativemetadata.MetadataConstantValue{
|
|
221
|
+
nativemetadata.MetadataConstantValue_create(nativemetadata.MetadataConstantValue{Value: true}),
|
|
222
|
+
},
|
|
223
|
+
}))
|
|
224
|
+
stationMeta.Atomics = append(stationMeta.Atomics,
|
|
225
|
+
nativemetadata.MetadataAtomic_create(nativemetadata.MetadataAtomic{Type: "boolean"}),
|
|
226
|
+
nativemetadata.MetadataAtomic_create(nativemetadata.MetadataAtomic{Type: "bigint"}),
|
|
227
|
+
nativemetadata.MetadataAtomic_create(nativemetadata.MetadataAtomic{Type: "number"}),
|
|
228
|
+
nativemetadata.MetadataAtomic_create(nativemetadata.MetadataAtomic{Type: "string"}),
|
|
229
|
+
)
|
|
230
|
+
stationMeta.Arrays = append(stationMeta.Arrays, stationArray)
|
|
231
|
+
stationMeta.Tuples = append(stationMeta.Tuples, stationTuple)
|
|
232
|
+
stationMeta.Sets = append(stationMeta.Sets, nativemetadata.MetadataSet_create(nativemetadata.MetadataSet{Value: stringMeta}))
|
|
233
|
+
stationMeta.Maps = append(stationMeta.Maps, nativemetadata.MetadataMap_create(nativemetadata.MetadataMap{Key: stringMeta, Value: stringMeta}))
|
|
234
|
+
stationMeta.Objects = append(stationMeta.Objects, nativemetadata.MetadataObject_create(nativemetadata.MetadataObject{Type: stationObject}))
|
|
235
|
+
stationMeta.Aliases = append(stationMeta.Aliases, nativemetadata.MetadataAlias_create(nativemetadata.MetadataAlias{
|
|
236
|
+
Type: nativemetadata.MetadataAliasType_create(nativemetadata.MetadataAliasType{Name: "StationAlias", Value: stringMeta}),
|
|
237
|
+
}))
|
|
238
|
+
if Json_schema_station(Json_schema_station_props{
|
|
239
|
+
Components: components,
|
|
240
|
+
Attribute: JsonSchema{"description": "station"},
|
|
241
|
+
Metadata: stationMeta,
|
|
242
|
+
}) == nil {
|
|
243
|
+
t.Fatal("union station should produce a schema")
|
|
244
|
+
}
|
|
247
245
|
|
|
248
|
-
factory := shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
|
|
249
|
-
input := factory.NewIdentifier("input")
|
|
250
|
-
value := factory.NewIdentifier("value")
|
|
251
|
-
optional := iterateAtomic("string")
|
|
252
|
-
optional.Required = false
|
|
253
|
-
optional.Optional = true
|
|
254
|
-
regular := []nativehelpers.IExpressionEntry{
|
|
255
|
-
{Input: input, Key: literal, Meta: optional, Expression: value},
|
|
256
|
-
{Input: input, Key: iterateLiteral("second"), Meta: stringMeta, Expression: value},
|
|
257
|
-
}
|
|
258
|
-
if len(Stringify_regular_properties(Stringify_regular_propertiesProps{Regular: regular})) == 0 ||
|
|
259
|
-
stringify_regular_properties_condition(regular[0]) == nil ||
|
|
260
|
-
stringify_regular_properties_reduce([]*shimast.Node{input, value}, shimast.KindAmpersandAmpersandToken) == nil ||
|
|
261
|
-
stringify_regular_properties_sequence(optional) != 0 {
|
|
262
|
-
t.Fatal("regular stringify property helper failed")
|
|
263
|
-
}
|
|
264
|
-
dynamicString := nativehelpers.IExpressionEntry{Input: input, Key: stringMeta, Meta: stringMeta, Expression: value}
|
|
265
|
-
dynamicPattern := nativehelpers.IExpressionEntry{Input: input, Key: literal, Meta: stringMeta, Expression: value}
|
|
266
|
-
if Stringify_dynamic_properties([]nativehelpers.IExpressionEntry{dynamicString}, []string{"fixed"}) == nil ||
|
|
267
|
-
Stringify_dynamic_properties([]nativehelpers.IExpressionEntry{dynamicPattern}, nil) == nil ||
|
|
268
|
-
stringify_dynamic_properties_stringify(dynamicString) == nil ||
|
|
269
|
-
stringify_dynamic_properties_binding_pattern() == nil {
|
|
270
|
-
t.Fatal("dynamic stringify property helper failed")
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
object := nativemetadata.MetadataObjectType_create(nativemetadata.MetadataObjectType{
|
|
274
|
-
Name: "IterateObject",
|
|
275
|
-
Properties: []*nativemetadata.MetadataProperty{
|
|
276
|
-
nativemetadata.MetadataProperty_create(nativemetadata.MetadataProperty{Key: literal, Value: stringMeta}),
|
|
277
|
-
nativemetadata.MetadataProperty_create(nativemetadata.MetadataProperty{Key: stringMeta, Value: stringMeta}),
|
|
278
|
-
},
|
|
279
|
-
})
|
|
280
|
-
if Prune_object_properties(object) == nil ||
|
|
281
|
-
prune_object_properties_reduce([]*shimast.Node{input, value}, shimast.KindBarBarToken) == nil ||
|
|
282
|
-
Stringify_native() == nil {
|
|
283
|
-
t.Fatal("prune or native stringify helper failed")
|
|
284
|
-
}
|
|
285
246
|
}
|
|
286
247
|
|
|
287
248
|
func iterateLiteral(value string) *nativemetadata.MetadataSchema {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
249
|
+
meta := nativemetadata.MetadataSchema_initialize()
|
|
250
|
+
meta.Constants = append(meta.Constants, nativemetadata.MetadataConstant_create(nativemetadata.MetadataConstant{
|
|
251
|
+
Type: "string",
|
|
252
|
+
Values: []*nativemetadata.MetadataConstantValue{
|
|
253
|
+
nativemetadata.MetadataConstantValue_create(nativemetadata.MetadataConstantValue{Value: value}),
|
|
254
|
+
},
|
|
255
|
+
}))
|
|
256
|
+
return meta
|
|
296
257
|
}
|
|
297
258
|
|
|
298
259
|
func iterateAtomic(kind string) *nativemetadata.MetadataSchema {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
260
|
+
meta := nativemetadata.MetadataSchema_initialize()
|
|
261
|
+
meta.Atomics = append(meta.Atomics, nativemetadata.MetadataAtomic_create(nativemetadata.MetadataAtomic{Type: kind}))
|
|
262
|
+
return meta
|
|
302
263
|
}
|
|
@@ -55,10 +55,16 @@ func json_schema_create_object_schema(props struct {
|
|
|
55
55
|
required := []string{}
|
|
56
56
|
|
|
57
57
|
for _, property := range props.object.Type.Properties {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
// A member that is only a function has no JSON to describe, so the schema
|
|
59
|
+
// drops it exactly as the serializer does. The condition has to match the
|
|
60
|
+
// serializer's (`StringifyJoiner`) or the two disagree about the same type:
|
|
61
|
+
// `Size()` counts `Functions`, so a pure function member is size 1 and a
|
|
62
|
+
// `Size() == 0` test could never fire for the case it was written to catch,
|
|
63
|
+
// leaving the member described as a `$ref` to an empty component — a schema
|
|
64
|
+
// for a document `json.stringify` never produces. Optionality is not part of
|
|
65
|
+
// the question either; an optional function member has no JSON either
|
|
66
|
+
// (samchon/typia#2270).
|
|
67
|
+
if json_schema_object_function_only(property.Value) {
|
|
62
68
|
continue
|
|
63
69
|
}
|
|
64
70
|
if json_schema_has_any_tag(property.JsDocTags, []string{"hidden", "ignore", "internal"}) {
|
|
@@ -111,7 +117,7 @@ func json_schema_create_object_schema(props struct {
|
|
|
111
117
|
if pattern == nativeutils.PatternUtil.STRING {
|
|
112
118
|
extraMeta.additionalProperties = &pair
|
|
113
119
|
} else {
|
|
114
|
-
extraMeta.
|
|
120
|
+
extraMeta.setPatternProperty(pattern, pair)
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
}
|
|
@@ -152,8 +158,8 @@ func json_schema_join(props struct {
|
|
|
152
158
|
extra json_schema_superfluous
|
|
153
159
|
}) JsonSchema {
|
|
154
160
|
elements := []json_schema_metadata_schema_pair{}
|
|
155
|
-
for _,
|
|
156
|
-
elements = append(elements,
|
|
161
|
+
for _, key := range props.extra.patternPropertyKeys {
|
|
162
|
+
elements = append(elements, props.extra.patternProperties[key])
|
|
157
163
|
}
|
|
158
164
|
if props.extra.additionalProperties != nil {
|
|
159
165
|
elements = append(elements, *props.extra.additionalProperties)
|
|
@@ -179,9 +185,45 @@ func json_schema_join(props struct {
|
|
|
179
185
|
type json_schema_superfluous struct {
|
|
180
186
|
additionalProperties *json_schema_metadata_schema_pair
|
|
181
187
|
patternProperties map[string]json_schema_metadata_schema_pair
|
|
188
|
+
// patternPropertyKeys preserves the first-insertion order of the map while
|
|
189
|
+
// later assignments to an existing pattern replace its value in place.
|
|
190
|
+
patternPropertyKeys []string
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
func (superfluous *json_schema_superfluous) setPatternProperty(pattern string, pair json_schema_metadata_schema_pair) {
|
|
194
|
+
if _, exists := superfluous.patternProperties[pattern]; exists == false {
|
|
195
|
+
superfluous.patternPropertyKeys = append(superfluous.patternPropertyKeys, pattern)
|
|
196
|
+
}
|
|
197
|
+
superfluous.patternProperties[pattern] = pair
|
|
182
198
|
}
|
|
183
199
|
|
|
184
200
|
type json_schema_metadata_schema_pair struct {
|
|
185
201
|
metadata *nativemetadata.MetadataSchema
|
|
186
202
|
schema JsonSchema
|
|
187
203
|
}
|
|
204
|
+
|
|
205
|
+
// json_schema_object_function_only reports whether a member has no JSON to
|
|
206
|
+
// describe because it is only a function, so the schema drops it exactly as the
|
|
207
|
+
// serializer does.
|
|
208
|
+
//
|
|
209
|
+
// The condition has to agree with the serializer's (`StringifyJoiner`) or the
|
|
210
|
+
// two describe the same type differently. Two ways it disagreed: `Size()` counts
|
|
211
|
+
// `Functions`, so a pure function member is size 1 and the previous
|
|
212
|
+
// `Size() == 0` test could never fire for the case it was written to catch; and
|
|
213
|
+
// a named alias of a function type carries `Aliases`, not `Functions`, so the
|
|
214
|
+
// same type reached through `type Consumer = (v: number) => string` survived as
|
|
215
|
+
// a `$ref` to an empty component while the interface spelling of it vanished —
|
|
216
|
+
// two documents for one type, and neither `json.stringify` ever produces
|
|
217
|
+
// (samchon/typia#2270).
|
|
218
|
+
//
|
|
219
|
+
// Optionality is deliberately not part of the question: an optional function
|
|
220
|
+
// member has no JSON either.
|
|
221
|
+
func json_schema_object_function_only(value *nativemetadata.MetadataSchema) bool {
|
|
222
|
+
if value == nil {
|
|
223
|
+
return false
|
|
224
|
+
}
|
|
225
|
+
resolved := nativemetadata.MetadataSchema_unalias(value)
|
|
226
|
+
return len(resolved.Functions) != 0 &&
|
|
227
|
+
resolved.Nullable == false &&
|
|
228
|
+
resolved.Size() == 1
|
|
229
|
+
}
|