-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix serialization and deserialization of composed types in TS #5461
Draft
rkodev
wants to merge
5
commits into
main
Choose a base branch
from
fix/ts-composed-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rkodev
force-pushed
the
fix/ts-composed-types
branch
4 times, most recently
from
October 7, 2024 12:02
8b7c090
to
070f0ac
Compare
Sample builder /* tslint:disable */
/* eslint-disable */
// Generated by Microsoft Kiota
// @ts-ignore
import { type BaseRequestBuilder, type Parsable, type ParsableFactory, type ParseNode, type RequestConfiguration, type RequestInformation, type RequestsMetadata, type SerializationWriter } from '@microsoft/kiota-abstractions';
/**
* Creates a new instance of the appropriate class based on discriminator value
* @param parseNode The parse node to use to read the discriminator value and create the object
* @returns {string[] | string}
*/
// @ts-ignore
export function createSuccessFromDiscriminatorValue(parseNode: ParseNode | undefined) : ((instance?: Parsable) => Record<string, (node: ParseNode) => void>) {
return deserializeIntoSuccess;
}
/**
* The deserialization information for the current model
* @returns {Record<string, (node: ParseNode) => void>}
*/
// @ts-ignore
export function deserializeIntoSuccess(success: Partial<Parsable | string[] | string> | undefined = {}) : Record<string, (node: ParseNode) => void> {
return {
"" : n => { success = n.getCollectionOfPrimitiveValues<string>() ?? n.getStringValue()},
}
}
/**
* Builds and executes requests for operations under /example1
*/
export interface Example1RequestBuilder extends BaseRequestBuilder<Example1RequestBuilder> {
/**
* Test generating error with message property.
* @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
* @returns {Promise<string[] | string>}
*/
post(requestConfiguration?: RequestConfiguration<object> | undefined) : Promise<string[] | string | undefined>;
/**
* Test generating error with message property.
* @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
* @returns {RequestInformation}
*/
toPostRequestInformation(requestConfiguration?: RequestConfiguration<object> | undefined) : RequestInformation;
}
/**
* Serializes information the current object
* @param writer Serialization writer to use to serialize this model
*/
// @ts-ignore
export function serializeSuccess(writer: SerializationWriter, success: Partial<string[] | string> | undefined | null = {}) : void {
if (success === undefined || success === null) return;
switch (true) {
case Array.isArray(success) && (success).every(item => typeof item === 'string') :
writer.writeCollectionOfPrimitiveValues<string>(undefined, success as string[]);
break;
case typeof success === "string":
writer.writeStringValue(undefined, success as string);
break;
}
}
export type Success = string[] | string;
/**
* Uri template for the request builder.
*/
export const Example1RequestBuilderUriTemplate = "{+baseurl}/example1";
/**
* Metadata for all the requests in the request builder.
*/
export const Example1RequestBuilderRequestsMetadata: RequestsMetadata = {
post: {
uriTemplate: Example1RequestBuilderUriTemplate,
responseBodyContentType: "application/json",
adapterMethodName: "send",
responseBodyFactory: createSuccessFromDiscriminatorValue,
},
};
/* tslint:enable */
/* eslint-enable */
|
This was referenced Oct 7, 2024
andrueastman
reviewed
Oct 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also enable the intergration test at
Line 234 in 01710c8
"Rationale": "https://github.com/microsoft/kiota/issues/5256" |
rkodev
force-pushed
the
fix/ts-composed-types
branch
3 times, most recently
from
October 15, 2024 11:15
4dbb95a
to
7971456
Compare
rkodev
force-pushed
the
fix/ts-composed-types
branch
from
October 15, 2024 11:17
7971456
to
58de04a
Compare
Quality Gate passedIssues Measures |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix serialization and deserialization of composed types in TS #5353
Changes made to fix the serializer will include writing an undefined value for the string and and the collection of string
changes made to fix thd deserializer. since
undefined
is not an acceptable key in a record, the serializers will have to invoke the method with an empty key i.e "" to as the assign the value of success to the node