@typespec/openapi3 0.67.0-dev.4 → 0.67.0-dev.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAGzF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GAAG,aAAa,EACpC,MAAM,EAAE,cAAc,GAAG,gBAAgB,EACzC,mBAAmB,EAAE,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,KAAK,MAAM,EACrE,OAAO,EAAE,8BAA8B,GACtC,cAAc,GAAG,gBAAgB,CAuBnC"}
|
package/dist/src/encoding.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { getEncode } from "@typespec/compiler";
|
|
2
2
|
import { ObjectBuilder } from "@typespec/compiler/emitter-framework";
|
|
3
|
+
import { isHeader } from "@typespec/http";
|
|
3
4
|
import { getSchemaForStdScalars } from "./std-scalar-schemas.js";
|
|
4
5
|
export function applyEncoding(program, typespecType, target, getEncodedFieldName, options) {
|
|
6
|
+
const encodedFieldName = getEncodedFieldName(typespecType);
|
|
7
|
+
const targetObject = new ObjectBuilder(target);
|
|
5
8
|
const encodeData = getEncode(program, typespecType);
|
|
6
9
|
if (encodeData) {
|
|
7
|
-
const newTarget = new ObjectBuilder(target);
|
|
8
10
|
const newType = getSchemaForStdScalars(encodeData.type, options);
|
|
9
|
-
|
|
11
|
+
targetObject.type = newType.type;
|
|
10
12
|
// If the target already has a format it takes priority. (e.g. int32)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return newTarget;
|
|
13
|
+
targetObject[encodedFieldName] = mergeFormatAndEncoding(targetObject[encodedFieldName], encodeData.encoding, newType.format);
|
|
14
|
+
return targetObject;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
if (isDateTimeHeader(program, typespecType, targetObject, encodedFieldName)) {
|
|
17
|
+
targetObject[encodedFieldName] = "http-date";
|
|
18
|
+
return targetObject;
|
|
19
|
+
}
|
|
20
|
+
return targetObject;
|
|
16
21
|
}
|
|
17
22
|
function mergeFormatAndEncoding(format, encoding, encodeAsFormat) {
|
|
18
23
|
switch (format) {
|
|
@@ -40,4 +45,10 @@ function mergeFormatAndEncoding(format, encoding, encodeAsFormat) {
|
|
|
40
45
|
return encodeAsFormat ?? encoding ?? format;
|
|
41
46
|
}
|
|
42
47
|
}
|
|
48
|
+
function isDateTimeHeader(program, typespecType, target, encodedFieldName) {
|
|
49
|
+
if (isHeader(program, typespecType) && target[encodedFieldName] === "date-time") {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
43
54
|
//# sourceMappingURL=encoding.js.map
|
package/dist/src/encoding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,SAAS,E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E,CAAC;gBACjB,KAAK,SAAS;oBACZ,OAAO,WAAW,CAAC;gBACrB,KAAK,eAAe;oBAClB,OAAO,UAAU,CAAC;gBACpB,KAAK,SAAS;oBACZ,OAAO,WAAW,CAAC;gBACrB;oBACE,OAAO,QAAQ,CAAC;YACpB,CAAC;QACH,KAAK,UAAU;YACb,QAAQ,QAAQ,EAAE,CAAC;gBACjB,KAAK,SAAS;oBACZ,OAAO,UAAU,CAAC;gBACpB;oBACE,OAAO,cAAc,IAAI,QAAQ,CAAC;YACtC,CAAC;QACH;YACE,OAAO,cAAc,IAAI,QAAQ,IAAI,MAAM,CAAC;IAChD,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CACvB,OAAgB,EAChB,YAAoC,EACpC,MAA0B,EAC1B,gBAAwB;IAExB,IAAI,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,gBAAgB,CAAC,KAAK,WAAW,EAAE,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/openapi3",
|
|
3
|
-
"version": "0.67.0-dev.
|
|
3
|
+
"version": "0.67.0-dev.5",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec library for emitting OpenAPI 3.0 from the TypeSpec REST protocol binding and converting OpenAPI3 to TypeSpec",
|
|
6
6
|
"homepage": "https://typespec.io",
|