You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using kiota with the Bing News API, we get errors that doesn't allow assigning read-only props because they are read-only :
bingNews/models/response.ts:43:14 - error TS2540: Cannot assign to '_webSearchUrl' because it is a read-only property.
43 this._webSearchUrl = value;
~~~~~~~~~~~~~
at createTSError (/home/slevert/source/sebastienlevert/KiotaApp/src/js/node_modules/ts-node/src/index.ts:859:12)
at reportTSError (/home/slevert/source/sebastienlevert/KiotaApp/src/js/node_modules/ts-node/src/index.ts:863:19)
at getOutput (/home/slevert/source/sebastienlevert/KiotaApp/src/js/node_modules/ts-node/src/index.ts:1077:36)
at Object.compile (/home/slevert/source/sebastienlevert/KiotaApp/src/js/node_modules/ts-node/src/index.ts:1433:41)
at Module.m._compile (/home/slevert/source/sebastienlevert/KiotaApp/src/js/node_modules/ts-node/src/index.ts:1617:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1203:10)
at Object.require.extensions.<computed> [as .ts] (/home/slevert/source/sebastienlevert/KiotaApp/src/js/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1027:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Module.require (node:internal/modules/cjs/loader:1051:19) {
diagnosticCodes: [ 2540 ]
The generated model :
import{Identifiable}from'./index';import{Parsable,ParseNode,SerializationWriter}from'@microsoft/kiota-abstractions';/** Defines a response. All schemas that could be returned at the root of a response should inherit from this */exportclassResponseextendsIdentifiableimplementsParsable{/** The URL To Bing's search result for this item. */privatereadonly_webSearchUrl?: string|undefined;/** * Instantiates a new Response and sets the default values. */publicconstructor(){super();};/** * The deserialization information for the current model * @returns a Record<string, (node: ParseNode) => void> */publicgetFieldDeserializers() : Record<string,(node: ParseNode)=>void>{return{...super.getFieldDeserializers(),"webSearchUrl": n=>{this.webSearchUrl=n.getStringValue();},};};/** * Serializes information the current object * @param writer Serialization writer to use to serialize this model */publicserialize(writer: SerializationWriter) : void{if(!writer)thrownewError("writer cannot be undefined");super.serialize(writer);};/** * Gets the webSearchUrl property value. The URL To Bing's search result for this item. * @returns a string */publicgetwebSearchUrl(){returnthis._webSearchUrl;};/** * Sets the webSearchUrl property value. The URL To Bing's search result for this item. * @param value Value to set for the webSearchUrl property. */publicsetwebSearchUrl(value: string|undefined){this._webSearchUrl=value;};}
I would assume this._webSearchUrl should not be a read-only prop as it's being set later.
I used the following command to generate the models :
@sebastienlevert can you test again for this one, I believe I already solved that a while ago since setting readonly was wrong. The reason it was wrong is that even though it's readonly from an API perspective, we still need to be able to set it from a model perspective when deserializing from the API.
When using kiota with the Bing News API, we get errors that doesn't allow assigning read-only props because they are read-only :
The generated model :
I would assume
this._webSearchUrl
should not be a read-only prop as it's being set later.I used the following command to generate the models :
The text was updated successfully, but these errors were encountered: