Skip to content

Commit f5493d1

Browse files
committed
Fix
1 parent bc5a246 commit f5493d1

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

packages/abstractions/src/serialization/parseNodeFactoryRegistry.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,22 @@ export class ParseNodeFactoryRegistry implements ParseNodeFactory {
5656
* @param type the class of the factory to be registered.
5757
* @param backingStoreFactory The backing store factory to use.
5858
*/
59-
public registerDefaultDeserializer(type: new (backingStoreFactory: BackingStoreFactory) => ParseNodeFactory, backingStoreFactory: BackingStoreFactory): void {
59+
public registerDefaultDeserializerWithBackingStoreFactory(type: new (backingStoreFactory: BackingStoreFactory) => ParseNodeFactory, backingStoreFactory: BackingStoreFactory): void {
6060
if (!type) throw new Error("Type is required");
6161
const deserializer = new type(backingStoreFactory);
6262
this.contentTypeAssociatedFactories.set(deserializer.getValidContentType(), deserializer);
6363
}
6464

65+
/**
66+
* Registers the default deserializer to the registry.
67+
* @param type the class of the factory to be registered.
68+
*/
69+
public registerDefaultDeserializer(type: new () => ParseNodeFactory): void {
70+
if (!type) throw new Error("Type is required");
71+
const deserializer = new type();
72+
this.contentTypeAssociatedFactories.set(deserializer.getValidContentType(), deserializer);
73+
}
74+
6575
/**
6676
* Deserializes a buffer into a parsable object
6777
* @param bufferOrString the value to serialize

packages/bundle/src/defaultRequestAdapter.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export class DefaultRequestAdapter extends FetchRequestAdapter {
4949
serializationWriterFactoryRegistry.registerDefaultSerializer(TextSerializationWriterFactory);
5050
serializationWriterFactoryRegistry.registerDefaultSerializer(FormSerializationWriterFactory);
5151
serializationWriterFactoryRegistry.registerDefaultSerializer(MultipartSerializationWriterFactory);
52-
parseNodeFactoryRegistry.registerDefaultDeserializer(JsonParseNodeFactory, backingStoreFactory);
53-
parseNodeFactoryRegistry.registerDefaultDeserializer(TextParseNodeFactory, backingStoreFactory);
54-
parseNodeFactoryRegistry.registerDefaultDeserializer(FormParseNodeFactory, backingStoreFactory);
52+
parseNodeFactoryRegistry.registerDefaultDeserializer(TextParseNodeFactory);
53+
parseNodeFactoryRegistry.registerDefaultDeserializerWithBackingStoreFactory(JsonParseNodeFactory, backingStoreFactory);
54+
parseNodeFactoryRegistry.registerDefaultDeserializerWithBackingStoreFactory(FormParseNodeFactory, backingStoreFactory);
5555
}
5656
}

packages/serialization/json/src/browser/jsonParseNodeFactory.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class JsonParseNodeFactory implements ParseNodeFactory {
1414
* Creates an instance of JsonParseNode.
1515
* @param backingStoreFactory - The factory to create backing stores.
1616
*/
17-
constructor(private readonly backingStoreFactory: BackingStoreFactory) {}
17+
constructor(private readonly backingStoreFactory?: BackingStoreFactory) {}
1818

1919
public getValidContentType(): string {
2020
return "application/json";

packages/serialization/text/src/textParseNodeFactory.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55
* -------------------------------------------------------------------------------------------
66
*/
77

8-
import { BackingStoreFactory, type ParseNode, type ParseNodeFactory } from "@microsoft/kiota-abstractions";
8+
import { type ParseNode, type ParseNodeFactory } from "@microsoft/kiota-abstractions";
99

1010
import { TextParseNode } from "./textParseNode";
1111

1212
export class TextParseNodeFactory implements ParseNodeFactory {
13-
/**
14-
* Creates an instance of TextParseNode.
15-
* @param backingStoreFactory - The factory to create backing stores.
16-
*/
17-
constructor(private readonly backingStoreFactory?: BackingStoreFactory) {}
1813
public getValidContentType(): string {
1914
return "text/plain";
2015
}

packages/test/generatedCode/apiClient.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ export function createApiClient(requestAdapter: RequestAdapter) {
4747
}
4848

4949
const backingStoreFactory = requestAdapter.getBackingStoreFactory();
50-
serializationWriterFactory.registerDefaultSerializer( JsonSerializationWriterFactory);
51-
serializationWriterFactory.registerDefaultSerializer( TextSerializationWriterFactory);
52-
serializationWriterFactory.registerDefaultSerializer( FormSerializationWriterFactory);
53-
serializationWriterFactory.registerDefaultSerializer( MultipartSerializationWriterFactory);
54-
parseNodeFactoryRegistry.registerDefaultDeserializer( JsonParseNodeFactory, backingStoreFactory);
55-
parseNodeFactoryRegistry.registerDefaultDeserializer( TextParseNodeFactory, backingStoreFactory);
56-
parseNodeFactoryRegistry.registerDefaultDeserializer( FormParseNodeFactory, backingStoreFactory);
50+
serializationWriterFactory.registerDefaultSerializer(JsonSerializationWriterFactory);
51+
serializationWriterFactory.registerDefaultSerializer(TextSerializationWriterFactory);
52+
serializationWriterFactory.registerDefaultSerializer(FormSerializationWriterFactory);
53+
serializationWriterFactory.registerDefaultSerializer(MultipartSerializationWriterFactory);
54+
parseNodeFactoryRegistry.registerDefaultDeserializer(TextParseNodeFactory);
55+
parseNodeFactoryRegistry.registerDefaultDeserializerWithBackingStoreFactory(JsonParseNodeFactory, backingStoreFactory);
56+
parseNodeFactoryRegistry.registerDefaultDeserializerWithBackingStoreFactory(FormParseNodeFactory, backingStoreFactory);
5757
if (requestAdapter.baseUrl === undefined || requestAdapter.baseUrl === "") {
5858
requestAdapter.baseUrl = "https://graph.microsoft.com/v1.0";
5959
}

0 commit comments

Comments
 (0)