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
Generated models do not correctly implement Parsable. TypeScript compiler gives the following error.
Class 'WeatherForecast' incorrectly implements interface 'Parsable'.
Property 'additionalData' is missing in type 'WeatherForecast' but required in type 'Parsable'.ts(2420)
Additional information
Created new ASP.NET/React app using dotnet new react.
Added Swashbuckle with dotnet add package Swashbuckle.AspNetCore
From your command-line, go the ClientApp directory in the project and run npm start. You'll see something like:
TypeScript error in C:/Source/temp/KiotaTest/ClientApp/src/api/weatherForecast/weatherForecast.ts(3,14):
Class 'WeatherForecast' incorrectly implements interface 'Parsable'.
Property 'additionalData' is missing in type 'WeatherForecast' but required in type 'Parsable'. TS2420
1 | import {Parsable, ParseNode, SerializationWriter} from '@microsoft/kiota-abstractions';
2 |
> 3 | export class WeatherForecast implements Parsable {
| ^
4 | private _date?: Date | undefined;
5 | private _summary?: string | undefined;
6 | private _temperatureC?: number | undefined;
The problem seems to be caused by the following line in swagger.json: "additionalProperties": false. Removing this line causes the generation to succeed.
Any service driven by OData is always going to require AdditionalProperties to be true, which is the default. To support non-OData services that are explicit about not supporting AdditionalProperties, I guess we will need to refactor the Parseable interface.
baywet
changed the title
Generation of TypeScript SDK using OpenAPI JSON file generated by Swashbuckle generates invalid models
Parsable interface should be splat
Feb 18, 2022
Generated models do not correctly implement
Parsable
. TypeScript compiler gives the following error.Additional information
dotnet new react
.dotnet add package Swashbuckle.AspNetCore
ConfigureServices
:Configure
just before theapp.UseHttpsRedirection();
line:ClientApp
directory in the project and runnpm start
. You'll see something like:The problem seems to be caused by the following line in swagger.json:
"additionalProperties": false
. Removing this line causes the generation to succeed.Generated OpenAPI
The text was updated successfully, but these errors were encountered: