@typespec/http-server-js 0.58.0-alpha.24-dev.0 → 0.58.0-alpha.24-dev.2
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/dist/generated-defs/package.json.js +2 -2
- package/dist/src/common/reference.js +1 -1
- package/dist/src/common/reference.js.map +1 -1
- package/dist/src/common/serialization/json.js +5 -5
- package/dist/src/common/serialization/json.js.map +1 -1
- package/dist/src/ctx.d.ts.map +1 -1
- package/dist/src/ctx.js +1 -3
- package/dist/src/ctx.js.map +1 -1
- package/dist/src/http/server/index.js +4 -4
- package/dist/src/http/server/index.js.map +1 -1
- package/dist/src/util/differentiate.js +1 -1
- package/dist/src/util/differentiate.js.map +1 -1
- package/generated-defs/package.json.ts +2 -2
- package/package.json +4 -4
- package/src/common/reference.ts +1 -1
- package/src/common/serialization/json.ts +5 -5
- package/src/ctx.ts +1 -3
- package/src/http/server/index.ts +4 -4
- package/src/util/differentiate.ts +1 -1
- package/temp/tsconfig.tsbuildinfo +1 -1
package/src/http/server/index.ts
CHANGED
|
@@ -250,7 +250,7 @@ function* emitRawServerOperation(
|
|
|
250
250
|
let value: string;
|
|
251
251
|
|
|
252
252
|
if (requiresJsonSerialization(ctx, module, body.type)) {
|
|
253
|
-
if (body.type.kind === "Model" && isArrayModelType(
|
|
253
|
+
if (body.type.kind === "Model" && isArrayModelType(body.type)) {
|
|
254
254
|
yield ` const __arrayBody = JSON.parse(body);`;
|
|
255
255
|
yield ` if (!Array.isArray(__arrayBody)) {`;
|
|
256
256
|
yield ` ${names.ctx}.errorHandlers.onInvalidRequest(`;
|
|
@@ -261,7 +261,7 @@ function* emitRawServerOperation(
|
|
|
261
261
|
yield ` return reject();`;
|
|
262
262
|
yield ` }`;
|
|
263
263
|
value = transposeExpressionFromJson(ctx, body.type, `__arrayBody`, module);
|
|
264
|
-
} else if (body.type.kind === "Model" && isRecordModelType(
|
|
264
|
+
} else if (body.type.kind === "Model" && isRecordModelType(body.type)) {
|
|
265
265
|
yield ` const __recordBody = JSON.parse(body);`;
|
|
266
266
|
yield ` if (typeof __recordBody !== "object" || __recordBody === null) {`;
|
|
267
267
|
yield ` ${names.ctx}.errorHandlers.onInvalidRequest(`;
|
|
@@ -641,7 +641,7 @@ function* emitResultProcessingForType(
|
|
|
641
641
|
} else {
|
|
642
642
|
yield `${names.ctx}.response.end(globalThis.JSON.stringify(${names.result}.${bodyCase.camelCase}));`;
|
|
643
643
|
}
|
|
644
|
-
} else if (isArrayModelType(
|
|
644
|
+
} else if (isArrayModelType(target)) {
|
|
645
645
|
const itemType = target.indexer.value;
|
|
646
646
|
|
|
647
647
|
const serializationRequired = isSerializationRequired(
|
|
@@ -659,7 +659,7 @@ function* emitResultProcessingForType(
|
|
|
659
659
|
} else {
|
|
660
660
|
yield `${names.ctx}.response.end(globalThis.JSON.stringify(${names.result}));`;
|
|
661
661
|
}
|
|
662
|
-
} else if (isRecordModelType(
|
|
662
|
+
} else if (isRecordModelType(target)) {
|
|
663
663
|
const itemType = target.indexer.value;
|
|
664
664
|
|
|
665
665
|
const serializationRequired = isSerializationRequired(
|
|
@@ -676,7 +676,7 @@ export function differentiateModelTypes(
|
|
|
676
676
|
let arrayVariant: Model | undefined = undefined;
|
|
677
677
|
|
|
678
678
|
for (const model of models) {
|
|
679
|
-
if (isArrayModelType(
|
|
679
|
+
if (isArrayModelType(model) && model.properties.size === 0 && !arrayVariant) {
|
|
680
680
|
arrayVariant = model;
|
|
681
681
|
continue;
|
|
682
682
|
}
|