Closed sword-jin closed 9 months ago
Hi everyone, I feel like I have a similar issue:
Some generated files (3 files in particular) throw the same error: Cannot find name 'createGuidFromDiscriminatorValue'.
For example output\subscription\createTrial\item\index.ts
/* tslint:disable */
/* eslint-disable */
// Generated by Microsoft Kiota
// @ts-ignore
import { createProblemDetailsFromDiscriminatorValue, serializeMspSubscriptionCmd, type MspSubscriptionCmd, type ProblemDetails } from '../../../models/';
// @ts-ignore
import { type BaseRequestBuilder, type Parsable, type ParsableFactory, type RequestConfiguration, type RequestInformation, type RequestsMetadata } from '@microsoft/kiota-abstractions';
// @ts-ignore
import { type Guid } from 'guid-typescript';
/**
* Builds and executes requests for operations under /Subscription/CreateTrial/{mspSubscriptionTechnicalId}
*/
export interface WithMspSubscriptionTechnicalItemRequestBuilder extends BaseRequestBuilder<WithMspSubscriptionTechnicalItemRequestBuilder> {
/**
* @param body The request body
* @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
* @returns {Promise<Guid>}
* @throws {ProblemDetails} error when the service returns a 400 status code
* @throws {ProblemDetails} error when the service returns a 404 status code
*/
post(body: MspSubscriptionCmd, requestConfiguration?: RequestConfiguration<object> | undefined) : Promise<Guid | undefined>;
/**
* @param body The request body
* @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
* @returns {RequestInformation}
*/
toPostRequestInformation(body: MspSubscriptionCmd, requestConfiguration?: RequestConfiguration<object> | undefined) : RequestInformation;
}
/**
* Uri template for the request builder.
*/
export const WithMspSubscriptionTechnicalItemRequestBuilderUriTemplate = "{+baseurl}/Subscription/CreateTrial/{mspSubscriptionTechnicalId}";
/**
* Metadata for all the requests in the request builder.
*/
export const WithMspSubscriptionTechnicalItemRequestBuilderRequestsMetadata: RequestsMetadata = {
post: {
uriTemplate: WithMspSubscriptionTechnicalItemRequestBuilderUriTemplate,
responseBodyContentType: "text/plain;q=0.9",
errorMappings: {
400: createProblemDetailsFromDiscriminatorValue as ParsableFactory<Parsable>,
404: createProblemDetailsFromDiscriminatorValue as ParsableFactory<Parsable>,
},
adapterMethodName: "send",
responseBodyFactory: createGuidFromDiscriminatorValue,
requestBodyContentType: "application/json-patch+json",
requestBodySerializer: serializeMspSubscriptionCmd,
requestInformationContentSetMethod: "setContentFromParsable",
},
};
/* tslint:enable */
/* eslint-enable */
We can indeed see that createGuidFromDiscriminatorValue
was never declared nor imported (I could not find any export named as such anyway).
I wish I could help some more but I'm not that familiar with how kiota's generation work, don't hesitate to ask me for more information.
Thanks for your help!
"@microsoft/kiota-abstractions": "^1.0.0-preview.50",
"@microsoft/kiota-http-fetchlibrary": "^1.0.0-preview.49",
"@microsoft/kiota-serialization-form": "^1.0.0-preview.39",
"@microsoft/kiota-serialization-json": "^1.0.0-preview.50",
"@microsoft/kiota-serialization-multipart": "^1.0.0-preview.28",
"@microsoft/kiota-serialization-text": "^1.0.0-preview.47",
EDIT: I just found this issue that looks similar as well: https://github.com/microsoft/kiota/issues/4018 maybe it can help
EDIT 2:
I'm noticing that this error appears for the 3 endpoints from which I'm returning ActionResult<Guid>
, maybe this is related?
EDIT 3:
After replacing my endoints with ActionResult<GuidDTO>
, using the following class, the ts files are correctly generated!
using System;
namespace Watsoft.Backend.API.Controllers
{
public class GuidDTO
{
public Guid Guid { get; set; }
}
}
FINAL EDIT: Created seperate issue here: https://github.com/microsoft/kiota/issues/4508
related to: https://github.com/microsoft/kiota/issues/4018
I am using this openapi:
I got this error:
The generated code is: