microsoft / kiota

OpenAPI based HTTP Client code generator
https://aka.ms/kiota/docs
MIT License
3.03k stars 210 forks source link

Missing typescript imports for createUntypedNodeFromDiscriminatorValue and UntypedNode #4925

Closed LaurentVandenbosch closed 5 months ago

LaurentVandenbosch commented 5 months ago

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

TypeScript

Describe the bug

When I generate my typescript client with Kiota.Builder 1.14 (indirectly through FastEndpoints.ClientGen.Kiota), the resulting typescript files are missing the imports of UntypedNode and createUntypedNodeFromDiscriminatorValue from @microsoft/kiota-abstractions.

Here is an example of a file

/* tslint:disable */
/* eslint-disable */
// Generated by Microsoft Kiota
// @ts-ignore
import { createDomainExceptionResponseFromDiscriminatorValue, createGetWishlistResponseFromDiscriminatorValue, serializeAddToWishlistRequest, serializeDeleteFromWishlistRequest, type AddToWishlistRequest, type DeleteFromWishlistRequest, type DomainExceptionResponse, type GetWishlistResponse } from '../../../../models/';
// @ts-ignore
import { type BaseRequestBuilder, type Parsable, type ParsableFactory, type RequestConfiguration, type RequestInformation, type RequestsMetadata } from '@microsoft/kiota-abstractions';

/**
 * Builds and executes requests for operations under /api/users/{userCodeOr-id}/wishlist
 */
export interface WishlistRequestBuilder extends BaseRequestBuilder<WishlistRequestBuilder> {
    /**
     * @param body The request body
     * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
     * @returns {Promise<UntypedNode>}
     * @throws {DomainExceptionResponse} error when the service returns a 422 status code
     */
     delete(body: DeleteFromWishlistRequest, requestConfiguration?: RequestConfiguration<object> | undefined) : Promise<UntypedNode | undefined>;
    /**
     * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
     * @returns {Promise<GetWishlistResponse>}
     * @throws {DomainExceptionResponse} error when the service returns a 422 status code
     */
     get(requestConfiguration?: RequestConfiguration<object> | undefined) : Promise<GetWishlistResponse | undefined>;
    /**
     * @param body The request body
     * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
     * @returns {Promise<UntypedNode>}
     * @throws {DomainExceptionResponse} error when the service returns a 422 status code
     */
     post(body: AddToWishlistRequest, requestConfiguration?: RequestConfiguration<object> | undefined) : Promise<UntypedNode | undefined>;
    /**
     * @param body The request body
     * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
     * @returns {RequestInformation}
     */
     toDeleteRequestInformation(body: DeleteFromWishlistRequest, requestConfiguration?: RequestConfiguration<object> | undefined) : RequestInformation;
    /**
     * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
     * @returns {RequestInformation}
     */
     toGetRequestInformation(requestConfiguration?: RequestConfiguration<object> | undefined) : RequestInformation;
    /**
     * @param body The request body
     * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
     * @returns {RequestInformation}
     */
     toPostRequestInformation(body: AddToWishlistRequest, requestConfiguration?: RequestConfiguration<object> | undefined) : RequestInformation;
}
/**
 * Uri template for the request builder.
 */
export const WishlistRequestBuilderUriTemplate = "{+baseurl}/api/users/{userCodeOr%2Did}/wishlist";
/**
 * Metadata for all the requests in the request builder.
 */
export const WishlistRequestBuilderRequestsMetadata: RequestsMetadata = {
    delete: {
        uriTemplate: WishlistRequestBuilderUriTemplate,
        responseBodyContentType: "text/plain;q=0.9",
        errorMappings: {
            422: createDomainExceptionResponseFromDiscriminatorValue as ParsableFactory<Parsable>,
        },
        adapterMethodName: "send",
        responseBodyFactory:  createUntypedNodeFromDiscriminatorValue,
        requestBodyContentType: "application/json",
        requestBodySerializer: serializeDeleteFromWishlistRequest,
        requestInformationContentSetMethod: "setContentFromParsable",
    },
    get: {
        uriTemplate: WishlistRequestBuilderUriTemplate,
        responseBodyContentType: "application/json",
        errorMappings: {
            422: createDomainExceptionResponseFromDiscriminatorValue as ParsableFactory<Parsable>,
        },
        adapterMethodName: "send",
        responseBodyFactory:  createGetWishlistResponseFromDiscriminatorValue,
    },
    post: {
        uriTemplate: WishlistRequestBuilderUriTemplate,
        responseBodyContentType: "text/plain;q=0.9",
        errorMappings: {
            422: createDomainExceptionResponseFromDiscriminatorValue as ParsableFactory<Parsable>,
        },
        adapterMethodName: "send",
        responseBodyFactory:  createUntypedNodeFromDiscriminatorValue,
        requestBodyContentType: "application/json",
        requestBodySerializer: serializeAddToWishlistRequest,
        requestInformationContentSetMethod: "setContentFromParsable",
    },
};
/* tslint:enable */
/* eslint-enable */

Expected behavior

The import should include UntypedNode and createUntypedNodeFromDiscriminatorValue

How to reproduce

Difficult to say which condition causes this

Open API description file

No response

Kiota Version

1.14

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

Click to expand log ``` ```

Other information

No response

baywet commented 5 months ago

Hi @LaurentVandenbosch Thank you for using kiota and for reaching out. Can you try with version 1.15 and tell us if you are still seeing the issue please?

LaurentVandenbosch commented 5 months ago

Hello @baywet ,

The issue is still present with 1.15. I have to use 1.12 to not have this issue, because it doesnt use UntypedNode.

andrueastman commented 5 months ago

Authored https://github.com/microsoft/kiota/pull/4927 to resolve.