Skip to content

Commit 64a2798

Browse files
authored
Restore @default constraint shifting (#144)
1 parent 43932f2 commit 64a2798

File tree

4 files changed

+38
-22
lines changed

4 files changed

+38
-22
lines changed

examples/function-calling/arguments/claude.sale.input.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"section_code": "general",
3+
"channels": [
4+
{
5+
"code": "samchon",
6+
"category_codes": [
7+
"2in1_laptops",
8+
"tablets",
9+
"windows_tablets"
10+
]
11+
}
12+
],
313
"opened_at": null,
414
"closed_at": null,
515
"content": {
@@ -25,22 +35,12 @@
2535
],
2636
"files": []
2737
},
28-
"channels": [
29-
{
30-
"code": "samchon",
31-
"category_codes": [
32-
"electronics",
33-
"laptops",
34-
"2in1_laptops"
35-
]
36-
}
37-
],
3838
"tags": [
3939
"surface",
40-
"laptop",
4140
"tablet",
4241
"2-in-1",
43-
"microsoft"
42+
"microsoft",
43+
"windows"
4444
],
4545
"units": [
4646
{
@@ -99,7 +99,7 @@
9999
],
100100
"stocks": [
101101
{
102-
"name": "i3/8GB/128GB",
102+
"name": "Surface Pro 9 (i3/8GB/128GB)",
103103
"price": {
104104
"nominal": 1000000,
105105
"real": 899000
@@ -121,7 +121,7 @@
121121
]
122122
},
123123
{
124-
"name": "i3/16GB/256GB",
124+
"name": "Surface Pro 9 (i3/16GB/256GB)",
125125
"price": {
126126
"nominal": 1200000,
127127
"real": 1099000
@@ -143,7 +143,7 @@
143143
]
144144
},
145145
{
146-
"name": "i3/16GB/512GB",
146+
"name": "Surface Pro 9 (i3/16GB/512GB)",
147147
"price": {
148148
"nominal": 1400000,
149149
"real": 1299000
@@ -165,7 +165,7 @@
165165
]
166166
},
167167
{
168-
"name": "i5/16GB/256GB",
168+
"name": "Surface Pro 9 (i5/16GB/256GB)",
169169
"price": {
170170
"nominal": 1500000,
171171
"real": 1399000
@@ -187,7 +187,7 @@
187187
]
188188
},
189189
{
190-
"name": "i5/32GB/512GB",
190+
"name": "Surface Pro 9 (i5/32GB/512GB)",
191191
"price": {
192192
"nominal": 1800000,
193193
"real": 1699000
@@ -209,7 +209,7 @@
209209
]
210210
},
211211
{
212-
"name": "i7/16GB/512GB",
212+
"name": "Surface Pro 9 (i7/16GB/512GB)",
213213
"price": {
214214
"nominal": 1800000,
215215
"real": 1699000
@@ -231,7 +231,7 @@
231231
]
232232
},
233233
{
234-
"name": "i7/32GB/512GB",
234+
"name": "Surface Pro 9 (i7/32GB/512GB)",
235235
"price": {
236236
"nominal": 2000000,
237237
"real": 1899000

examples/function-calling/schemas/claude.sale.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
},
195195
"units": {
196196
"title": "List of units",
197-
"description": "List of units.\n\nRecords about individual product composition informations that are sold\nin the sale. Each {@link IShoppingSaleUnit unit} record has configurable\n{@link IShoppingSaleUnitOption options},\n{@link IShoppingSaleUnitOptionCandidate candidate} values for each\noption, and {@link IShoppingSaleUnitStock final stocks} determined by\nselecting every candidate values of each option.",
197+
"description": "List of units.\n\nRecords about individual product composition information that are sold\nin the sale. Each {@link IShoppingSaleUnit unit} record has configurable\n{@link IShoppingSaleUnitOption options},\n{@link IShoppingSaleUnitOptionCandidate candidate} values for each\noption, and {@link IShoppingSaleUnitStock final stocks} determined by\nselecting every candidate values of each option.",
198198
"type": "array",
199199
"items": {
200200
"description": "Creation information of sale unit.\n\n------------------------------\n\nDescription of the current {@link IShoppingSaleUnit.ICreate} type:\n\n> Creation information of sale unit.\n\n------------------------------\n\nDescription of the parent {@link IShoppingSaleUnit} type:\n\n> Product composition information handled in the sale.\n> \n> `IShoppingSaleUnit` is an entity that embodies the \"individual product\"\n> information handled in the {@link IShoppingSale sale}.\n> \n> For reference, the reason why `IShoppingSaleUnit` is separated from\n> {@link IShoppingSaleSnapshot} by an algebraic relationship of 1: N is because\n> there are some cases where multiple products are sold in one listing. This is\n> the case with so-called \"bundled products\".\n> \n> - Bundle from regular product (Mackbook Set)\n> - Main Body\n> - Keyboard\n> - Mouse\n> - Apple Care (Free A/S Voucher)\n> \n> And again, `IShoppingSaleUnit` does not in itself refer to the\n> {@link IShoppingSaleUnitStock final stock} that the\n> {@link IShoppingCustomer customer} will {@link IShoppingOrder purchase}.\n> The final stock can be found only after selecting all given\n> {@link IShoppingSaleUnitOption options} and their\n> {@link IShoppingSaleUnitOptionCandidate candidate values}.\n> \n> For example, even if you buy a Macbook, the final stocks are determined only\n> after selecting all the options (CPU / RAM / SSD), etc.",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@samchon/openapi",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
44
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",
55
"main": "./lib/index.js",
66
"module": "./lib/index.mjs",

src/utils/OpenApiConstraintShifter.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export namespace OpenApiConstraintShifter {
3838
| "exclusiveMinimum"
3939
| "exclusiveMaximum"
4040
| "multipleOf"
41+
| "default"
4142
>,
4243
>(
4344
v: Schema,
@@ -48,6 +49,7 @@ export namespace OpenApiConstraintShifter {
4849
| "exclusiveMinimum"
4950
| "exclusiveMaximum"
5051
| "multipleOf"
52+
| "default"
5153
> => {
5254
const tags: string[] = [];
5355
if (v.exclusiveMinimum === undefined && v.minimum !== undefined) {
@@ -76,6 +78,10 @@ export namespace OpenApiConstraintShifter {
7678
description: v.description,
7779
tags,
7880
});
81+
if (v.default !== undefined) {
82+
tags.push(`@default ${v.default}`);
83+
delete v.default;
84+
}
7985
return v;
8086
};
8187

@@ -88,12 +94,18 @@ export namespace OpenApiConstraintShifter {
8894
| "format"
8995
| "pattern"
9096
| "contentMediaType"
97+
| "default"
9198
>,
9299
>(
93100
v: Schema,
94101
): Omit<
95102
Schema,
96-
"minLength" | "maxLength" | "format" | "pattern" | "contentMediaType"
103+
| "minLength"
104+
| "maxLength"
105+
| "format"
106+
| "pattern"
107+
| "contentMediaType"
108+
| "default"
97109
> => {
98110
const tags: string[] = [];
99111
if (v.minLength !== undefined) {
@@ -116,6 +128,10 @@ export namespace OpenApiConstraintShifter {
116128
tags.push(`@contentMediaType ${v.contentMediaType}`);
117129
delete v.contentMediaType;
118130
}
131+
if (v.default !== undefined) {
132+
tags.push(`@default ${v.default}`);
133+
delete v.default;
134+
}
119135
v.description = writeTagWithDescription({
120136
description: v.description,
121137
tags,

0 commit comments

Comments
 (0)